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
Mypy doesn't currently narrow bool types when the value is compared against True or False, so the type of x within the else clause is Union[bool, Foo]. This new capability would need to be added to make the above code type check without error.
For now, you could work around it using the technique you identified, or you can add a assert not isinstance(x, bool) statement in the else clause of the errors method.
Bug Report
I would expect that
errors
andworks
are equal, buterrors
produces an error.Sorry if this is a duplicate, I tried googling it!
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.10&gist=f17cd6e5962f2edd358143dcce83ab51
Expected Behavior
No error
Actual Behavior
Your Environment
See link above - can be reproduced in all versions
The text was updated successfully, but these errors were encountered: