From 067f171b4cbfdadddbbbb6fe57e39177b6fc04ac Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 8 Jul 2019 11:28:23 +0300 Subject: [PATCH] builtins,numbers: harmonize float.__round__ and Real.__round__ See: https://docs.python.org/3/reference/datamodel.html#object.__round__ https://docs.python.org/3/library/functions.html#round --- stdlib/2/__builtin__.pyi | 4 +--- stdlib/2and3/builtins.pyi | 4 +--- stdlib/2and3/numbers.pyi | 8 ++++++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index daadf8fb040c..36b6711d4056 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -242,9 +242,7 @@ class float: def __getnewargs__(self) -> Tuple[float]: ... if sys.version_info >= (3,): @overload - def __round__(self) -> int: ... - @overload - def __round__(self, ndigits: None) -> int: ... + def __round__(self, ndigits: None = ...) -> int: ... @overload def __round__(self, ndigits: int) -> float: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index daadf8fb040c..36b6711d4056 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -242,9 +242,7 @@ class float: def __getnewargs__(self) -> Tuple[float]: ... if sys.version_info >= (3,): @overload - def __round__(self) -> int: ... - @overload - def __round__(self, ndigits: None) -> int: ... + def __round__(self, ndigits: None = ...) -> int: ... @overload def __round__(self, ndigits: int) -> float: ... diff --git a/stdlib/2and3/numbers.pyi b/stdlib/2and3/numbers.pyi index 50b561c24a32..befe7d53a781 100644 --- a/stdlib/2and3/numbers.pyi +++ b/stdlib/2and3/numbers.pyi @@ -5,7 +5,7 @@ # Note: these stubs are incomplete. The more complex type # signatures are currently omitted. -from typing import Any, Optional, SupportsFloat +from typing import Any, Optional, SupportsFloat, overload from abc import ABCMeta, abstractmethod import sys @@ -70,7 +70,11 @@ class Real(Complex, SupportsFloat): @abstractmethod def __ceil__(self) -> int: ... @abstractmethod - def __round__(self, ndigits: Optional[int] = ...): ... + @overload + def __round__(self, ndigits: None = ...): ... + @abstractmethod + @overload + def __round__(self, ndigits: int): ... def __divmod__(self, other): ... def __rdivmod__(self, other): ... @abstractmethod