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
Describe the bug
With a variable foo typed as T | None, the statement isinstance(foo, NoneType) does not narrow foo to be None.
Similarly, a match statement with a case NoneType() arm fails to narrow.
Describe the bug
With a variable
foo
typed asT | None
, the statementisinstance(foo, NoneType)
does not narrowfoo
to beNone
.Similarly, a match statement with a
case NoneType()
arm fails to narrow.To Reproduce
I get an identical error using a match statement as below:
Expected behavior
I would not expect mypy to give an error; I'd expect mypy to narrow
foo
asNone
in the second arm of the if-elif block above.Additional context
I've opened a similar issue against pyright: microsoft/pyright#4402.
Environment
The text was updated successfully, but these errors were encountered: