==
Narrows the type of an Enum in an if-elif block when following an is
#9786
Labels
==
Narrows the type of an Enum in an if-elif block when following an is
#9786
is
and==
work strangely together when narrowing the type of anEnum
in an if-elif block. It is known that you need to useis
rather than==
to narrow the type of anEnum
, but it seems if theif
statement usesis
then theelif
can have==
and still narrow the type of the variable.To Reproduce
This is compared to how have come to expect
==
to work with an enum where it will not narrow the type.Interestingly this doesn't just occur when an
is
is used in theif
. It can occur in anelif
and still "propogate" its narrowing ability to the following==
's.Expected Behavior
==
would either narrow the type of an enum or not and it would not depend on whether or not it was preceded by anis
.Actual Behavior
==
narrows the type of an enum only when it is preceded by anis
.Your Environment
--strict
will both demonstrate this behaviormypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: