Files
typeshed/stdlib/3.4/enum.pyi
Semyon Proshev fed4e03e53 Add __new__ to str and int stubs in both Pythons. (#1352)
* Update default values to `...` in `__init__` and `__new__` in `int` and `str`.
* Add `__new__` to `enum.IntEnum` to override inherited `__new__`.
* Add `type: ignore` comment to `IntEnum`
2017-06-12 20:53:32 -07:00

61 lines
2.2 KiB
Python

import sys
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
_T = TypeVar('_T', bound=Enum)
_S = TypeVar('_S', bound=Type[Enum])
class EnumMeta(type, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]):
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
def __contains__(self, member: Any) -> bool: ...
def __getitem__(self: Type[_T], name: str) -> _T: ...
@property
def __members__(self: Type[_T]) -> Mapping[str, _T]: ...
class Enum(metaclass=EnumMeta):
def __new__(cls: Type[_T], value: Any) -> _T: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __dir__(self) -> List[str]: ...
def __format__(self, format_spec: str) -> str: ...
def __hash__(self) -> Any: ...
def __reduce_ex__(self, proto: Any) -> Any: ...
name = ... # type: str
value = ... # type: Any
_T1 = TypeVar('_T1')
class IntEnum(int, Enum): # type: ignore
value = ... # type: int
def __new__(cls: Type[_T1], value: Any) -> _T1: ...
def unique(enumeration: _S) -> _S: ...
if sys.version_info >= (3, 6):
_auto_null = ... # type: Any
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
class auto(IntFlag):
value = ... # type: Any
class Flag(Enum):
def __contains__(self: _T, other: _T) -> bool: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __bool__(self) -> bool: ...
def __or__(self: _T, other: _T) -> _T: ...
def __and__(self: _T, other: _T) -> _T: ...
def __xor__(self: _T, other: _T) -> _T: ...
def __invert__(self: _T) -> _T: ...
# The `type: ignore` comment is needed because mypy considers the type
# signatures of several methods defined in int and Flag to be incompatible.
class IntFlag(int, Flag): # type: ignore
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: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__