summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-30 22:22:08 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-30 23:13:20 +0200
commitac5518ac50121c88043ba45ba6fa8f7ece7430c3 (patch)
treee0011e168b01009f128ed0294a3d10830471789c /pylint/checkers/classes.py
parentd23fa78be60cdef41a45ab5070a520387fd74471 (diff)
downloadpylint-git-ac5518ac50121c88043ba45ba6fa8f7ece7430c3.tar.gz
[unused-private-member] Remove boolean in favor of using for/else
See https://github.com/PyCQA/pylint/pull/4642\#discussion_r661712743
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r--pylint/checkers/classes.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index de945b177..c5d631f24 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -905,7 +905,6 @@ a metaclass class method.",
# Check for unused private functions
for function_def in node.nodes_of_class(astroid.FunctionDef):
function_def = cast(astroid.FunctionDef, function_def)
- found = False
if not is_attr_private(function_def.name):
continue
for attribute in node.nodes_of_class(astroid.Attribute):
@@ -915,16 +914,13 @@ a metaclass class method.",
and attribute.scope() != function_def # We ignore recursive calls
and attribute.expr.name in ("self", node.name)
):
- found = True
break
- if not found:
+ else:
+ function_repr = f"{function_def.name}({function_def.args.as_string()})"
self.add_message(
"unused-private-member",
node=function_def,
- args=(
- node.name,
- f"{function_def.name}({function_def.args.as_string()})",
- ),
+ args=(node.name, function_repr),
)
# Check for unused private variables