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
Guard clause prevents match from seeing that all paths return #12534
In a match statement in which all cases include a return statement, mypy 0.942 falsely reports "Missing return statement [return]" if at least one case includes a guard clause.
To Reproduce
def func(e) -> int:
match e:
case x if True:
return x
case _:
return 0
Or even more simply:
def func(e) -> int:
match e:
case _ if True:
return 0
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
Activity
Improve match narrowing and reachability analysis
Improve match narrowing and reachability analysis
hauntsaninja commentedon 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
Improve match narrowing and reachability analysis (#15882)
hauntsaninja commentedon Aug 19, 2023
I've merged the fix, but if your project is open source, please let me know!