|
1 | 1 | import sys |
2 | 2 | from _typeshed import structseq |
3 | | -from typing import Any, Final, Literal, Protocol, final, type_check_only |
| 3 | +from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only |
4 | 4 | from typing_extensions import TypeAlias |
5 | 5 |
|
6 | 6 | _TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int] |
7 | 7 |
|
| 8 | +if sys.version_info >= (3, 15): |
| 9 | + # anticipate on https://github.com/python/cpython/pull/139224 |
| 10 | + _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex |
| 11 | +else: |
| 12 | + # before, time functions only accept (subclass of) float, *not* SupportsFloat |
| 13 | + _SupportsFloatOrIndex: TypeAlias = float | SupportsIndex |
| 14 | + |
8 | 15 | altzone: int |
9 | 16 | daylight: int |
10 | 17 | timezone: int |
@@ -68,11 +75,11 @@ class struct_time(structseq[Any | int], _TimeTuple): |
68 | 75 | def tm_gmtoff(self) -> int: ... |
69 | 76 |
|
70 | 77 | def asctime(time_tuple: _TimeTuple | struct_time = ..., /) -> str: ... |
71 | | -def ctime(seconds: float | None = None, /) -> str: ... |
72 | | -def gmtime(seconds: float | None = None, /) -> struct_time: ... |
73 | | -def localtime(seconds: float | None = None, /) -> struct_time: ... |
| 78 | +def ctime(seconds: _SupportsFloatOrIndex | None = None, /) -> str: ... |
| 79 | +def gmtime(seconds: _SupportsFloatOrIndex | None = None, /) -> struct_time: ... |
| 80 | +def localtime(seconds: _SupportsFloatOrIndex | None = None, /) -> struct_time: ... |
74 | 81 | def mktime(time_tuple: _TimeTuple | struct_time, /) -> float: ... |
75 | | -def sleep(seconds: float, /) -> None: ... |
| 82 | +def sleep(seconds: _SupportsFloatOrIndex, /) -> None: ... |
76 | 83 | def strftime(format: str, time_tuple: _TimeTuple | struct_time = ..., /) -> str: ... |
77 | 84 | def strptime(data_string: str, format: str = "%a %b %d %H:%M:%S %Y", /) -> struct_time: ... |
78 | 85 | def time() -> float: ... |
|
0 commit comments