Skip to content

Commit 2c6acd5

Browse files
committed
builtins use definition from numbers
1 parent f1b4011 commit 2c6acd5

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

stdlib/2.7/__builtin__.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from typing import (
1111
MutableSet, ItemsView, KeysView, ValuesView
1212
)
1313
from abc import abstractmethod, ABCMeta
14+
import numbers
1415

1516
_T = TypeVar('_T')
1617
_T_co = TypeVar('_T_co', covariant=True)
@@ -62,7 +63,7 @@ class type:
6263
def mro(self) -> List[type]: ...
6364
def __subclasses__(self) -> List[type]: ...
6465

65-
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
66+
class int(numbers.Integral):
6667
@overload
6768
def __init__(self) -> None: ...
6869
@overload
@@ -114,7 +115,7 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
114115
def __abs__(self) -> int: ...
115116
def __hash__(self) -> int: ...
116117

117-
class float(SupportsFloat, SupportsInt, SupportsAbs[float]):
118+
class float(numbers.Real):
118119
@overload
119120
def __init__(self) -> None: ...
120121
@overload
@@ -161,7 +162,7 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]):
161162
def __abs__(self) -> float: ...
162163
def __hash__(self) -> int: ...
163164

164-
class complex(SupportsAbs[float]):
165+
class complex(numbers.complex):
165166
@overload
166167
def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ...
167168
@overload

stdlib/2.7/typing.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Stubs for typing (Python 2.7)
22

33
from abc import abstractmethod, ABCMeta
4+
import numbers
45

56
# Definitions of special type checking related constructs. Their definition
67
# are not used, so their value does not matter.
@@ -50,7 +51,7 @@ _T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
5051

5152
class SupportsComplex(metaclass=ABCMeta):
5253
@abstractmethod
53-
def __complex__(self) -> complex: pass
54+
def __complex__(self) -> numbers.Complex: pass
5455

5556
class SupportsInt(metaclass=ABCMeta):
5657
@abstractmethod

stdlib/2and3/numbers.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import sys
1010

1111
class Number: ...
1212

13-
class Complex(Number, SupportsComplex, SupportsAbs):
13+
class Complex(Number, SupportsComplex, SupportsAbs[float]):
1414
@property
1515
@abstractmethod
1616
def real(self) -> Complex: ...
@@ -68,7 +68,7 @@ class Rational(Real):
6868
def denominator(self) -> int: ...
6969
def __float__(self) -> float: ...
7070

71-
class Integral(Rational, SupportsInt):
71+
class Integral(Rational, SupportsInt, SupportsAbs[int]):
7272
@property
7373
def numerator(self) -> int: ...
7474
@property

stdlib/3/builtins.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from typing import (
88
)
99
from abc import abstractmethod, ABCMeta
1010
from types import TracebackType
11+
import numbers
1112
import sys
1213

1314
# Note that names imported above are not automatically made visible via the
@@ -62,7 +63,7 @@ class type:
6263
# implementation seems to be returning a list.
6364
def mro(self) -> List[type]: ...
6465

65-
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
66+
class int(numbers.Integral):
6667
def __init__(self, x: Union[SupportsInt, str, bytes] = None, base: int = None) -> None: ...
6768
def bit_length(self) -> int: ...
6869
def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ...
@@ -111,7 +112,7 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
111112
def __abs__(self) -> int: ...
112113
def __hash__(self) -> int: ...
113114

114-
class float(SupportsFloat, SupportsInt, SupportsAbs[float]):
115+
class float(numbers.Real):
115116
def __init__(self, x: Union[SupportsFloat, str, bytes]=None) -> None: ...
116117
def as_integer_ratio(self) -> Tuple[int, int]: ...
117118
def hex(self) -> str: ...
@@ -149,7 +150,7 @@ class float(SupportsFloat, SupportsInt, SupportsAbs[float]):
149150
def __abs__(self) -> float: ...
150151
def __hash__(self) -> int: ...
151152

152-
class complex(SupportsAbs[float]):
153+
class complex(numbers.Complex):
153154
@overload
154155
def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ...
155156
@overload

stdlib/3/typing.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Stubs for typing
22

33
from abc import abstractmethod, ABCMeta
4+
import numbers
45

56
# Definitions of special type checking related constructs. Their definition
67
# are not used, so their value does not matter.
@@ -59,7 +60,7 @@ class SupportsFloat(metaclass=ABCMeta):
5960

6061
class SupportsComplex(metaclass=ABCMeta):
6162
@abstractmethod
62-
def __complex__(self) -> complex: pass
63+
def __complex__(self) -> numbers.Complex: pass
6364

6465
class SupportsBytes(metaclass=ABCMeta):
6566
@abstractmethod

0 commit comments

Comments
 (0)