Skip to content

Commit d4b21ef

Browse files
elazargJelleZijlstra
authored andcommitted
Derive EnumMeta from ABCMeta (#1598)
Avoid inconsistent metaclass structure for enum mixins due to #1595 - e.g. mypy/#2824
1 parent 6865c24 commit d4b21ef

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎stdlib/3.4/enum.pyi‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import sys
22
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
3+
from abc import ABCMeta
34

45
_T = TypeVar('_T', bound=Enum)
56
_S = TypeVar('_S', bound=Type[Enum])
67

7-
class EnumMeta(type, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]):
8+
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
9+
# This is a temporary workaround to allow multiple creation of enums with builtins
10+
# such as str as mixins, which due to the handling of ABCs of builtin types, cause
11+
# spurious inconsistent metaclass structure. See #1595.
12+
class EnumMeta(ABCMeta, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]):
813
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
914
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
1015
def __contains__(self, member: Any) -> bool: ...

0 commit comments

Comments
 (0)