From 8ecb74012a6bf7bb9bbdf96b32a1701aee4089b2 Mon Sep 17 00:00:00 2001 From: David Euresti Date: Sun, 18 Feb 2018 16:59:12 -0800 Subject: [PATCH] Add __divmod__ to numeric types (#1900) Helps with #1889 --- stdlib/2/__builtin__.pyi | 4 ++++ stdlib/2and3/fractions.pyi | 2 ++ stdlib/3/builtins.pyi | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 55fdea25b..46e409f0b 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -101,6 +101,7 @@ class int: def __div__(self, x: int) -> int: ... def __truediv__(self, x: int) -> float: ... def __mod__(self, x: int) -> int: ... + def __divmod__(self, x: int) -> Tuple[int, int]: ... def __radd__(self, x: int) -> int: ... def __rsub__(self, x: int) -> int: ... def __rmul__(self, x: int) -> int: ... @@ -108,6 +109,7 @@ class int: def __rdiv__(self, x: int) -> int: ... def __rtruediv__(self, x: int) -> float: ... def __rmod__(self, x: int) -> int: ... + def __rdivmod__(self, x: int) -> Tuple[int, int]: ... def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x. def __rpow__(self, x: int) -> Any: ... def __and__(self, n: int) -> int: ... @@ -153,6 +155,7 @@ class float: def __div__(self, x: float) -> 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 __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... @@ -161,6 +164,7 @@ class float: def __rdiv__(self, x: float) -> 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 __eq__(self, x: object) -> bool: ... diff --git a/stdlib/2and3/fractions.pyi b/stdlib/2and3/fractions.pyi index e02b5e767..783a001e1 100644 --- a/stdlib/2and3/fractions.pyi +++ b/stdlib/2and3/fractions.pyi @@ -62,6 +62,8 @@ class Fraction(Rational): def __rfloordiv__(self, other) -> int: ... def __mod__(self, other): ... def __rmod__(self, other): ... + def __divmod__(self, other): ... + def __rdivmod__(self, other): ... def __pow__(self, other): ... def __rpow__(self, other): ... diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 96df001f4..2e2ee6c82 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -121,12 +121,14 @@ class int: def __floordiv__(self, x: int) -> int: ... def __truediv__(self, x: int) -> float: ... def __mod__(self, x: int) -> int: ... + def __divmod__(self, x: int) -> Tuple[int, int]: ... def __radd__(self, x: int) -> int: ... def __rsub__(self, x: int) -> int: ... def __rmul__(self, x: int) -> int: ... def __rfloordiv__(self, x: int) -> int: ... def __rtruediv__(self, x: int) -> float: ... def __rmod__(self, x: int) -> int: ... + def __rdivmod__(self, x: int) -> Tuple[int, int]: ... def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x. def __rpow__(self, x: int) -> Any: ... def __and__(self, n: int) -> int: ... @@ -171,6 +173,7 @@ class float: def __floordiv__(self, x: float) -> 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 __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... @@ -178,6 +181,7 @@ class float: def __rfloordiv__(self, x: float) -> 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 __eq__(self, x: object) -> bool: ...