Type the constructor of IntEnum and IntFlag (#5217)

These should only accept integers or enum members.
This commit is contained in:
Maxime Arthaud
2021-04-14 18:41:07 -07:00
committed by GitHub
parent 901b8cb92d
commit 3536e2a080

View File

@@ -45,6 +45,7 @@ class Enum(metaclass=EnumMeta):
class IntEnum(int, Enum):
value: int
def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ...
def unique(enumeration: _S) -> _S: ...
@@ -53,6 +54,7 @@ _auto_null: Any
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
class auto(IntFlag):
value: Any
def __new__(cls: Type[_T]) -> _T: ...
class Flag(Enum):
def __contains__(self: _T, other: _T) -> bool: ...
@@ -65,6 +67,7 @@ class Flag(Enum):
def __invert__(self: _T) -> _T: ...
class IntFlag(int, Flag):
def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ...
def __or__(self: _T, other: Union[int, _T]) -> _T: ...
def __and__(self: _T, other: Union[int, _T]) -> _T: ...
def __xor__(self: _T, other: Union[int, _T]) -> _T: ...