From 7ac2fec48da4193c34d1026894171d709af3298e Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Sun, 2 Dec 2018 03:39:00 +0530 Subject: [PATCH 1/3] builtins.pyi: Return complex from __(r)pow__() Fixes #1406 --- stdlib/3/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 6d6483904a79..6b4fcb4c3f31 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -196,7 +196,7 @@ 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: ... + def __pow__(self, x: float) -> complex: ... def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... def __rmul__(self, x: float) -> float: ... @@ -204,7 +204,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) -> float: ... + def __rpow__(self, x: float) -> complex: ... def __getnewargs__(self) -> Tuple[float]: ... @overload def __round__(self) -> int: ... From a862513e43563e70800abc2b189ebd19859b5d6f Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Sun, 2 Dec 2018 03:53:12 +0530 Subject: [PATCH 2/3] builtins.pyi: Return complex from __(r)pow__() Fixes #1406 --- stdlib/3/builtins.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 6b4fcb4c3f31..14bf00b00173 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -196,6 +196,9 @@ class float: def __truediv__(self, x: float) -> float: ... def __mod__(self, x: float) -> float: ... def __divmod__(self, x: float) -> Tuple[float, float]: ... + @overload + def __pow__(self, x: int) -> float: ... + @overload def __pow__(self, x: float) -> complex: ... def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... From c5f5af83be15ad05c4e89fd1529102a9cdfa3a10 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Mon, 3 Dec 2018 17:15:31 +0530 Subject: [PATCH 3/3] builtins.pyi: Return float from __(r)pow__() This add a comment to the __pow__() function. Fixes #1406 --- stdlib/3/builtins.pyi | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 14bf00b00173..709bd5f7046a 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -196,10 +196,7 @@ class float: def __truediv__(self, x: float) -> float: ... def __mod__(self, x: float) -> float: ... def __divmod__(self, x: float) -> Tuple[float, float]: ... - @overload - def __pow__(self, x: int) -> float: ... - @overload - def __pow__(self, x: float) -> complex: ... + def __pow__(self, x: float) -> float: ... # Returns complex if self is negative and x is not whole def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... def __rmul__(self, x: float) -> float: ... @@ -207,7 +204,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) -> complex: ... + def __rpow__(self, x: float) -> float: ... def __getnewargs__(self) -> Tuple[float]: ... @overload def __round__(self) -> int: ...