Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Enum Iterable (etc.) only structurally #1755

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions stdlib/3.4/enum.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
from typing import List, Any, TypeVar, Union, Iterator, TypeVar, Generic, Type, Sized, Mapping
from abc import ABCMeta

_T = TypeVar('_T', bound=Enum)
Expand All @@ -9,10 +9,11 @@ _S = TypeVar('_S', bound=Type[Enum])
# 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]):
# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
class EnumMeta(ABCMeta, Sized):
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
def __contains__(self, member: Any) -> bool: ...
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]: ...
Expand Down