Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mhumetskyi opened this issue Jul 1, 2021 · 1 comment · Fixed by #4669
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@mhumetskyi
Copy link
Contributor

#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)]
@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code labels Jul 1, 2021
@mhumetskyi mhumetskyi changed the title Similarities false negative with "ignore-signatures" option enabled and functions with docstring-only bodies Similarities checker with "ignore-signatures" option enabled ignores functions with docstring-only bodies Jul 4, 2021
@mhumetskyi
Copy link
Contributor Author

@Pierre-Sassoulas I have opened PR with a proposed fix 🙃

Will be glad if anybody could have a look.

Thanks!

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.9.4 milestone Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
2 participants