From f789ee25ad3a887bc8ba98eb0d8bfd0d96f3f0a5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 11 Jun 2018 14:02:17 -0700 Subject: [PATCH] make EnumMeta instantiable (#2118) part of #1476. Verified that len(Enum) is still allowed by mypy. --- stdlib/3.4/enum.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/3.4/enum.pyi b/stdlib/3.4/enum.pyi index 271126006..09b3d8aa6 100644 --- a/stdlib/3.4/enum.pyi +++ b/stdlib/3.4/enum.pyi @@ -11,13 +11,14 @@ _S = TypeVar('_S', bound=Type[Enum]) # such as str as mixins, which due to the handling of ABCs of builtin types, cause # spurious inconsistent metaclass structure. See #1595. # Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself -class EnumMeta(ABCMeta, Sized): +class EnumMeta(ABCMeta): def __iter__(self: Type[_T]) -> Iterator[_T]: ... def __reversed__(self: Type[_T]) -> Iterator[_T]: ... def __contains__(self: Type[_T], member: Any) -> bool: ... def __getitem__(self: Type[_T], name: str) -> _T: ... @property def __members__(self: Type[_T]) -> Mapping[str, _T]: ... + def __len__(self) -> int: ... class Enum(metaclass=EnumMeta): def __new__(cls: Type[_T], value: Any) -> _T: ...