Open EugeneZelenko opened 1 year ago
Thank you for opening the issue, it's still happening on main.
Another example using StrEnum
:
import enum
class Foo(enum.StrEnum):
ABC = enum.auto()
DEF = enum.auto()
bar = Foo.ABC
bar = Foo.DEF
results in:
R0204: Redefinition of bar type from Foo.ABC to Foo.DEF (redefined-variable-type)
Looks like pylint assumes that the type is Foo.ABC
instead of just Foo
. Sometimes it will assume str
instead of the StrEnum
type. Annotations don't help here.
import enum
class Foo(enum.StrEnum):
ABC = enum.auto()
DEF = enum.auto()
def return_enum():
return Foo("DEF")
bar = Foo.ABC
if True:
bar = return_enum()
results in:
R0204: Redefinition of bar type from Foo.ABC to str (redefined-variable-type)
Thank you for reporting this, I am also running into this issue.
Bug description
redefined-variable-type
shows weir warning forenum.IntEnum
:Command used
Pylint output
Expected behavior
If check meant redefinition from
None
toTransition
, such warnings should be shown for every assignment. If not, warning should not be there.Pylint version