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
in this case, it's safe to narrow to Foo in the else block, because the Literal["a"] cannot have a custom __eq__. this means if a == "a" returns False, there's no chance that a is a Literal["a"], but if it returns True then it's still possible for it to be a Foo because of the Foo.__eq__.
playground
in this case, it's safe to narrow to
Foo
in theelse
block, because theLiteral["a"]
cannot have a custom__eq__
. this means ifa == "a"
returnsFalse
, there's no chance thata
is aLiteral["a"]
, but if it returnsTrue
then it's still possible for it to be aFoo
because of theFoo.__eq__
.therefore, the narrowing should work like this:
this would also be consistent with pyright's behavior: playground
The text was updated successfully, but these errors were encountered: