mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 20:45:49 +08:00
[time] Fix parameter type of sleep et al. (#15321)
This commit is contained in:
+12
-5
@@ -1,10 +1,17 @@
|
||||
import sys
|
||||
from _typeshed import structseq
|
||||
from typing import Any, Final, Literal, Protocol, final, type_check_only
|
||||
from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int]
|
||||
|
||||
if sys.version_info >= (3, 15):
|
||||
# anticipate on https://github.com/python/cpython/pull/139224
|
||||
_SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
|
||||
else:
|
||||
# before, time functions only accept (subclass of) float, *not* SupportsFloat
|
||||
_SupportsFloatOrIndex: TypeAlias = float | SupportsIndex
|
||||
|
||||
altzone: int
|
||||
daylight: int
|
||||
timezone: int
|
||||
@@ -68,11 +75,11 @@ class struct_time(structseq[Any | int], _TimeTuple):
|
||||
def tm_gmtoff(self) -> int: ...
|
||||
|
||||
def asctime(time_tuple: _TimeTuple | struct_time = ..., /) -> str: ...
|
||||
def ctime(seconds: float | None = None, /) -> str: ...
|
||||
def gmtime(seconds: float | None = None, /) -> struct_time: ...
|
||||
def localtime(seconds: float | None = None, /) -> struct_time: ...
|
||||
def ctime(seconds: _SupportsFloatOrIndex | None = None, /) -> str: ...
|
||||
def gmtime(seconds: _SupportsFloatOrIndex | None = None, /) -> struct_time: ...
|
||||
def localtime(seconds: _SupportsFloatOrIndex | None = None, /) -> struct_time: ...
|
||||
def mktime(time_tuple: _TimeTuple | struct_time, /) -> float: ...
|
||||
def sleep(seconds: float, /) -> None: ...
|
||||
def sleep(seconds: _SupportsFloatOrIndex, /) -> None: ...
|
||||
def strftime(format: str, time_tuple: _TimeTuple | struct_time = ..., /) -> str: ...
|
||||
def strptime(data_string: str, format: str = "%a %b %d %H:%M:%S %Y", /) -> struct_time: ...
|
||||
def time() -> float: ...
|
||||
|
||||
Reference in New Issue
Block a user