diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-11-25 10:19:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-25 16:19:03 +0100 |
commit | ffdedfe48a73c09e2cf94e91ff51d1fad4c9fc29 (patch) | |
tree | 5aa6890bc498d0ff23190ab26d32037cc3ab0986 /pylint/checkers | |
parent | a6a544613fd6cd28c3213751173f1b0e4205d1c0 (diff) | |
download | pylint-git-ffdedfe48a73c09e2cf94e91ff51d1fad4c9fc29.tar.gz |
Prevent `used-before-assignment` for variables defined in assignment expressions (#7847)
Diffstat (limited to 'pylint/checkers')
-rw-r--r-- | pylint/checkers/variables.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 32843417c..818d625d1 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -738,14 +738,14 @@ scope_type : {self._atomic.scope_type} if any(node.nodes_of_class(nodes.Break)): return True - # If there is no else, then there is no collectively exhaustive set of paths - if not node.orelse: - return False - # Is there an assignment in this node itself, e.g. in named expression? if NamesConsumer._defines_name_raises_or_returns(name, node): return True + # If there is no else, then there is no collectively exhaustive set of paths + if not node.orelse: + return False + return NamesConsumer._branch_handles_name( name, node.body ) and NamesConsumer._branch_handles_name(name, node.orelse) |