From d9d7c0c39aa104f64fda7b777a772cbae28fbfed Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 09:51:02 +0900 Subject: [PATCH 1/6] SupportsIndex for cmath --- stdlib/cmath.pyi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index 3f3327074579..e799d9fa26a3 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,5 +1,9 @@ +import sys from typing import SupportsComplex, SupportsFloat, Union +if sys.version >= (3, 8): + from typing import SupportsIndex + e: float pi: float inf: float @@ -8,7 +12,10 @@ nan: float nanj: complex tau: float -_C = Union[SupportsFloat, SupportsComplex, complex] +if sys.version >= (3, 8): + _C = Union[SupportsFloat, SupportsComplex, SupportsIndex, complex] +else: + _C = Union[SupportsFloat, SupportsComplex, complex] def acos(__z: _C) -> complex: ... def acosh(__z: _C) -> complex: ... From 99af8504e77300f85e7f4903ffee4a1e1cdaf158 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 09:54:20 +0900 Subject: [PATCH 2/6] Don't support __index__ on <3.7 --- stdlib/math.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 19042962b28f..1ea073f398bf 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -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 >= (3, 8): + _SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex] +else: + _SupportsFloatOrIndex = SupportsFloat e: float pi: float From 1c5c37bda295c04bc00aaaab94979baf07343cc0 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 09:58:39 +0900 Subject: [PATCH 3/6] Formatting (oops) --- stdlib/cmath.pyi | 6 +++--- stdlib/math.pyi | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index e799d9fa26a3..04c2b632d411 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,7 +1,7 @@ import sys from typing import SupportsComplex, SupportsFloat, Union -if sys.version >= (3, 8): +if sys.version_info >= (3, 8): from typing import SupportsIndex e: float @@ -12,10 +12,10 @@ nan: float nanj: complex tau: float -if sys.version >= (3, 8): +if sys.version_info >= (3, 8): _C = Union[SupportsFloat, SupportsComplex, SupportsIndex, complex] else: - _C = Union[SupportsFloat, SupportsComplex, complex] + _C = Union[SupportsFloat, SupportsComplex, complex] def acos(__z: _C) -> complex: ... def acosh(__z: _C) -> complex: ... diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 1ea073f398bf..8c0540cee652 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -3,10 +3,10 @@ from _typeshed import SupportsTrunc from typing import Iterable, SupportsFloat, Union, overload from typing_extensions import SupportsIndex -if sys.version >= (3, 8): +if sys.version_info >= (3, 8): _SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex] else: - _SupportsFloatOrIndex = SupportsFloat + _SupportsFloatOrIndex = SupportsFloat e: float pi: float From bb044d652fd42e474ff95638a310631e7a2c5bbd Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 10:01:50 +0900 Subject: [PATCH 4/6] math.factorial only accepts int <3.8 --- stdlib/math.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 8c0540cee652..70b8685a32f4 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -39,7 +39,12 @@ 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]: ... From 463b9f78e5a8895d0ec0db9142370530448f77a4 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 10:04:32 +0900 Subject: [PATCH 5/6] Please black --- stdlib/math.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 70b8685a32f4..8270ac06febc 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -42,6 +42,7 @@ def fabs(__x: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= 3.8: def factorial(__x: SupportsIndex) -> int: ... + else: def factorial(__x: int) -> int: ... From da8c3f3403d0fdc37cd9a9cb8c12bb105a57dbe6 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 31 Oct 2021 10:07:06 +0900 Subject: [PATCH 6/6] Actually compare against the right version --- stdlib/math.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 8270ac06febc..f92a3d94f978 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -40,7 +40,7 @@ def exp(__x: _SupportsFloatOrIndex) -> float: ... def expm1(__x: _SupportsFloatOrIndex) -> float: ... def fabs(__x: _SupportsFloatOrIndex) -> float: ... -if sys.version_info >= 3.8: +if sys.version_info >= (3, 8): def factorial(__x: SupportsIndex) -> int: ... else: