-
-
Couldn't load subscription status.
- Fork 1.2k
Closed
Labels
Enhancement ✨Improvement to a componentImprovement to a componentduplicate-codeRelated to code duplication checkerRelated to code duplication checker
Milestone
Description
Bug description
Function decorators are not ignored by the similarities checker when the "ignore-signatures" option is enabled.
For me, it makes sense to ignore them as well as parameterized decorators might be applied to many different functions and look almost the same. For example, some frameworks use decorators to make declare API handlers functions like in the following example:
app = FastAPI()
@app.put(
"/get-something",
status_code=200,
responses={
status.HTTP_400_BAD_REQUEST: {
"model": HTTPExceptionResponseModel,
},
status.HTTP_404_NOT_FOUND: {
"model": HTTPExceptionResponseModel,
},
status.HTTP_409_CONFLICT: {
"model": HTTPExceptionResponseModel,
},
},
)
def get_something(task_id: str, response: Response):
passIt should be easy to fix it, I am going to open PR, but the main question is is it a bug or it was intentionally implemented this way?
Steps to reproduce
Given multiple files:
module\
__init__.py
a.py
b.py
a.py:
@decorator1(
arg1=1,
arg2="2",
arg3=True,
arg4=None,
arg5="",
)
def func_a():
"""Example func."""b.py:
@decorator1(
arg1=1,
arg2="2",
arg3=True,
arg4=None,
arg5="",
)
def func_b():
"""Example func."""Command used
pylint --disable=all --enable=similarities --ignore-signatures=yes modulePylint output
************* Module module.b
module/b.py:1:0: R0801: Similar lines in 2 files
==module.a:0
==module.b:0
@decorator1(
arg1=1,
arg2="2",
arg3=True,
arg4=None,
arg5="",
) (duplicate-code)
------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 7.50/10, -2.50)Expected behavior
duplicate-code error shouldn't be reported in this case.
Pylint version
pylint 2.9.6
astroid 2.6.6
Python 3.8.2 (default, Jun 8 2021, 11:59:35)Metadata
Metadata
Assignees
Labels
Enhancement ✨Improvement to a componentImprovement to a componentduplicate-codeRelated to code duplication checkerRelated to code duplication checker