Too easy to trigger duplicate-code
with multiline destructuring assignments
#10319
Labels
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
Uh oh!
There was an error while loading. Please reload this page.
Bug description
Consider the following:
It's a bit silly to treat such multiline destructuring assignments as "lines" for the purposes of
duplicate-code
/min-similarity-lines
. In particular, I am struggling to come up with a way to refactor this kind of code to "satisfy" pylint.In this case, all the common logic has already been refactored into a separate function and the only thing left is the assignment of the attributes. This can't be fixed by using inheritance, because the
woop
andbee
methods themselves are different (and theBaz1
/Baz2
classes are barely related).I suppose, I could create a separate function
and then use it like
However, this essentially makes
target
an "out parameter" forrun_common_code_and_assign
, which is an antipattern in Python (and setting class members outside the class/module is also kind of yucky, especially ifa_lot_of_attributes
are_protected
or__private
).Command used
Pylint output
Expected behavior
Pylint version
The text was updated successfully, but these errors were encountered: