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
"Statement is unreachable" when doing match on type objects #18524
Hello mypy maintainers! I attempted to search for a dupe for this but couldn't find one, apologies if I missed it.
Bug Report
When running mypy with warn_unreachable = true (set in pyproject, but also on CLI), I get what appears to be a false positive for unreachable code on match statements where the matched object is a type and some of the arms are types.
For example (minimized/abstracted from my actual code):
main.py:8: note: Revealed type is "type[Any]"
main.py:11: note: Revealed type is "Never"
main.py:14: note: Revealed type is "Never"
main.py:17: note: Revealed type is "type[builtins.bool]"
main.py:20: error: Statement is unreachable [unreachable]
main.py:23: note: Revealed type is "type[builtins.bool]"
Activity
sterliakov commentedon Jan 24, 2025
That's also
typevstype[Any]issue. Withtype[Any]unreachable warnings are mostly gone, but the output is no better:Rework narrowing logic for equality and identity (#20492)
woodruffw commentedon Jan 16, 2026
Thanks @hauntsaninja!
hauntsaninja commentedon Jan 16, 2026
Technically the OP got fixed by #19338 . The thing I just fixed is sterliakov's case
Add some additional narrowing test cases (#20598)