mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Type the constructor of IntEnum and IntFlag (#5217)
These should only accept integers or enum members.
This commit is contained in:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user