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
Type Narrowing: if val == Literal should always narrow to Literal #16819
FWIW, pyright applies narrowing in this case. Pyright playground. I haven't observed false positives in cases involving invariance, but I agree that could be a small concern if code bases are relying on mypy's current behavior.
Activity
JelleZijlstra commentedon Jan 25, 2024
Agree. There's some risk this could lead to new false positives in cases involving invariance, but on balance this is almost certainly a positive.
erictraut commentedon Jan 25, 2024
FWIW, pyright applies narrowing in this case. Pyright playground. I haven't observed false positives in cases involving invariance, but I agree that could be a small concern if code bases are relying on mypy's current behavior.
CarliJoy commentedon Jan 26, 2024
Actually the full example works already in pyright as expected