-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-possibly-undefinedpossibly-undefined error codepossibly-undefined error code
Description
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
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 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
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-possibly-undefinedpossibly-undefined error codepossibly-undefined error code