Skip to content
Merged
Changes from 1 commit
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
Next Next commit
enum: more updates for Python 3.11
  • Loading branch information
AlexWaygood committed May 14, 2022
commit f02159098f1314c4dfe430ec463ee416ec71c03c
24 changes: 20 additions & 4 deletions stdlib/enum.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__
Comment thread
AlexWaygood marked this conversation as resolved.

if sys.version_info >= (3, 11):
class StrEnum(str, ReprEnum):
Expand Down