From 586d5ee132966ce70cf5e31ce2b9030375d9be4e Mon Sep 17 00:00:00 2001 From: vidhyavijayan3 Date: Sat, 19 Apr 2025 18:54:20 +0530 Subject: [PATCH 1/2] Fix base class compatibility for IntFlag in Python 3.11+ to resolve inverted type issue --- stdlib/enum.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 8c88b26a3a2f..c5b7821b329b 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -299,6 +299,7 @@ if sys.version_info >= (3, 11): def __or__(self, other: int) -> Self: ... def __and__(self, other: int) -> Self: ... def __xor__(self, other: int) -> Self: ... + def __invert__(self) -> IntFlag: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ @@ -309,6 +310,7 @@ else: def __or__(self, other: int) -> Self: ... def __and__(self, other: int) -> Self: ... def __xor__(self, other: int) -> Self: ... + def __invert__(self) -> IntFlag: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ From 40986bc8fb901113e904db5b7c469ee7ef12873e Mon Sep 17 00:00:00 2001 From: vidhyavijayan3 Date: Sat, 19 Apr 2025 19:45:52 +0530 Subject: [PATCH 2/2] Addressed the review comments --- stdlib/enum.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index c5b7821b329b..26f198867113 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -299,7 +299,7 @@ if sys.version_info >= (3, 11): def __or__(self, other: int) -> Self: ... def __and__(self, other: int) -> Self: ... def __xor__(self, other: int) -> Self: ... - def __invert__(self) -> IntFlag: ... + def __invert__(self) -> Self: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ @@ -310,7 +310,7 @@ else: def __or__(self, other: int) -> Self: ... def __and__(self, other: int) -> Self: ... def __xor__(self, other: int) -> Self: ... - def __invert__(self) -> IntFlag: ... + def __invert__(self) -> Self: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__