mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
enum: Correct IntFlag mro on 3.11+ (#8334)
This commit is contained in:
@@ -181,6 +181,8 @@ class Enum(metaclass=EnumMeta):
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class ReprEnum(Enum): ...
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
_IntEnumBase = ReprEnum
|
||||
else:
|
||||
_IntEnumBase = Enum
|
||||
@@ -222,14 +224,26 @@ class Flag(Enum):
|
||||
__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: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
if sys.version_info >= (3, 11):
|
||||
# The body of the class is the same, but the base classes are different.
|
||||
class IntFlag(int, ReprEnum, Flag, boundary=KEEP):
|
||||
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: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
else:
|
||||
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: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class StrEnum(str, ReprEnum):
|
||||
|
||||
Reference in New Issue
Block a user