Open JanczarKurek opened 1 year ago
I ran into this on 1.11 with:
from typing import Any
ruff: dict[str, Any] = {"src": ["src"], "other": True}
match ruff:
case {"src": ["src"]}:
print("got it!")
It's fine with dict[str, object]
, but the Any
makes it unreachable.
Bug Report When trying to use pattern matching statements that contain list-type matches mypy emits bogus "unreachable" errors.
To Reproduce The following code
generates error
when run with option
--warn-unreachable
. Curiously it is enough to hint at a possibility ofl
being a list by doingto make the error disappear.
Expected Behavior Both snippets of code should emit no errors as it is clearly possible to match
l
if it is a list.Actual Behavior The following error is generated
My Environment
--warn-unreachable