1 from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
\r
2 from abc import ABCMeta
\r
5 _S = TypeVar('_S', bound=Type[Enum])
\r
7 # Note: EnumMeta actually subclasses type directly, not ABCMeta.
\r
8 # This is a temporary workaround to allow multiple creation of enums with builtins
\r
9 # such as str as mixins, which due to the handling of ABCs of builtin types, cause
\r
10 # spurious inconsistent metaclass structure. See #1595.
\r
11 class EnumMeta(ABCMeta, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]):
\r
12 def __iter__(self: Type[_T]) -> Iterator[_T]: ...
\r
13 def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
\r
14 def __contains__(self, member: Any) -> bool: ...
\r
15 def __getitem__(self: Type[_T], name: str) -> _T: ...
\r
17 def __members__(self: Type[_T]) -> Mapping[str, _T]: ...
\r
18 def __len__(self) -> int: ...
\r
20 class Enum(metaclass=EnumMeta):
\r
21 def __new__(cls: Type[_T], value: Any) -> _T: ...
\r
22 def __repr__(self) -> str: ...
\r
23 def __str__(self) -> str: ...
\r
24 def __dir__(self) -> List[str]: ...
\r
25 def __format__(self, format_spec: str) -> str: ...
\r
26 def __hash__(self) -> Any: ...
\r
27 def __reduce_ex__(self, proto: Any) -> Any: ...
\r
29 name = ... # type: str
\r
30 value = ... # type: Any
\r
32 class IntEnum(int, Enum):
\r
33 value = ... # type: int
\r
35 def unique(enumeration: _S) -> _S: ...
\r