diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 5d76742010f1..761f110cf7f4 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -11,6 +11,7 @@ from typing import ( MutableSet, ItemsView, KeysView, ValuesView ) from abc import abstractmethod, ABCMeta +import numbers _T = TypeVar('_T') _T_co = TypeVar('_T_co', covariant=True) @@ -62,7 +63,7 @@ class type: def mro(self) -> List[type]: ... def __subclasses__(self) -> List[type]: ... -class int(SupportsInt, SupportsFloat, SupportsAbs[int]): +class int(numbers.Integral): @overload def __init__(self) -> None: ... @overload @@ -71,13 +72,13 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __init__(self, x: Union[str, unicode, bytearray], base: int = 10) -> None: ... def bit_length(self) -> int: ... - def __add__(self, x: int) -> int: ... + def __add__(self, x: numbers.Integral) -> int: ... # type: ignore def __sub__(self, x: int) -> int: ... - def __mul__(self, x: int) -> int: ... - def __floordiv__(self, x: int) -> int: ... - def __div__(self, x: int) -> int: ... - def __truediv__(self, x: int) -> float: ... - def __mod__(self, x: int) -> int: ... + def __mul__(self, x: numbers.Integral) -> int: ... # type: ignore + def __floordiv__(self, x: numbers.Integral) -> int: ... # type: ignore + def __div__(self, x: numbers.Integral) -> int: ... # type: ignore + def __truediv__(self, x: numbers.Integral) -> float: ... # type: ignore + def __mod__(self, x: numbers.Integral) -> int: ... # type: ignore def __radd__(self, x: int) -> int: ... def __rsub__(self, x: int) -> int: ... def __rmul__(self, x: int) -> int: ... @@ -85,13 +86,13 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __rdiv__(self, x: int) -> int: ... def __rtruediv__(self, x: int) -> float: ... def __rmod__(self, x: int) -> int: ... - def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x. + def __pow__(self, x: numbers.Integral) -> Any: ... # Return type can be int or float, depending on x. # type: ignore def __rpow__(self, x: int) -> Any: ... - def __and__(self, n: int) -> int: ... - def __or__(self, n: int) -> int: ... - def __xor__(self, n: int) -> int: ... - def __lshift__(self, n: int) -> int: ... - def __rshift__(self, n: int) -> int: ... + def __and__(self, n: numbers.Integral) -> int: ... # type: ignore + def __or__(self, n: numbers.Integral) -> int: ... # type: ignore + def __xor__(self, n: numbers.Integral) -> int: ... # type: ignore + def __lshift__(self, n: numbers.Integral) -> int: ... # type: ignore + def __rshift__(self, n: numbers.Integral) -> int: ... # type: ignore def __rand__(self, n: int) -> int: ... def __ror__(self, n: int) -> int: ... def __rxor__(self, n: int) -> int: ... @@ -103,10 +104,10 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: int) -> bool: ... - def __le__(self, x: int) -> bool: ... - def __gt__(self, x: int) -> bool: ... - def __ge__(self, x: int) -> bool: ... + def __lt__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __le__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __gt__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __ge__(self, x: numbers.Integral) -> bool: ... # type: ignore def __str__(self) -> str: ... def __float__(self) -> float: ... @@ -114,7 +115,7 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __abs__(self) -> int: ... def __hash__(self) -> int: ... -class float(SupportsFloat, SupportsInt, SupportsAbs[float]): +class float(numbers.Real): @overload def __init__(self) -> None: ... @overload @@ -129,14 +130,14 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): @classmethod def fromhex(cls, s: str) -> float: ... - def __add__(self, x: float) -> float: ... + def __add__(self, x: numbers.Real) -> float: ... # type: ignore def __sub__(self, x: float) -> float: ... - def __mul__(self, x: float) -> float: ... - def __floordiv__(self, x: float) -> float: ... - def __div__(self, x: float) -> float: ... - def __truediv__(self, x: float) -> float: ... - def __mod__(self, x: float) -> float: ... - def __pow__(self, x: float) -> float: ... + def __mul__(self, x: numbers.Real) -> float: ... # type: ignore + def __floordiv__(self, x: numbers.Real) -> float: ... # type: ignore + def __div__(self, x: numbers.Real) -> float: ... # type: ignore + def __truediv__(self, x: numbers.Real) -> float: ... # type: ignore + def __mod__(self, x: numbers.Real) -> float: ... # type: ignore + def __pow__(self, x: numbers.Real) -> float: ... # type: ignore def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... def __rmul__(self, x: float) -> float: ... @@ -148,10 +149,10 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: float) -> bool: ... - def __le__(self, x: float) -> bool: ... - def __gt__(self, x: float) -> bool: ... - def __ge__(self, x: float) -> bool: ... + def __lt__(self, x: numbers.Real) -> bool: ... # type: ignore + def __le__(self, x: numbers.Real) -> bool: ... # type: ignore + def __gt__(self, x: numbers.Real) -> bool: ... # type: ignore + def __ge__(self, x: numbers.Real) -> bool: ... # type: ignore def __neg__(self) -> float: ... def __pos__(self) -> float: ... @@ -161,7 +162,7 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __abs__(self) -> float: ... def __hash__(self) -> int: ... -class complex(SupportsAbs[float]): +class complex(numbers.Complex): @overload def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ... @overload @@ -174,12 +175,12 @@ class complex(SupportsAbs[float]): def conjugate(self) -> complex: ... - def __add__(self, x: complex) -> complex: ... + def __add__(self, x: numbers.Complex) -> complex: ... # type: ignore def __sub__(self, x: complex) -> complex: ... - def __mul__(self, x: complex) -> complex: ... - def __pow__(self, x: complex) -> complex: ... - def __div__(self, x: complex) -> complex: ... - def __truediv__(self, x: complex) -> complex: ... + def __mul__(self, x: numbers.Complex) -> complex: ... # type: ignore + def __pow__(self, x: numbers.Complex) -> complex: ... # type: ignore + def __div__(self, x: numbers.Complex) -> complex: ... # type: ignore + def __truediv__(self, x: numbers.Complex) -> complex: ... # type: ignore def __radd__(self, x: complex) -> complex: ... def __rsub__(self, x: complex) -> complex: ... def __rmul__(self, x: complex) -> complex: ... diff --git a/stdlib/2.7/numbers.pyi b/stdlib/2.7/numbers.pyi deleted file mode 100644 index f55611a2af3a..000000000000 --- a/stdlib/2.7/numbers.pyi +++ /dev/null @@ -1,77 +0,0 @@ -# Stubs for numbers (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -class Number: - __metaclass__ = ... # type: Any - __hash__ = ... # type: Any - -class Complex(Number): - def __complex__(self): ... - def __nonzero__(self): ... - def real(self): ... - def imag(self): ... - def __add__(self, other): ... - def __radd__(self, other): ... - def __neg__(self): ... - def __pos__(self): ... - def __sub__(self, other): ... - def __rsub__(self, other): ... - def __mul__(self, other): ... - def __rmul__(self, other): ... - def __div__(self, other): ... - def __rdiv__(self, other): ... - def __truediv__(self, other): ... - def __rtruediv__(self, other): ... - def __pow__(self, exponent): ... - def __rpow__(self, base): ... - def __abs__(self): ... - def conjugate(self): ... - def __eq__(self, other): ... - def __ne__(self, other): ... - -class Real(Complex): - def __float__(self): ... - def __trunc__(self): ... - def __divmod__(self, other): ... - def __rdivmod__(self, other): ... - def __floordiv__(self, other): ... - def __rfloordiv__(self, other): ... - def __mod__(self, other): ... - def __rmod__(self, other): ... - def __lt__(self, other): ... - def __le__(self, other): ... - def __complex__(self): ... - @property - def real(self): ... - @property - def imag(self): ... - def conjugate(self): ... - -class Rational(Real): - def numerator(self): ... - def denominator(self): ... - def __float__(self): ... - -class Integral(Rational): - def __long__(self): ... - def __index__(self): ... - def __pow__(self, exponent, modulus=...): ... - def __lshift__(self, other): ... - def __rlshift__(self, other): ... - def __rshift__(self, other): ... - def __rrshift__(self, other): ... - def __and__(self, other): ... - def __rand__(self, other): ... - def __xor__(self, other): ... - def __rxor__(self, other): ... - def __or__(self, other): ... - def __ror__(self, other): ... - def __invert__(self): ... - def __float__(self): ... - @property - def numerator(self): ... - @property - def denominator(self): ... diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index da952421ee8a..cb318569475a 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -1,6 +1,7 @@ # Stubs for typing (Python 2.7) from abc import abstractmethod, ABCMeta +import numbers # Definitions of special type checking related constructs. Their definition # are not used, so their value does not matter. @@ -48,6 +49,10 @@ _KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. _VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. _T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. +class SupportsComplex(metaclass=ABCMeta): + @abstractmethod + def __complex__(self) -> numbers.Complex: pass + class SupportsInt(metaclass=ABCMeta): @abstractmethod def __int__(self) -> int: ... diff --git a/stdlib/2and3/numbers.pyi b/stdlib/2and3/numbers.pyi new file mode 100644 index 000000000000..419b8ec06609 --- /dev/null +++ b/stdlib/2and3/numbers.pyi @@ -0,0 +1,168 @@ +# Stubs for numbers + +from typing import ( + Any, Optional, + SupportsAbs, SupportsComplex, SupportsFloat, SupportsInt, SupportsRound, +) +from abc import abstractmethod +import sys + + +class Number: ... + +class Complex(Number, SupportsComplex, SupportsAbs[float]): + @property + @abstractmethod + def real(self) -> Complex: ... + @property + @abstractmethod + def imag(self) -> Complex: ... + @abstractmethod + def __add__(self, other: Complex) -> Complex: ... + def __neg__(self) -> Complex: ... + @abstractmethod + def __mul__(self, other: Complex) -> Complex: ... + if sys.version_info >= (3,): + @abstractmethod + def __truediv__(self, other: Complex) -> Complex: ... + else: + @abstractmethod + def __div__(self, other: Complex) -> Complex: ... + @abstractmethod + def conjugate(self) -> Complex: ... + +class Real(Complex, SupportsFloat, SupportsRound): + @abstractmethod + def __trunc__(self) -> int: ... + @abstractmethod + def __floor__(self) -> int: ... + @abstractmethod + def __ceil__(self) -> int: ... + @abstractmethod + def __divmod__(self, other: Real) -> Real: ... + @abstractmethod + def __floordiv__(self, other: Real) -> Real: ... + @abstractmethod + def __mod__(self, other: Real) -> Real: ... + @abstractmethod + def __lt__(self, other: Real) -> bool: ... + @abstractmethod + def __le__(self, other: Real) -> bool: ... + @abstractmethod + def __gt__(self, other: Real) -> bool: ... + @abstractmethod + def __ge__(self, other: Real) -> bool: ... + def __complex__(self) -> Complex: ... # type: ignore + @property + def real(self) -> Real: ... + @property + def imag(self) -> Real: ... + def conjugate(self) -> Real: ... + + @abstractmethod + def __add__(self, other: Real) -> Real: ... # type: ignore + def __neg__(self) -> Real: ... # type: ignore + @abstractmethod + def __mul__(self, other: Real) -> Real: ... # type: ignore + if sys.version_info >= (3,): + @abstractmethod + def __truediv__(self, other: Real) -> Real: ... # type: ignore + else: + @abstractmethod + def __div__(self, other: Real) -> Real: ... # type: ignore + +class Rational(Real): + @property + @abstractmethod + def numerator(self) -> int: ... + @property + @abstractmethod + def denominator(self) -> int: ... + def __float__(self) -> float: ... + + @abstractmethod + def __divmod__(self, other: Rational) -> Rational: ... # type: ignore + @abstractmethod + def __floordiv__(self, other: Rational) -> Rational: ... # type: ignore + @abstractmethod + def __mod__(self, other: Rational) -> Rational: ... # type: ignore + @abstractmethod + def __lt__(self, other: Rational, float) -> bool: ... # type: ignore + @abstractmethod + def __le__(self, other: Rational) -> bool: ... # type: ignore + @abstractmethod + def __gt__(self, other: Rational) -> bool: ... # type: ignore + @abstractmethod + def __ge__(self, other: Rational) -> bool: ... # type: ignore + def __complex__(self) -> Complex: ... # type: ignore + @property + def real(self) -> Rational: ... # type: ignore + @property + def imag(self) -> Rational: ... # type: ignore + def conjugate(self) -> Rational: ... # type: ignore + + @abstractmethod + def __add__(self, other: Rational) -> Rational: ... # type: ignore + def __neg__(self) -> Rational: ... + @abstractmethod + def __mul__(self, other: Rational) -> Rational: ... # type: ignore + if sys.version_info >= (3,): + @abstractmethod + def __truediv__(self, other: Rational) -> Rational: ... # type: ignore + else: + @abstractmethod + def __div__(self, other: Rational) -> Rational: ... # type: ignore + +class Integral(Rational, SupportsInt, SupportsAbs[int]): + @property + def numerator(self) -> int: ... # type: ignore + @property + def denominator(self) -> int: ... # type: ignore + @abstractmethod + def __pow__(self, exponent: float, # type: ignore + modulus: Optional[int] = ...) -> Integral: ... + @abstractmethod + def __lshift__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __rshift__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __and__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __xor__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __or__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __invert__(self) -> Integral: ... # type: ignore + + @abstractmethod + def __divmod__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __floordiv__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __mod__(self, other: Integral) -> Integral: ... # type: ignore + @abstractmethod + def __lt__(self, other: Integral) -> bool: ... # type: ignore + @abstractmethod + def __le__(self, other: Integral) -> bool: ... # type: ignore + @abstractmethod + def __gt__(self, other: Integral) -> bool: ... # type: ignore + @abstractmethod + def __ge__(self, other: Integral) -> bool: ... # type: ignore + def __complex__(self) -> Complex: ... # type: ignore + @property + def real(self) -> Integral: ... # type: ignore + @property + def imag(self) -> Integral: ... # type: ignore + def conjugate(self) -> Integral: ... # type: ignore + + @abstractmethod + def __add__(self, other: Integral) -> Integral: ... # type: ignore + def __neg__(self) -> Integral: ... # type: ignore + @abstractmethod + def __mul__(self, other: Integral) -> Integral: ... # type: ignore + if sys.version_info >= (3,): + @abstractmethod + def __truediv__(self, other: Integral) -> Integral: ... # type: ignore + else: + @abstractmethod + def __div__(self, other: Integral) -> Integral: ... # type: ignore diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 22d9b9cce2f7..8bef2575d10f 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -8,6 +8,7 @@ from typing import ( ) from abc import abstractmethod, ABCMeta from types import TracebackType +import numbers import sys # Note that names imported above are not automatically made visible via the @@ -62,7 +63,7 @@ class type: # implementation seems to be returning a list. def mro(self) -> List[type]: ... -class int(SupportsInt, SupportsFloat, SupportsAbs[int]): +class int(numbers.Integral): def __init__(self, x: Union[SupportsInt, str, bytes] = None, base: int = None) -> None: ... def bit_length(self) -> int: ... def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ... @@ -70,25 +71,25 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def from_bytes(cls, bytes: Sequence[int], byteorder: str, *, signed: bool = ...) -> int: ... # TODO buffer object argument - def __add__(self, x: int) -> int: ... + def __add__(self, x: numbers.Integral) -> int: ... # type: ignore def __sub__(self, x: int) -> int: ... - def __mul__(self, x: int) -> int: ... - def __floordiv__(self, x: int) -> int: ... - def __truediv__(self, x: int) -> float: ... - def __mod__(self, x: int) -> int: ... + def __mul__(self, x: numbers.Integral) -> int: ... # type: ignore + def __floordiv__(self, x: numbers.Integral) -> int: ... # type: ignore + def __truediv__(self, x: numbers.Integral) -> float: ... # type: ignore + def __mod__(self, x: numbers.Integral) -> int: ... # type: ignore 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 __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x. + def __pow__(self, x: numbers.Integral) -> Any: ... # Return type can be int or float, depending on x. # type: ignore def __rpow__(self, x: int) -> Any: ... - def __and__(self, n: int) -> int: ... - def __or__(self, n: int) -> int: ... - def __xor__(self, n: int) -> int: ... - def __lshift__(self, n: int) -> int: ... - def __rshift__(self, n: int) -> int: ... + def __and__(self, n: numbers.Integral) -> int: ... # type: ignore + def __or__(self, n: numbers.Integral) -> int: ... # type: ignore + def __xor__(self, n: numbers.Integral) -> int: ... # type: ignore + def __lshift__(self, n: numbers.Integral) -> int: ... # type: ignore + def __rshift__(self, n: numbers.Integral) -> int: ... # type: ignore def __rand__(self, n: int) -> int: ... def __ror__(self, n: int) -> int: ... def __rxor__(self, n: int) -> int: ... @@ -100,10 +101,10 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: int) -> bool: ... - def __le__(self, x: int) -> bool: ... - def __gt__(self, x: int) -> bool: ... - def __ge__(self, x: int) -> bool: ... + def __lt__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __le__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __gt__(self, x: numbers.Integral) -> bool: ... # type: ignore + def __ge__(self, x: numbers.Integral) -> bool: ... # type: ignore def __str__(self) -> str: ... def __float__(self) -> float: ... @@ -111,7 +112,7 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __abs__(self) -> int: ... def __hash__(self) -> int: ... -class float(SupportsFloat, SupportsInt, SupportsAbs[float]): +class float(numbers.Real): def __init__(self, x: Union[SupportsFloat, str, bytes]=None) -> None: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... @@ -119,13 +120,13 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): @classmethod def fromhex(cls, s: str) -> float: ... - def __add__(self, x: float) -> float: ... + def __add__(self, x: numbers.Real) -> float: ... # type: ignore def __sub__(self, x: float) -> float: ... - def __mul__(self, x: float) -> float: ... - def __floordiv__(self, x: float) -> float: ... - def __truediv__(self, x: float) -> float: ... - def __mod__(self, x: float) -> float: ... - def __pow__(self, x: float) -> float: ... + def __mul__(self, x: numbers.Real) -> float: ... # type: ignore + def __floordiv__(self, x: numbers.Real) -> float: ... # type: ignore + def __truediv__(self, x: numbers.Real) -> float: ... # type: ignore + def __mod__(self, x: numbers.Real) -> float: ... # type: ignore + def __pow__(self, x: numbers.Real) -> float: ... # type: ignore def __radd__(self, x: float) -> float: ... def __rsub__(self, x: float) -> float: ... def __rmul__(self, x: float) -> float: ... @@ -136,10 +137,10 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: float) -> bool: ... - def __le__(self, x: float) -> bool: ... - def __gt__(self, x: float) -> bool: ... - def __ge__(self, x: float) -> bool: ... + def __lt__(self, x: numbers.Real) -> bool: ... # type: ignore + def __le__(self, x: numbers.Real) -> bool: ... # type: ignore + def __gt__(self, x: numbers.Real) -> bool: ... # type: ignore + def __ge__(self, x: numbers.Real) -> bool: ... # type: ignore def __neg__(self) -> float: ... def __pos__(self) -> float: ... @@ -149,7 +150,7 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]): def __abs__(self) -> float: ... def __hash__(self) -> int: ... -class complex(SupportsAbs[float]): +class complex(numbers.Complex): @overload def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ... @overload @@ -162,11 +163,11 @@ class complex(SupportsAbs[float]): def conjugate(self) -> complex: ... - def __add__(self, x: complex) -> complex: ... + def __add__(self, x: numbers.Complex) -> complex: ... # type: ignore def __sub__(self, x: complex) -> complex: ... - def __mul__(self, x: complex) -> complex: ... - def __pow__(self, x: complex) -> complex: ... - def __truediv__(self, x: complex) -> complex: ... + def __mul__(self, x: numbers.Complex) -> complex: ... # type: ignore + def __pow__(self, x: numbers.Complex) -> complex: ... # type: ignore + def __truediv__(self, x: numbers.Complex) -> complex: ... # type: ignore def __radd__(self, x: complex) -> complex: ... def __rsub__(self, x: complex) -> complex: ... def __rmul__(self, x: complex) -> complex: ... diff --git a/stdlib/3/numbers.pyi b/stdlib/3/numbers.pyi deleted file mode 100644 index 8bea0b0222da..000000000000 --- a/stdlib/3/numbers.pyi +++ /dev/null @@ -1,80 +0,0 @@ -# Stubs for numbers (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -class Number: - __hash__ = ... # type: Any - -class Complex(Number): - def __complex__(self): ... - def __bool__(self): ... - @property - def real(self): ... - @property - def imag(self): ... - def __add__(self, other): ... - def __radd__(self, other): ... - def __neg__(self): ... - def __pos__(self): ... - def __sub__(self, other): ... - def __rsub__(self, other): ... - def __mul__(self, other): ... - def __rmul__(self, other): ... - def __truediv__(self, other): ... - def __rtruediv__(self, other): ... - def __pow__(self, exponent): ... - def __rpow__(self, base): ... - def __abs__(self): ... - def conjugate(self): ... - def __eq__(self, other): ... - -class Real(Complex): - def __float__(self): ... - def __trunc__(self): ... - def __floor__(self): ... - def __ceil__(self): ... - def __round__(self, ndigits=None): ... - def __divmod__(self, other): ... - def __rdivmod__(self, other): ... - def __floordiv__(self, other): ... - def __rfloordiv__(self, other): ... - def __mod__(self, other): ... - def __rmod__(self, other): ... - def __lt__(self, other): ... - def __le__(self, other): ... - def __complex__(self): ... - @property - def real(self): ... - @property - def imag(self): ... - def conjugate(self): ... - -class Rational(Real): - @property - def numerator(self): ... - @property - def denominator(self): ... - def __float__(self): ... - -class Integral(Rational): - def __int__(self): ... - def __index__(self): ... - def __pow__(self, exponent, modulus=None): ... - def __lshift__(self, other): ... - def __rlshift__(self, other): ... - def __rshift__(self, other): ... - def __rrshift__(self, other): ... - def __and__(self, other): ... - def __rand__(self, other): ... - def __xor__(self, other): ... - def __rxor__(self, other): ... - def __or__(self, other): ... - def __ror__(self, other): ... - def __invert__(self): ... - def __float__(self): ... - @property - def numerator(self): ... - @property - def denominator(self): ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 84dffe248dd7..ea7ae8739487 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -1,6 +1,7 @@ # Stubs for typing from abc import abstractmethod, ABCMeta +import numbers # Definitions of special type checking related constructs. Their definition # are not used, so their value does not matter. @@ -59,7 +60,7 @@ class SupportsFloat(metaclass=ABCMeta): class SupportsComplex(metaclass=ABCMeta): @abstractmethod - def __complex__(self) -> complex: pass + def __complex__(self) -> numbers.Complex: pass class SupportsBytes(metaclass=ABCMeta): @abstractmethod diff --git a/tests/pytype_blacklist.txt b/tests/pytype_blacklist.txt index 86f2c7d5f092..4608d303d4e9 100644 --- a/tests/pytype_blacklist.txt +++ b/tests/pytype_blacklist.txt @@ -14,5 +14,6 @@ 2and3/logging/handlers.pyi 2and3/logging/__init__.pyi 2and3/mmap.pyi +2and3/numbers.pyi 2and3/plistlib.pyi 2and3/webbrowser.pyi