mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
Add EnumMeta.__bool__ (#7206)
Most Python objects evaluate as falsey if they have length 0, but an enum class is truthy even if it has length 0.
Source code: 841c77d802/Lib/enum.py (L353)
This commit is contained in:
@@ -5,6 +5,7 @@ from abc import ABCMeta
|
||||
from builtins import property as _builtins_property
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
from typing import Any, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S", bound=type[Enum])
|
||||
@@ -54,6 +55,7 @@ class EnumMeta(ABCMeta):
|
||||
@_builtins_property
|
||||
def __members__(self: type[_T]) -> types.MappingProxyType[str, _T]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __bool__(self) -> Literal[True]: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
# Simple value lookup
|
||||
@overload # type: ignore[override]
|
||||
|
||||
Reference in New Issue
Block a user