Open
Description
Please consider
import typing as tp
import enum
@enum.unique
class ColorIndex(enum.IntEnum):
BLACK = 0
GREY = 1
WHITE = 2
def _missing_(cls, value: object) -> tp.Any:
return ColorIndex.BLACK
then mypy shows very confusing error (both signatures, for the subclass and the superclass, are the same)
$ mypy t.py
t.py:10: error: Signature of "_missing_" incompatible with supertype "Enum"
t.py:10: note: Superclass:
t.py:10: note: def _missing_(cls, value: object) -> Any
t.py:10: note: Subclass:
t.py:10: note: def _missing_(cls, value: object) -> Any
Found 1 error in 1 file (checked 1 source file)
The real issue is that _missing_
should be decorated with classmethod
.
Python 3.10.1, mypy 0.930.