Skip to content

Commit f4143c4

Browse files
authored
Update SupportsIndex support for math and cmath (#6216)
* SupportsIndex for cmath * Don't support __index__ on <3.7
1 parent 151f256 commit f4143c4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

stdlib/cmath.pyi

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import sys
12
from typing import SupportsComplex, SupportsFloat, Union
23

4+
if sys.version_info >= (3, 8):
5+
from typing import SupportsIndex
6+
37
e: float
48
pi: float
59
inf: float
@@ -8,7 +12,10 @@ nan: float
812
nanj: complex
913
tau: float
1014

11-
_C = Union[SupportsFloat, SupportsComplex, complex]
15+
if sys.version_info >= (3, 8):
16+
_C = Union[SupportsFloat, SupportsComplex, SupportsIndex, complex]
17+
else:
18+
_C = Union[SupportsFloat, SupportsComplex, complex]
1219

1320
def acos(__z: _C) -> complex: ...
1421
def acosh(__z: _C) -> complex: ...

stdlib/math.pyi

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ from _typeshed import SupportsTrunc
33
from typing import Iterable, SupportsFloat, Union, overload
44
from typing_extensions import SupportsIndex
55

6-
_SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex]
6+
if sys.version_info >= (3, 8):
7+
_SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex]
8+
else:
9+
_SupportsFloatOrIndex = SupportsFloat
710

811
e: float
912
pi: float
@@ -36,7 +39,13 @@ def erfc(__x: _SupportsFloatOrIndex) -> float: ...
3639
def exp(__x: _SupportsFloatOrIndex) -> float: ...
3740
def expm1(__x: _SupportsFloatOrIndex) -> float: ...
3841
def fabs(__x: _SupportsFloatOrIndex) -> float: ...
39-
def factorial(__x: SupportsIndex) -> int: ...
42+
43+
if sys.version_info >= (3, 8):
44+
def factorial(__x: SupportsIndex) -> int: ...
45+
46+
else:
47+
def factorial(__x: int) -> int: ...
48+
4049
def floor(__x: _SupportsFloatOrIndex) -> int: ...
4150
def fmod(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ...
4251
def frexp(__x: _SupportsFloatOrIndex) -> tuple[float, int]: ...

0 commit comments

Comments
 (0)