make enums support len() (#1139)

This commit is contained in:
Jelle Zijlstra
2017-04-05 08:22:28 -07:00
committed by Guido van Rossum
parent 8510adfe05
commit f7e4cb8c79

View File

@@ -1,10 +1,10 @@
import sys
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized
_T = TypeVar('_T', bound=Enum)
_S = TypeVar('_S', bound=Type[Enum])
class EnumMeta(type, Iterable[Enum]):
class EnumMeta(type, Iterable[Enum], Sized):
def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore
class Enum(metaclass=EnumMeta):