You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you use a walrus operator in a match statement mypy will complain about an used-before-def for any use of the variable after the first case. (It doesn't complain for the first case)
I'm pretty sure the code is fine and that there's no way the variable is actually undefined. I also realize that I can rewrite the code to be case 5 as value: to work around the issue. Also, I realize the example is trivial but imagine if the 5 was int().
Actual Behavior
main.py:6: error: Name "result" is used before definition [used-before-def]
Your Environment
Mypy version used: mypy 1.0.0 (compiled: yes)
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files):
Python version used: 3.11
The text was updated successfully, but these errors were encountered:
Bug Report
When you use a walrus operator in a
match
statement mypy will complain about an used-before-def for any use of the variable after the first case. (It doesn't complain for the first case)To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=f0900514987ceef340db8076b6319cd8
Expected Behavior
I'm pretty sure the code is fine and that there's no way the variable is actually undefined. I also realize that I can rewrite the code to be
case 5 as value:
to work around the issue. Also, I realize the example is trivial but imagine if the5
wasint()
.Actual Behavior
main.py:6: error: Name "result" is used before definition [used-before-def]
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: