Skip to content

Commit 963f76d

Browse files
authored
Derive EnumMeta from ABCMeta
Avoid inconsistent metaclass structure for enum mixins due to python#1595 - e.g. mypy/python#2824
1 parent 6865c24 commit 963f76d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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 an 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)