I have this class for auto-name enums.
class AutoNameEnum(Enum):
def _generate_next_value_(name, start, count, last_values):
return name
This is taken straight from the Python documentation on enums.
Usage is like this
class Priority(AutoNameEnum):
LOW = auto()
HIGH = auto()
priority = Priority.LOW
This all works fine and mypy understands everything here. But when I try to put AutoNameEnum
into a separate package I get an error. Specifically, this
from utilities import AutoNameEnum
class Priority(AutoNameEnum):
LOW = auto()
HIGH = auto()
priority = Priority.LOW
results in
Incompatible default for argument "priority" (default has type "auto", argument has type "Priority")
What does this mypy error mean, and why does it only happen when I import the class from a different package?