From b588d43a32e4582871d26c9396777f6f918eac36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E8=91=89?= Date: Wed, 6 Mar 2019 22:31:53 +0800 Subject: [PATCH] Add sunder names to enum (#2822) Closes #2766 --- stdlib/3/enum.pyi | 21 +++++++++++++++------ third_party/2/enum.pyi | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/stdlib/3/enum.pyi b/stdlib/3/enum.pyi index febc0dd5a..404da0292 100644 --- a/stdlib/3/enum.pyi +++ b/stdlib/3/enum.pyi @@ -21,6 +21,18 @@ class EnumMeta(ABCMeta): def __len__(self) -> int: ... class Enum(metaclass=EnumMeta): + name: str + value: Any + _name_: str + _value_: Any + if sys.version_info >= (3, 7): + _ignore_: Union[str, List[str]] + if sys.version_info >= (3, 6): + _order_: str + @classmethod + def _missing_(cls, value: object) -> Any: ... + @staticmethod + def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... def __new__(cls: Type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... @@ -29,20 +41,17 @@ class Enum(metaclass=EnumMeta): def __hash__(self) -> Any: ... def __reduce_ex__(self, proto: object) -> Any: ... - name = ... # type: str - value = ... # type: Any - class IntEnum(int, Enum): - value = ... # type: int + value: int def unique(enumeration: _S) -> _S: ... if sys.version_info >= (3, 6): - _auto_null = ... # type: Any + _auto_null: Any # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() class auto(IntFlag): - value = ... # type: Any + value: Any class Flag(Enum): def __contains__(self: _T, other: _T) -> bool: ... diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index febc0dd5a..404da0292 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -21,6 +21,18 @@ class EnumMeta(ABCMeta): def __len__(self) -> int: ... class Enum(metaclass=EnumMeta): + name: str + value: Any + _name_: str + _value_: Any + if sys.version_info >= (3, 7): + _ignore_: Union[str, List[str]] + if sys.version_info >= (3, 6): + _order_: str + @classmethod + def _missing_(cls, value: object) -> Any: ... + @staticmethod + def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... def __new__(cls: Type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... @@ -29,20 +41,17 @@ class Enum(metaclass=EnumMeta): def __hash__(self) -> Any: ... def __reduce_ex__(self, proto: object) -> Any: ... - name = ... # type: str - value = ... # type: Any - class IntEnum(int, Enum): - value = ... # type: int + value: int def unique(enumeration: _S) -> _S: ... if sys.version_info >= (3, 6): - _auto_null = ... # type: Any + _auto_null: Any # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() class auto(IntFlag): - value = ... # type: Any + value: Any class Flag(Enum): def __contains__(self: _T, other: _T) -> bool: ...