summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
diff options
context:
space:
mode:
authorYu Shao, Pang <p.yushao2@gmail.com>2021-07-25 13:12:29 +0800
committerYu Shao, Pang <p.yushao2@gmail.com>2021-08-01 19:18:50 +0800
commit4ffea0b03f6d9e9feb25585c84b3ba227e53cb05 (patch)
treefdbff33fc5803041d07e7157178830b5bfd6398e /pylint/checkers/classes.py
parente4d624346b1be8ae0600a226d282c806cc130b1d (diff)
downloadpylint-git-4ffea0b03f6d9e9feb25585c84b3ba227e53cb05.tar.gz
Update pr based on review
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r--pylint/checkers/classes.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index bc2048394..e3d921354 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -912,9 +912,8 @@ a metaclass class method.",
parent_scope = function_def.parent.scope()
if isinstance(parent_scope, astroid.FunctionDef):
# Handle nested functions
- outer_fn = parent_scope
if function_def.name in (
- n.name for n in outer_fn.nodes_of_class(astroid.Name)
+ n.name for n in parent_scope.nodes_of_class(astroid.Name)
):
continue
for attribute in node.nodes_of_class(astroid.Attribute):
@@ -940,19 +939,23 @@ a metaclass class method.",
break
else:
name_stack = []
+ outer_level_names = ""
curr = parent_scope
# Generate proper names for nested functions
while curr != node:
name_stack.append(curr.name)
curr = curr.parent.scope()
- function_repr = f"{function_def.name}({function_def.args.as_string()})"
+ if name_stack:
+ outer_level_names = f"{'.'.join(reversed(name_stack))}."
+
+ function_repr = f"{outer_level_names}{function_def.name}({function_def.args.as_string()})"
self.add_message(
"unused-private-member",
node=function_def,
args=(
node.name,
- f"{'.'.join(reversed(name_stack))}{'.' if name_stack else ''}{function_repr}",
+ function_repr,
),
)