Skip to content

Improve numbers #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions stdlib/2.7/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -71,27 +72,27 @@ 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: ...
def __rfloordiv__(self, x: int) -> 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: ...
Expand All @@ -103,18 +104,18 @@ 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: ...
def __int__(self) -> 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
Expand All @@ -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: ...
Expand All @@ -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: ...

Expand All @@ -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
Expand All @@ -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: ...
Expand Down
77 changes: 0 additions & 77 deletions stdlib/2.7/numbers.pyi

This file was deleted.

5 changes: 5 additions & 0 deletions stdlib/2.7/typing.pyi
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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: ...
Expand Down
Loading