diff options
Diffstat (limited to 'pylint/checkers/utils.py')
| -rw-r--r-- | pylint/checkers/utils.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index ed2c1478c..912cac06c 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -374,13 +374,17 @@ def is_defined_before(var_node: astroid.Name) -> bool: return False -def is_default_argument(node: astroid.node_classes.NodeNG) -> bool: +def is_default_argument( + node: astroid.node_classes.NodeNG, + scope: Optional[astroid.node_classes.NodeNG] = None, +) -> bool: """return true if the given Name node is used in function or lambda default argument's value """ - parent = node.scope() - if isinstance(parent, (astroid.FunctionDef, astroid.Lambda)): - for default_node in parent.args.defaults: + if not scope: + scope = node.scope() + if isinstance(scope, (astroid.FunctionDef, astroid.Lambda)): + for default_node in scope.args.defaults: for default_name_node in default_node.nodes_of_class(astroid.Name): if default_name_node is node: return True |
