Skip to content
Merged
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
17 changes: 12 additions & 5 deletions stdlib/time.pyi
Original file line number Diff line number Diff line change
@@ -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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, we don't accept changes for alpha versions of Python. In this case, I'm making an exception as this is easy to miss when we update our stubs.

# 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
Expand Down Expand Up @@ -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: ...
Expand Down