Skip to content

Commit

Permalink
Fix a false positive of self-assigning-variable on tuple unpacking.
Browse files Browse the repository at this point in the history
Close #3433
  • Loading branch information
PCManticore committed Mar 3, 2020
1 parent 93bc0db commit 8ade2da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Release date: TBA

Close #3373

* Fix a false positive of ``self-assigning-variable`` on tuple unpacking.

Close #3433

* Fix a false positive for ``undefined-variable`` when ``__class__`` is used

Close #3090
Expand Down
3 changes: 3 additions & 0 deletions pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,9 @@ def _check_self_assigning_variable(self, node):
# A complex assignment, so bail out early.
return
targets = targets[0].elts
if len(targets) == 1:
# Unpacking a variable into the same name.
return

if isinstance(node.value, astroid.Name):
if len(targets) != 1:
Expand Down
1 change: 1 addition & 0 deletions tests/functional/s/self_assigning_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Class:


FOO = 1
FOO, = [FOO]


class RedefinedModuleLevel:
Expand Down

0 comments on commit 8ade2da

Please sign in to comment.