Skip to content

Commit

Permalink
Derive EnumMeta from ABCMeta
Browse files Browse the repository at this point in the history
Avoid inconsistent metaclass structure for enum mixins due to python#1595 - e.g. mypy/python#2824
  • Loading branch information
elazarg authored Sep 10, 2017
1 parent 6865c24 commit 88cf09d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stdlib/3.4/enum.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import sys
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
from abc import ABCMeta

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

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

0 comments on commit 88cf09d

Please sign in to comment.