--- /dev/null
+# NB: third_party/3/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!\r
+import sys\r
+from typing import Any, Iterator, List, Mapping, Type, TypeVar, Union\r
+from abc import ABCMeta\r
+\r
+_T = TypeVar('_T')\r
+_S = TypeVar('_S', bound=Type[Enum])\r
+\r
+# Note: EnumMeta actually subclasses type directly, not ABCMeta.\r
+# This is a temporary workaround to allow multiple creation of enums with builtins\r
+# such as str as mixins, which due to the handling of ABCs of builtin types, cause\r
+# spurious inconsistent metaclass structure. See #1595.\r
+# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself\r
+class EnumMeta(ABCMeta):\r
+ def __iter__(self: Type[_T]) -> Iterator[_T]: ...\r
+ def __reversed__(self: Type[_T]) -> Iterator[_T]: ...\r
+ def __contains__(self: Type[_T], member: Any) -> bool: ...\r
+ def __getitem__(self: Type[_T], name: str) -> _T: ...\r
+ @property\r
+ def __members__(self: Type[_T]) -> Mapping[str, _T]: ...\r
+ def __len__(self) -> int: ...\r
+\r
+class Enum(metaclass=EnumMeta):\r
+ def __new__(cls: Type[_T], value: Any) -> _T: ...\r
+ def __repr__(self) -> str: ...\r
+ def __str__(self) -> str: ...\r
+ def __dir__(self) -> List[str]: ...\r
+ def __format__(self, format_spec: str) -> str: ...\r
+ def __hash__(self) -> Any: ...\r
+ def __reduce_ex__(self, proto: Any) -> Any: ...\r
+\r
+ name = ... # type: str\r
+ value = ... # type: Any\r
+\r
+class IntEnum(int, Enum):\r
+ value = ... # type: int\r
+\r
+def unique(enumeration: _S) -> _S: ...\r
+\r
+if sys.version_info >= (3, 6):\r
+ _auto_null = ... # type: Any\r
+\r
+ # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()\r
+ class auto(IntFlag):\r
+ value = ... # type: Any\r
+\r
+ class Flag(Enum):\r
+ def __contains__(self: _T, other: _T) -> bool: ...\r
+ def __repr__(self) -> str: ...\r
+ def __str__(self) -> str: ...\r
+ def __bool__(self) -> bool: ...\r
+ def __or__(self: _T, other: _T) -> _T: ...\r
+ def __and__(self: _T, other: _T) -> _T: ...\r
+ def __xor__(self: _T, other: _T) -> _T: ...\r
+ def __invert__(self: _T) -> _T: ...\r
+\r
+ # The `type: ignore` comment is needed because mypy considers the type\r
+ # signatures of several methods defined in int and Flag to be incompatible.\r
+ class IntFlag(int, Flag): # type: ignore\r
+ def __or__(self: _T, other: Union[int, _T]) -> _T: ...\r
+ def __and__(self: _T, other: Union[int, _T]) -> _T: ...\r
+ def __xor__(self: _T, other: Union[int, _T]) -> _T: ...\r
+ __ror__ = __or__\r
+ __rand__ = __and__\r
+ __rxor__ = __xor__\r