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
{{ message }}
Repository navigation
Two possibly-undefined bugs with match statements #15958
Neither invocation of mypy should result in any errors being emitted. The match statement is an exhaustive match, so there's no possibility that f could be undefined by the end of the match x statement.
Actual Behavior
mypy --enable-error-code=possibly-undefined repro.py produces this output, which seems like a false positive:
> mypy --enable-error-code=possibly-undefined repro.py
repro.py:12: error: Name "f" may be undefined [possibly-undefined]
Found 1 error in 1 file (checked 1 source file)
What's particularly strange, however, is that adding --warn-unreachable makes the error go away:
> mypy --enable-error-code=possibly-undefined --warn-unreachable repro.py
Success: no issues found in 1 source file
It seems like there's two bugs here:
The possibly-undefined error is a false positive
Adding --warn-unreachable to the config reduces the number of possibly-undefined errors emitted by mypy, and it seems like it definitely shouldn't be doing that.
changed the title [-]Two possibly-undefined bugs with `match` statements[/-][+]Two `possibly-undefined` bugs with `match` statements[/+]on Aug 25, 2023
Activity
AlexWaygood commentedon Aug 25, 2023
Hmm, I guess bug (1) that I listed above is a duplicate of #13926. Bug (2) might be new, though :)
[-]Two possibly-undefined bugs with `match` statements[/-][+]Two `possibly-undefined` bugs with `match` statements[/+]hauntsaninja commentedon Aug 28, 2023
Link for myself to pick back up with pdb: python/cpython#108454 (comment)
AlexWaygood commentedon Nov 23, 2023
Fixed in #15995