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
Although narrowing using == is completely valid, and mypy is indeed incorrect here, the more idiomatic way to compare enum values is using is rather than ==. If you use is instead of ==, mypy understands your code flow as you'd expect (mypy playground link here).
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
With the example below, the second
if
doesn't properly narrow the type, it works fine if theLiteral['b']
instead of the enum version.To Reproduce
Expected Behavior
Should report:
Actual Behavior
Reported type is:
Your Environment
mypy 0.910
,mypy 0.941
,mypy 0.950+dev.fd8a15e1abdd2bb4f75c3a6319ebfba233e1fe8e (compiled: no)
mypy t.py
mypy.ini
(and other config files):nothing
Python 3.10.2
Fedora Linux 35
The text was updated successfully, but these errors were encountered: