diff options
author | yushao2 <36848472+yushao2@users.noreply.github.com> | 2021-08-02 03:48:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-01 21:48:27 +0200 |
commit | e7b71cf681fd1aea42c38e0837d19731ed8492ed (patch) | |
tree | 10021f5f9a21f7601538a4094ca91f19322f359f /pylint/checkers/classes.py | |
parent | 7c515808db7298f7f2a1fa3de5abcaab2148e9a5 (diff) | |
download | pylint-git-e7b71cf681fd1aea42c38e0837d19731ed8492ed.tar.gz |
Fix crash for `unused-private-member` when there are nested attributes (#4783)
* Fix crash for `unused-private-member` when there are nested attributes
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r-- | pylint/checkers/classes.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 0e7296de5..fccfd64eb 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -975,7 +975,9 @@ a metaclass class method.", def _check_unused_private_attributes(self, node: astroid.ClassDef) -> None: for assign_attr in node.nodes_of_class(astroid.AssignAttr): assign_attr = cast(astroid.AssignAttr, assign_attr) - if not is_attr_private(assign_attr.attrname): + if not is_attr_private(assign_attr.attrname) or not isinstance( + assign_attr.expr, astroid.Name + ): continue # Logic for checking false positive when using __new__, |