mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
enum: More changes for 3.11 (#7862)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from _typeshed import Self, SupportsKeysAndGetItem
|
||||
from abc import ABCMeta
|
||||
from builtins import property as _builtins_property
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
@@ -68,6 +68,16 @@ if sys.version_info >= (3, 11):
|
||||
class _EnumDict(dict[str, Any]):
|
||||
def __init__(self) -> None: ...
|
||||
def __setitem__(self, key: str, value: Any) -> None: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
# See comment above `typing.MutableMapping.update`
|
||||
# for why overloads are preferable to a Union here
|
||||
#
|
||||
# Unlike with MutableMapping.update(), the first argument is required,
|
||||
# hence the type: ignore
|
||||
@overload # type: ignore[override]
|
||||
def update(self, members: SupportsKeysAndGetItem[str, Any], **more_members: Any) -> None: ...
|
||||
@overload
|
||||
def update(self, members: Iterable[tuple[str, Any]], **more_members: Any) -> None: ...
|
||||
|
||||
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
|
||||
# This is a temporary workaround to allow multiple creation of enums with builtins
|
||||
@@ -213,15 +223,21 @@ class Flag(Enum):
|
||||
def __and__(self: Self, other: Self) -> Self: ...
|
||||
def __xor__(self: Self, other: Self) -> Self: ...
|
||||
def __invert__(self: Self) -> Self: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __iter__(self: Self) -> Iterator[Self]: ...
|
||||
def __len__(self) -> int: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
class IntFlag(int, Flag):
|
||||
def __new__(cls: type[Self], value: int) -> Self: ...
|
||||
def __or__(self: Self, other: int) -> Self: ...
|
||||
def __and__(self: Self, other: int) -> Self: ...
|
||||
def __xor__(self: Self, other: int) -> Self: ...
|
||||
def __ror__(self: Self, other: int) -> Self: ...
|
||||
def __rand__(self: Self, other: int) -> Self: ...
|
||||
def __rxor__(self: Self, other: int) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class StrEnum(str, ReprEnum):
|
||||
|
||||
Reference in New Issue
Block a user