From 146d291c4524bb9cf56b79bfab12063c13f9a510 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 11 Sep 2018 12:28:54 +0200 Subject: [PATCH] Return Any from float.__(r)pow__ __pow__ will return a float or complex value, depending on the input values. While float is a subtype of complex, it will be inconvenient for callers to handle a complex return value. Closes #1406 --- stdlib/3/builtins.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 78c598592c77..22614453e5de 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -175,7 +175,10 @@ 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) -> float: ... + @overload + def __pow__(self, x: int) -> float: ... + @overload + def __pow__(self, x: float) -> Any: ... # -> Union[float, complex] def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... def __rmul__(self, x: float) -> float: ... @@ -183,7 +186,8 @@ 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) -> float: ... + # -> Union[float, complex] + def __rpow__(self, x: float) -> Any: ... @overload def __round__(self) -> int: ... @overload