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).
Activity
AlexWaygood commentedon Mar 23, 2022
Although narrowing using
==is completely valid, and mypy is indeed incorrect here, the more idiomatic way to compare enum values is usingisrather than==. If you useisinstead of==, mypy understands your code flow as you'd expect (mypy playground link here).You'd just rewrite your
dofunction like so:AlexWaygood commentedon Mar 23, 2022
With regard to mypy not understanding enum narrowing using
==, there's already an open PR by @hauntsaninja to fix that: #11521AlexWaygood commentedon Mar 24, 2022
Closing as a duplicate of #10915