Spurious used-before-def in a specific situation using walrus #14683
Labels
bug
mypy got something wrong
topic-pep-572
PEP 572 (walrus operator)
topic-possibly-undefined
possibly-undefined error code
Bug Report
I'm getting the following mypy error
used-before-def
on the code snippet below:I played around a bit trying to simplify, but there could be other scenarios I haven't explored.
Generalizing what I deem the problem to be:
WHEN:
THEN:
the
used-before-def
error is generated even though there is nothing at all incorrect in this scenario since the new variable would ALWAYS be available.To Reproduce
run
mypy
version 1.0 on the following:Expected Behavior
No error should be generated.
Actual Behavior
pyteal/walrus.py:15 error: Name "x" is used before definition [used-before-def]
Your Environment
Python 3.11.1 running on mac Ventura 13.1
mypy.ini
(and other config files): not relevant IMOThe text was updated successfully, but these errors were encountered: