From e7f5d99206c40690acdfd65caeb7d88204eca15a Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Tue, 26 Apr 2022 00:25:15 +0530 Subject: [PATCH 1/2] Loosen `__pow__` overloads a bit --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index bf1e6cde2c08..e12a61bc1949 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -261,7 +261,7 @@ class int: @overload def __pow__(self, __x: _NegativeInteger, __modulo: None = ...) -> float: ... # positive x -> int; negative x -> float - # return type must be Any as `int | float` causes too many false-positive errors + # return type is `int | float | Any` as `int | float` causes too many false-positive errors @overload def __pow__(self, __x: int, __modulo: None = ...) -> Any: ... def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... @@ -318,7 +318,7 @@ class float: @overload def __pow__(self, __x: int, __mod: None = ...) -> float: ... # positive x -> float; negative x -> complex - # return type must be Any as `float | complex` causes too many false-positive errors + # return type is `float | complex | Any` as `float | complex` causes too many false-positive errors @overload def __pow__(self, __x: float, __mod: None = ...) -> Any: ... def __radd__(self, __x: float) -> float: ... From 7eaf2bc9c41314d50b2311596b9d10c5bfc82d57 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Tue, 26 Apr 2022 00:27:37 +0530 Subject: [PATCH 2/2] Update builtins.pyi --- stdlib/builtins.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index e12a61bc1949..ab8b362ab47c 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -263,8 +263,8 @@ class int: # positive x -> int; negative x -> float # return type is `int | float | Any` as `int | float` causes too many false-positive errors @overload - def __pow__(self, __x: int, __modulo: None = ...) -> Any: ... - def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... + def __pow__(self, __x: int, __modulo: None = ...) -> int | float | Any: ... + def __rpow__(self, __x: int, __mod: int | None = ...) -> int | float | Any: ... def __and__(self, __n: int) -> int: ... def __or__(self, __n: int) -> int: ... def __xor__(self, __n: int) -> int: ... @@ -320,7 +320,7 @@ class float: # positive x -> float; negative x -> complex # return type is `float | complex | Any` as `float | complex` causes too many false-positive errors @overload - def __pow__(self, __x: float, __mod: None = ...) -> Any: ... + def __pow__(self, __x: float, __mod: None = ...) -> float | complex | Any: ... def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -329,7 +329,7 @@ class float: def __rmod__(self, __x: float) -> float: ... def __rdivmod__(self, __x: float) -> tuple[float, float]: ... # Returns complex if the argument is negative. - def __rpow__(self, __x: float, __mod: None = ...) -> Any: ... + def __rpow__(self, __x: float, __mod: None = ...) -> float | complex | Any: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9):