Skip to content

Similarities checker with "ignore-signatures" option enabled ignores functions with docstring-only bodies #4652

@hutsulyk

Description

@hutsulyk

#4648 follow-up.

Steps to reproduce

Given multiple files:

module\
    __init__.py
    a.py
    b.py

a.py:

def example_func(
    arg1,
    arg2,
    arg3,
    arg4,
):
    """Valid function definition with docstring only."""

b.py:

def example_func(
    arg1,
    arg2,
    arg3,
    arg4,
):
    """Valid function definition with docstring only."""

Current behavior

Result of pylint --disable=all --enable=similarities --ignore-signatures=yes module:

************* Module module.b
module/b.py:1:0: R0801: Similar lines in 2 files
==module.a:0
==module.b:0
def example_func(
    arg1,
    arg2,
    arg3,
    arg4,
):
    """Valid function definition with docstring only.""" (duplicate-code)

-----------------------------------
Your code has been rated at 5.00/10

Expected behavior

duplicate-code error shouldn't be reported in this case.

Note: if functions have bodies everything works correctly. You could add pass to the example functions above and no duplicate-code error would be reported.

pylint --version output

Result of pylint --version output:

pylint 2.9.3
astroid 2.6.2
Python 3.8.2 (default, Jun  8 2021, 11:59:35) 
[Clang 12.0.5 (clang-1205.0.22.11)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲False Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions