From 2a40d396788a44b8de0e5477b1300a868d28200b Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 21 Jan 2020 18:55:05 -0600 Subject: [PATCH] builtins.pow: improve annotation --- stdlib/2/__builtin__.pyi | 18 ++++++++++-------- stdlib/2and3/builtins.pyi | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 4b238a383fd1..3dd79deb214b 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -1370,14 +1370,16 @@ else: # This is only available after from __future__ import print_function. def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... -@overload -def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y -@overload -def pow(__x: int, __y: int, __z: int) -> Any: ... -@overload -def pow(__x: float, __y: float) -> float: ... -@overload -def pow(__x: float, __y: float, __z: float) -> float: ... +if sys.version_info >= (3, 8): + @overload + def pow(base: int, exp: int, mod: Optional[int] = ...) -> int: ... + @overload + def pow(base: float, exp: float, mod: None = ...) -> float: ... +else: + @overload + def pow(__base: int, __exp: int, __mod: Optional[int] = ...) -> int: ... + @overload + def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... def quit(code: object = ...) -> NoReturn: ... if sys.version_info < (3,): def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 4b238a383fd1..3dd79deb214b 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -1370,14 +1370,16 @@ else: # This is only available after from __future__ import print_function. def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... -@overload -def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y -@overload -def pow(__x: int, __y: int, __z: int) -> Any: ... -@overload -def pow(__x: float, __y: float) -> float: ... -@overload -def pow(__x: float, __y: float, __z: float) -> float: ... +if sys.version_info >= (3, 8): + @overload + def pow(base: int, exp: int, mod: Optional[int] = ...) -> int: ... + @overload + def pow(base: float, exp: float, mod: None = ...) -> float: ... +else: + @overload + def pow(__base: int, __exp: int, __mod: Optional[int] = ...) -> int: ... + @overload + def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... def quit(code: object = ...) -> NoReturn: ... if sys.version_info < (3,): def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ...