diff options
author | yushao2 <36848472+yushao2@users.noreply.github.com> | 2021-09-15 01:26:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 19:26:44 +0200 |
commit | 272596b80c8f9cb6ddb6e3f893298f20242a9c32 (patch) | |
tree | 9455f789eda9e34611ece1455787e1e9cfff5433 /pylint/checkers | |
parent | af407c73064c1a9cb3cce5f056fa1e26c9e7b540 (diff) | |
download | pylint-git-272596b80c8f9cb6ddb6e3f893298f20242a9c32.tar.gz |
Fix false positive ``unused-private-member`` for accessing attributes in a class using ``cls`` (#4965)
* Fix false positive ``unused-private-member`` for accessing attributes in
a class using ``cls``
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/checkers')
-rw-r--r-- | pylint/checkers/classes.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 3ce95033e..4e208f064 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -1003,11 +1003,15 @@ a metaclass class method.", if attribute.attrname != assign_attr.attrname: continue - if assign_attr.expr.name == "cls" and attribute.expr.name in [ - "cls", - "self", - ]: - # If assigned to cls.attrib, can be accessed by cls/self + if ( + assign_attr.expr.name + in [ + "cls", + node.name, + ] + and attribute.expr.name in ["cls", "self", node.name] + ): + # If assigned to cls or class name, can be accessed by cls/self/class name break if ( |