-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Guard clause prevents match
from seeing that all paths return
#12534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
bug
mypy got something wrong
topic-match-statement
Python 3.10's match statement
topic-reachability
Detecting unreachable code
Comments
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Aug 16, 2023
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Aug 16, 2023
Opened a PR that should fix this. Are any of the people here encountering this in open source projects? I could use some more match statement coverage in https://github.com/hauntsaninja/mypy_primer |
hauntsaninja
added a commit
that referenced
this issue
Aug 19, 2023
I've merged the fix, but if your project is open source, please let me know! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
mypy got something wrong
topic-match-statement
Python 3.10's match statement
topic-reachability
Detecting unreachable code
Bug Report
In a
match
statement in which allcase
s include a return statement, mypy 0.942 falsely reports "Missing return statement [return]" if at least onecase
includes a guard clause.To Reproduce
Or even more simply:
Expected Behavior
This code should type-check.
Actual Behavior
Notes
If we change the first case to something that does not include a guard clause, like this:
then mypy returns no errors.
Environment
mypy.ini
(and other config files): (none)The text was updated successfully, but these errors were encountered: