From 867bb7a91636fa78aed893a2b977a4a2d771ede4 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 18:50:13 +0000 Subject: [PATCH 1/9] Improve stubs for `__pow__` --- stdlib/builtins.pyi | 53 +++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 503eccf35eef..2c872cd9ab44 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -221,10 +221,14 @@ class int: def __rmod__(self, __x: int) -> int: ... def __rdivmod__(self, __x: int) -> tuple[int, int]: ... @overload + def __pow__(self, __x: int, __modulo: Literal[0]) -> NoReturn: ... + @overload def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... @overload - def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. - def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... + def __pow__(self, __x: Literal[3], __modulo: int | None = ...) -> int: ... + @overload + def __pow__(self, __x: int, __modulo: int | None = ...) -> int | float: ... # Return type can be int or float, depending on x. + def __rpow__(self, __x: int, __mod: int | None = ...) -> int | float: ... def __and__(self, __n: int) -> int: ... def __or__(self, __n: int) -> int: ... def __xor__(self, __n: int) -> int: ... @@ -276,9 +280,13 @@ class float: def __truediv__(self, __x: float) -> float: ... def __mod__(self, __x: float) -> float: ... def __divmod__(self, __x: float) -> tuple[float, float]: ... - def __pow__( - self, __x: float, __mod: None = ... - ) -> float: ... # In Python 3, returns complex if self is negative and x is not whole + if sys.version_info < (3, 0): + def __pow__(self, __x: float, __mod: None = ...) -> float: ... + else: + @overload + def __pow__(self, __x: int, __mod: None = ...) -> float: ... + @overload + def __pow__(self, __x: float, __mod: None = ...) -> float | complex: ... def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -286,7 +294,10 @@ class float: def __rtruediv__(self, __x: float) -> float: ... def __rmod__(self, __x: float) -> float: ... def __rdivmod__(self, __x: float) -> tuple[float, float]: ... - def __rpow__(self, __x: float, __mod: None = ...) -> float: ... + if sys.version_info < (3, 0): + def __rpow__(self, __x: float, __mod: None = ...) -> float: ... + else: + def __rpow__(self, __x: float, __mod: None = ...) -> float | complex: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9): @@ -324,12 +335,12 @@ class complex: def __add__(self, __x: complex) -> complex: ... def __sub__(self, __x: complex) -> complex: ... def __mul__(self, __x: complex) -> complex: ... - def __pow__(self, __x: complex, mod: None = ...) -> complex: ... + def __pow__(self, __x: complex | int | float, mod: None = ...) -> complex: ... def __truediv__(self, __x: complex) -> complex: ... def __radd__(self, __x: complex) -> complex: ... def __rsub__(self, __x: complex) -> complex: ... def __rmul__(self, __x: complex) -> complex: ... - def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ... + def __rpow__(self, __x: complex | int | float, __mod: None = ...) -> complex: ... def __rtruediv__(self, __x: complex) -> complex: ... def __eq__(self, __x: object) -> bool: ... def __ne__(self, __x: object) -> bool: ... @@ -1271,11 +1282,19 @@ class _SupportsPow3(Protocol[_E, _M, _T_co]): if sys.version_info >= (3, 8): @overload - def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative + def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... + @overload + def pow(base: int, exp: Literal[2], mod: None = ...) -> int: ... + @overload + def pow(base: int, exp: Literal[3], mod: None = ...) -> int: ... + @overload + def pow(base: int, exp: int, mod: None = ...) -> int | float: ... # returns int or float depending on whether exp is non-negative @overload def pow(base: int, exp: int, mod: int) -> int: ... @overload - def pow(base: float, exp: float, mod: None = ...) -> float: ... + def pow(base: float, exp: int, mod: None = ...) -> float: ... + @overload + def pow(base: float, exp: float, mod: None = ...) -> float | complex: ... @overload def pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co: ... @overload @@ -1283,13 +1302,19 @@ if sys.version_info >= (3, 8): else: @overload - def pow( - __base: int, __exp: int, __mod: None = ... - ) -> Any: ... # returns int or float depending on whether exp is non-negative + def pow(__base: Any, __exp: Any, __mod: Literal[0]) -> NoReturn: ... + @overload + def pow(__base: int, __exp: Literal[2], __mod: None = ...) -> int: ... + @overload + def pow(__base: int, __exp: Literal[3], __mod: None = ...) -> int: ... + @overload + def pow(__base: int, __exp: int, __mod: None = ...) -> int | float: ... # returns int or float depending on whether exp is non-negative @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload - def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... + def pow(__base: float, __exp: int, __mod: None = ...) -> float: ... + @overload + def pow(__base: float, __exp: float, __mod: None = ...) -> float | complex: ... @overload def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... @overload From cdb959cdadf1b3af3e2dd826a5d994f3a53768e9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 19:06:57 +0000 Subject: [PATCH 2/9] Apply black, address review --- stdlib/builtins.pyi | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 2c872cd9ab44..1da8c2a645f8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -227,7 +227,9 @@ class int: @overload def __pow__(self, __x: Literal[3], __modulo: int | None = ...) -> int: ... @overload - def __pow__(self, __x: int, __modulo: int | None = ...) -> int | float: ... # Return type can be int or float, depending on x. + def __pow__( + self, __x: int, __modulo: int | None = ... + ) -> int | float: ... # Return type can be int or float, depending on x. def __rpow__(self, __x: int, __mod: int | None = ...) -> int | float: ... def __and__(self, __n: int) -> int: ... def __or__(self, __n: int) -> int: ... @@ -280,13 +282,10 @@ class float: def __truediv__(self, __x: float) -> float: ... def __mod__(self, __x: float) -> float: ... def __divmod__(self, __x: float) -> tuple[float, float]: ... - if sys.version_info < (3, 0): - def __pow__(self, __x: float, __mod: None = ...) -> float: ... - else: - @overload - def __pow__(self, __x: int, __mod: None = ...) -> float: ... - @overload - def __pow__(self, __x: float, __mod: None = ...) -> float | complex: ... + @overload + def __pow__(self, __x: int, __mod: None = ...) -> float: ... + @overload + def __pow__(self, __x: float, __mod: None = ...) -> float | complex: ... def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -294,10 +293,7 @@ class float: def __rtruediv__(self, __x: float) -> float: ... def __rmod__(self, __x: float) -> float: ... def __rdivmod__(self, __x: float) -> tuple[float, float]: ... - if sys.version_info < (3, 0): - def __rpow__(self, __x: float, __mod: None = ...) -> float: ... - else: - def __rpow__(self, __x: float, __mod: None = ...) -> float | complex: ... + def __rpow__(self, __x: float, __mod: None = ...) -> float | complex: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9): @@ -1288,7 +1284,9 @@ if sys.version_info >= (3, 8): @overload def pow(base: int, exp: Literal[3], mod: None = ...) -> int: ... @overload - def pow(base: int, exp: int, mod: None = ...) -> int | float: ... # returns int or float depending on whether exp is non-negative + def pow( + base: int, exp: int, mod: None = ... + ) -> int | float: ... # returns int or float depending on whether exp is non-negative @overload def pow(base: int, exp: int, mod: int) -> int: ... @overload @@ -1308,7 +1306,9 @@ else: @overload def pow(__base: int, __exp: Literal[3], __mod: None = ...) -> int: ... @overload - def pow(__base: int, __exp: int, __mod: None = ...) -> int | float: ... # returns int or float depending on whether exp is non-negative + def pow( + __base: int, __exp: int, __mod: None = ... + ) -> int | float: ... # returns int or float depending on whether exp is non-negative @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload From c9786cf8360a3d675cb9bdb98f2b6f5e477442d8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 19:29:50 +0000 Subject: [PATCH 3/9] Change return types to `Any` --- stdlib/builtins.pyi | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 1da8c2a645f8..5147dde60a45 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -227,10 +227,8 @@ class int: @overload def __pow__(self, __x: Literal[3], __modulo: int | None = ...) -> int: ... @overload - def __pow__( - self, __x: int, __modulo: int | None = ... - ) -> int | float: ... # Return type can be int or float, depending on x. - def __rpow__(self, __x: int, __mod: int | None = ...) -> int | float: ... + def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. + def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... def __and__(self, __n: int) -> int: ... def __or__(self, __n: int) -> int: ... def __xor__(self, __n: int) -> int: ... @@ -285,7 +283,7 @@ class float: @overload def __pow__(self, __x: int, __mod: None = ...) -> float: ... @overload - def __pow__(self, __x: float, __mod: None = ...) -> float | complex: ... + def __pow__(self, __x: float, __mod: None = ...) -> Any: ... def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -293,7 +291,7 @@ class float: def __rtruediv__(self, __x: float) -> float: ... def __rmod__(self, __x: float) -> float: ... def __rdivmod__(self, __x: float) -> tuple[float, float]: ... - def __rpow__(self, __x: float, __mod: None = ...) -> float | complex: ... + def __rpow__(self, __x: float, __mod: None = ...) -> Any: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9): @@ -1284,15 +1282,13 @@ if sys.version_info >= (3, 8): @overload def pow(base: int, exp: Literal[3], mod: None = ...) -> int: ... @overload - def pow( - base: int, exp: int, mod: None = ... - ) -> int | float: ... # returns int or float depending on whether exp is non-negative + def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload def pow(base: int, exp: int, mod: int) -> int: ... @overload def pow(base: float, exp: int, mod: None = ...) -> float: ... @overload - def pow(base: float, exp: float, mod: None = ...) -> float | complex: ... + def pow(base: float, exp: float, mod: None = ...) -> Any: ... # return type could be float or complex @overload def pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co: ... @overload @@ -1308,13 +1304,13 @@ else: @overload def pow( __base: int, __exp: int, __mod: None = ... - ) -> int | float: ... # returns int or float depending on whether exp is non-negative + ) -> Any: ... # returns int or float depending on whether exp is non-negative @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload def pow(__base: float, __exp: int, __mod: None = ...) -> float: ... @overload - def pow(__base: float, __exp: float, __mod: None = ...) -> float | complex: ... + def pow(__base: float, __exp: float, __mod: None = ...) -> Any: ... # return type could be float or complex @overload def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... @overload From 83b9b951bdfa3555f5bc51e6253d8d550da8a512 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 19:38:07 +0000 Subject: [PATCH 4/9] Remove overlapping overloads --- stdlib/builtins.pyi | 8 -------- 1 file changed, 8 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 5147dde60a45..dc0c7d141914 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1278,10 +1278,6 @@ if sys.version_info >= (3, 8): @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... @overload - def pow(base: int, exp: Literal[2], mod: None = ...) -> int: ... - @overload - def pow(base: int, exp: Literal[3], mod: None = ...) -> int: ... - @overload def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload def pow(base: int, exp: int, mod: int) -> int: ... @@ -1298,10 +1294,6 @@ else: @overload def pow(__base: Any, __exp: Any, __mod: Literal[0]) -> NoReturn: ... @overload - def pow(__base: int, __exp: Literal[2], __mod: None = ...) -> int: ... - @overload - def pow(__base: int, __exp: Literal[3], __mod: None = ...) -> int: ... - @overload def pow( __base: int, __exp: int, __mod: None = ... ) -> Any: ... # returns int or float depending on whether exp is non-negative From 964511d491094b8f43601e99a0db61c7ca2b3f1b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 19:47:44 +0000 Subject: [PATCH 5/9] cleanup --- stdlib/builtins.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index dc0c7d141914..91a0cfbd1068 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -283,7 +283,7 @@ class float: @overload def __pow__(self, __x: int, __mod: None = ...) -> float: ... @overload - def __pow__(self, __x: float, __mod: None = ...) -> Any: ... + def __pow__(self, __x: float, __mod: None = ...) -> Any: ... # return type could be complex or float depending on x def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -291,7 +291,7 @@ class float: def __rtruediv__(self, __x: float) -> float: ... def __rmod__(self, __x: float) -> float: ... def __rdivmod__(self, __x: float) -> tuple[float, float]: ... - def __rpow__(self, __x: float, __mod: None = ...) -> Any: ... + def __rpow__(self, __x: float, __mod: None = ...) -> float: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9): @@ -1284,7 +1284,7 @@ if sys.version_info >= (3, 8): @overload def pow(base: float, exp: int, mod: None = ...) -> float: ... @overload - def pow(base: float, exp: float, mod: None = ...) -> Any: ... # return type could be float or complex + def pow(base: float, exp: float, mod: None = ...) -> Any: ... # return type could be float or complex depending on x @overload def pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co: ... @overload @@ -1302,7 +1302,7 @@ else: @overload def pow(__base: float, __exp: int, __mod: None = ...) -> float: ... @overload - def pow(__base: float, __exp: float, __mod: None = ...) -> Any: ... # return type could be float or complex + def pow(__base: float, __exp: float, __mod: None = ...) -> Any: ... # return type could be float or complex depending on x @overload def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... @overload From 431741aea3ff27b6e84469f5484db983d37f0fc8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 19:58:39 +0000 Subject: [PATCH 6/9] Address review --- stdlib/builtins.pyi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 91a0cfbd1068..2773843fdac8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -223,9 +223,7 @@ class int: @overload def __pow__(self, __x: int, __modulo: Literal[0]) -> NoReturn: ... @overload - def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... - @overload - def __pow__(self, __x: Literal[3], __modulo: int | None = ...) -> int: ... + def __pow__(self, __x: Literal[2, 3, 4, 5], __modulo: int | None = ...) -> int: ... @overload def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... @@ -329,12 +327,12 @@ class complex: def __add__(self, __x: complex) -> complex: ... def __sub__(self, __x: complex) -> complex: ... def __mul__(self, __x: complex) -> complex: ... - def __pow__(self, __x: complex | int | float, mod: None = ...) -> complex: ... + def __pow__(self, __x: complex | float, mod: None = ...) -> complex: ... def __truediv__(self, __x: complex) -> complex: ... def __radd__(self, __x: complex) -> complex: ... def __rsub__(self, __x: complex) -> complex: ... def __rmul__(self, __x: complex) -> complex: ... - def __rpow__(self, __x: complex | int | float, __mod: None = ...) -> complex: ... + def __rpow__(self, __x: complex | float, __mod: None = ...) -> complex: ... def __rtruediv__(self, __x: complex) -> complex: ... def __eq__(self, __x: object) -> bool: ... def __ne__(self, __x: object) -> bool: ... From 7c57a5a816791f440777643954881312ddefc5d6 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 20:13:13 +0000 Subject: [PATCH 7/9] Complex duck-types for float --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 2773843fdac8..364fa7cbb02b 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -327,12 +327,12 @@ class complex: def __add__(self, __x: complex) -> complex: ... def __sub__(self, __x: complex) -> complex: ... def __mul__(self, __x: complex) -> complex: ... - def __pow__(self, __x: complex | float, mod: None = ...) -> complex: ... + def __pow__(self, __x: complex, mod: None = ...) -> complex: ... def __truediv__(self, __x: complex) -> complex: ... def __radd__(self, __x: complex) -> complex: ... def __rsub__(self, __x: complex) -> complex: ... def __rmul__(self, __x: complex) -> complex: ... - def __rpow__(self, __x: complex | float, __mod: None = ...) -> complex: ... + def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ... def __rtruediv__(self, __x: complex) -> complex: ... def __eq__(self, __x: object) -> bool: ... def __ne__(self, __x: object) -> bool: ... From a264b3f071905679bc7bc787112f9b3f31be7d17 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 20:19:06 +0000 Subject: [PATCH 8/9] Correct oversight --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 364fa7cbb02b..e240d7467188 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1290,7 +1290,7 @@ if sys.version_info >= (3, 8): else: @overload - def pow(__base: Any, __exp: Any, __mod: Literal[0]) -> NoReturn: ... + def pow(__base: int, __exp: int, __mod: Literal[0]) -> NoReturn: ... @overload def pow( __base: int, __exp: int, __mod: None = ... From 226774ae4eaad8a3a5e60e0f67166985780052b2 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 12 Nov 2021 21:02:34 +0000 Subject: [PATCH 9/9] More descriptive comments --- stdlib/builtins.pyi | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index e240d7467188..2393f3c9583b 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -224,8 +224,10 @@ class int: def __pow__(self, __x: int, __modulo: Literal[0]) -> NoReturn: ... @overload def __pow__(self, __x: Literal[2, 3, 4, 5], __modulo: int | None = ...) -> int: ... + # positive x -> int; negative x -> float + # return type must be Any as `int | float` causes too many false-positive errors @overload - def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. + def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... def __and__(self, __n: int) -> int: ... def __or__(self, __n: int) -> int: ... @@ -280,8 +282,10 @@ class float: def __divmod__(self, __x: float) -> tuple[float, 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 @overload - def __pow__(self, __x: float, __mod: None = ...) -> Any: ... # return type could be complex or float depending on x + def __pow__(self, __x: float, __mod: None = ...) -> Any: ... def __radd__(self, __x: float) -> float: ... def __rsub__(self, __x: float) -> float: ... def __rmul__(self, __x: float) -> float: ... @@ -1275,14 +1279,18 @@ class _SupportsPow3(Protocol[_E, _M, _T_co]): if sys.version_info >= (3, 8): @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... + # int base & positive-int exp -> int; int base & negative-int exp -> float + # return type must be Any as `int | float` causes too many false-positive errors @overload - def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative + def pow(base: int, exp: int, mod: None = ...) -> Any: ... @overload def pow(base: int, exp: int, mod: int) -> int: ... @overload def pow(base: float, exp: int, mod: None = ...) -> float: ... + # float base & float exp could return float or complex + # return type must be Any as `float | complex` causes too many false-positive errors @overload - def pow(base: float, exp: float, mod: None = ...) -> Any: ... # return type could be float or complex depending on x + def pow(base: float, exp: float, mod: None = ...) -> Any: ... @overload def pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co: ... @overload @@ -1292,15 +1300,13 @@ else: @overload def pow(__base: int, __exp: int, __mod: Literal[0]) -> NoReturn: ... @overload - def pow( - __base: int, __exp: int, __mod: None = ... - ) -> Any: ... # returns int or float depending on whether exp is non-negative + def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload def pow(__base: float, __exp: int, __mod: None = ...) -> float: ... @overload - def pow(__base: float, __exp: float, __mod: None = ...) -> Any: ... # return type could be float or complex depending on x + def pow(__base: float, __exp: float, __mod: None = ...) -> Any: ... @overload def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... @overload