Skip to content
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

Update SupportsIndex support for math and cmath #6216

Merged
merged 6 commits into from
Oct 31, 2021
Merged
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
9 changes: 8 additions & 1 deletion stdlib/cmath.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import sys
from typing import SupportsComplex, SupportsFloat, Union

if sys.version_info >= (3, 8):
from typing import SupportsIndex

e: float
pi: float
inf: float
Expand All @@ -8,7 +12,10 @@ nan: float
nanj: complex
tau: float

_C = Union[SupportsFloat, SupportsComplex, complex]
if sys.version_info >= (3, 8):
_C = Union[SupportsFloat, SupportsComplex, SupportsIndex, complex]
else:
_C = Union[SupportsFloat, SupportsComplex, complex]

def acos(__z: _C) -> complex: ...
def acosh(__z: _C) -> complex: ...
Expand Down
13 changes: 11 additions & 2 deletions stdlib/math.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ from _typeshed import SupportsTrunc
from typing import Iterable, SupportsFloat, Union, overload
from typing_extensions import SupportsIndex

_SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex]
if sys.version_info >= (3, 8):
_SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex]
else:
_SupportsFloatOrIndex = SupportsFloat

e: float
pi: float
Expand Down Expand Up @@ -36,7 +39,13 @@ def erfc(__x: _SupportsFloatOrIndex) -> float: ...
def exp(__x: _SupportsFloatOrIndex) -> float: ...
def expm1(__x: _SupportsFloatOrIndex) -> float: ...
def fabs(__x: _SupportsFloatOrIndex) -> float: ...
def factorial(__x: SupportsIndex) -> int: ...

if sys.version_info >= (3, 8):
def factorial(__x: SupportsIndex) -> int: ...

else:
def factorial(__x: int) -> int: ...

def floor(__x: _SupportsFloatOrIndex) -> int: ...
def fmod(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ...
def frexp(__x: _SupportsFloatOrIndex) -> tuple[float, int]: ...
Expand Down