1
1
# Stubs for numbers
2
2
3
3
from typing import (
4
- Any , Optional , Union ,
4
+ Any , Optional ,
5
5
SupportsAbs , SupportsComplex , SupportsFloat , SupportsInt , SupportsRound ,
6
6
)
7
7
from abc import abstractmethod
@@ -18,10 +18,10 @@ class Complex(Number, SupportsComplex, SupportsAbs[float]):
18
18
@abstractmethod
19
19
def imag (self ) -> Complex : ...
20
20
@abstractmethod
21
- def __add__ (self , other : Union [ Number , complex ] ) -> Complex : ...
21
+ def __add__ (self , other : Complex ) -> Complex : ...
22
22
def __neg__ (self ) -> Complex : ...
23
23
@abstractmethod
24
- def __mul__ (self , other : Union [ Number , complex ] ) -> Complex : ...
24
+ def __mul__ (self , other : Complex ) -> Complex : ...
25
25
if sys .version_info >= (3 ,):
26
26
@abstractmethod
27
27
def __truediv__ (self , other : Complex ) -> Complex : ...
@@ -39,26 +39,38 @@ class Real(Complex, SupportsFloat, SupportsRound):
39
39
@abstractmethod
40
40
def __ceil__ (self ) -> int : ...
41
41
@abstractmethod
42
- def __divmod__ (self , other : Union [ Real , float ] ) -> Real : ...
42
+ def __divmod__ (self , other : Real ) -> Real : ...
43
43
@abstractmethod
44
- def __floordiv__ (self , other : Union [ Real , float ] ) -> Real : ...
44
+ def __floordiv__ (self , other : Real ) -> Real : ...
45
45
@abstractmethod
46
- def __mod__ (self , other : Union [ Real , float ] ) -> Real : ...
46
+ def __mod__ (self , other : Real ) -> Real : ...
47
47
@abstractmethod
48
- def __lt__ (self , other : Union [ Real , float ] ) -> bool : ...
48
+ def __lt__ (self , other : Real ) -> bool : ...
49
49
@abstractmethod
50
- def __le__ (self , other : Union [ Real , float ] ) -> bool : ...
50
+ def __le__ (self , other : Real ) -> bool : ...
51
51
@abstractmethod
52
- def __gt__ (self , other : Union [ Real , float ] ) -> bool : ...
52
+ def __gt__ (self , other : Real ) -> bool : ...
53
53
@abstractmethod
54
- def __ge__ (self , other : Union [ Real , float ] ) -> bool : ...
54
+ def __ge__ (self , other : Real ) -> bool : ...
55
55
def __complex__ (self ) -> Complex : ... # type: ignore
56
56
@property
57
57
def real (self ) -> Real : ...
58
58
@property
59
59
def imag (self ) -> Real : ...
60
60
def conjugate (self ) -> Real : ...
61
61
62
+ @abstractmethod
63
+ def __add__ (self , other : Real ) -> Real : ...
64
+ def __neg__ (self ) -> Real : ...
65
+ @abstractmethod
66
+ def __mul__ (self , other : Real ) -> Real : ...
67
+ if sys .version_info >= (3 ,):
68
+ @abstractmethod
69
+ def __truediv__ (self , other : Real ) -> Real : ...
70
+ else :
71
+ @abstractmethod
72
+ def __div__ (self , other : Real ) -> Real : ...
73
+
62
74
class Rational (Real ):
63
75
@property
64
76
@abstractmethod
@@ -68,6 +80,39 @@ class Rational(Real):
68
80
def denominator (self ) -> int : ...
69
81
def __float__ (self ) -> float : ...
70
82
83
+ @abstractmethod
84
+ def __divmod__ (self , other : Rational ) -> Rational : ...
85
+ @abstractmethod
86
+ def __floordiv__ (self , other : Rational ) -> Rational : ...
87
+ @abstractmethod
88
+ def __mod__ (self , other : Rational ) -> Rational : ...
89
+ @abstractmethod
90
+ def __lt__ (self , other : Rational , float ) -> bool : ...
91
+ @abstractmethod
92
+ def __le__ (self , other : Rational ) -> bool : ...
93
+ @abstractmethod
94
+ def __gt__ (self , other : Rational ) -> bool : ...
95
+ @abstractmethod
96
+ def __ge__ (self , other : Rational ) -> bool : ...
97
+ def __complex__ (self ) -> Complex : ... # type: ignore
98
+ @property
99
+ def real (self ) -> Rational : ...
100
+ @property
101
+ def imag (self ) -> Rational : ...
102
+ def conjugate (self ) -> Rational : ...
103
+
104
+ @abstractmethod
105
+ def __add__ (self , other : Rational ) -> Rational : ...
106
+ def __neg__ (self ) -> Rational : ...
107
+ @abstractmethod
108
+ def __mul__ (self , other : Rational ) -> Rational : ...
109
+ if sys .version_info >= (3 ,):
110
+ @abstractmethod
111
+ def __truediv__ (self , other : Rational ) -> Rational : ...
112
+ else :
113
+ @abstractmethod
114
+ def __div__ (self , other : Rational ) -> Rational : ...
115
+
71
116
class Integral (Rational , SupportsInt , SupportsAbs [int ]):
72
117
@property
73
118
def numerator (self ) -> int : ...
@@ -77,14 +122,47 @@ class Integral(Rational, SupportsInt, SupportsAbs[int]):
77
122
def __pow__ (self , exponent : float ,
78
123
modulus : Optional [int ] = ...) -> Integral : ...
79
124
@abstractmethod
80
- def __lshift__ (self , other : Union [ int , Integral ] ) -> Integral : ...
125
+ def __lshift__ (self , other : Integral ) -> Integral : ...
81
126
@abstractmethod
82
- def __rshift__ (self , other : Union [ int , Integral ] ) -> Integral : ...
127
+ def __rshift__ (self , other : Integral ) -> Integral : ...
83
128
@abstractmethod
84
- def __and__ (self , other : Union [ int , Integral ] ) -> Integral : ...
129
+ def __and__ (self , other : Integral ) -> Integral : ...
85
130
@abstractmethod
86
- def __xor__ (self , other : Union [ int , Integral ] ) -> Integral : ...
131
+ def __xor__ (self , other : Integral ) -> Integral : ...
87
132
@abstractmethod
88
- def __or__ (self , other : Union [ int , Integral ] ) -> Integral : ...
133
+ def __or__ (self , other : Integral ) -> Integral : ...
89
134
@abstractmethod
90
135
def __invert__ (self ) -> Integral : ...
136
+
137
+ @abstractmethod
138
+ def __divmod__ (self , other : Integral ) -> Integral : ...
139
+ @abstractmethod
140
+ def __floordiv__ (self , other : Integral ) -> Integral : ...
141
+ @abstractmethod
142
+ def __mod__ (self , other : Integral ) -> Integral : ...
143
+ @abstractmethod
144
+ def __lt__ (self , other : Integral ) -> bool : ...
145
+ @abstractmethod
146
+ def __le__ (self , other : Integral ) -> bool : ...
147
+ @abstractmethod
148
+ def __gt__ (self , other : Integral ) -> bool : ...
149
+ @abstractmethod
150
+ def __ge__ (self , other : Integral ) -> bool : ...
151
+ def __complex__ (self ) -> Complex : ... # type: ignore
152
+ @property
153
+ def real (self ) -> Integral : ...
154
+ @property
155
+ def imag (self ) -> Integral : ...
156
+ def conjugate (self ) -> Integral : ...
157
+
158
+ @abstractmethod
159
+ def __add__ (self , other : Integral ) -> Integral : ...
160
+ def __neg__ (self ) -> Integral : ...
161
+ @abstractmethod
162
+ def __mul__ (self , other : Integral ) -> Integral : ...
163
+ if sys .version_info >= (3 ,):
164
+ @abstractmethod
165
+ def __truediv__ (self , other : Integral ) -> Integral : ...
166
+ else :
167
+ @abstractmethod
168
+ def __div__ (self , other : Integral ) -> Integral : ...
0 commit comments