-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Assignment expressionRelated to the walrus operator / assignment expressionRelated to the walrus operator / assignment expressionC: undefined-variableIssues related to 'undefined-variable' checkIssues related to 'undefined-variable' checkControl flowRequires control flow understandingRequires control flow understandingEnhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
#5163 added the following test to the test suite for undefined-variable
:
# pylint: disable-next=fixme
# TODO: With better control-flow inference related to NamedExpr we should see that the
# NamedExpr is never called here and the second call to `var` is thus undefined
def typing_and_incorrect_assignment_expression():
"""The variable gets assigned in an assignment expression which is never called"""
var: int
if False:
if (var := 1 ** 2):
print(var)
else:
print(var) # This should raise
Basically, we should be able to recognise when NamedExpr
s have been called. In this case it clearly hasn't and thus var
remains undefined.
Metadata
Metadata
Assignees
Labels
Assignment expressionRelated to the walrus operator / assignment expressionRelated to the walrus operator / assignment expressionC: undefined-variableIssues related to 'undefined-variable' checkIssues related to 'undefined-variable' checkControl flowRequires control flow understandingRequires control flow understandingEnhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation