Skip to content

Use better types for time.get_clock_info #7040

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

Merged
merged 6 commits into from
Jan 26, 2022
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
13 changes: 9 additions & 4 deletions stdlib/time.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys
from _typeshed import structseq
from types import SimpleNamespace
from typing import Any, Union
from typing_extensions import final
from typing import Any, Protocol, Union
from typing_extensions import Literal, final

_TimeTuple = tuple[int, int, int, int, int, int, int, int, int]

Expand Down Expand Up @@ -80,7 +79,13 @@ def time() -> float: ...
if sys.platform != "win32":
def tzset() -> None: ... # Unix only

def get_clock_info(name: str) -> SimpleNamespace: ...
class _ClockInfo(Protocol):
adjustable: bool
implementation: str
monotonic: bool
resolution: float

def get_clock_info(name: Literal["monotonic", "perf_counter", "process_time", "time", "thread_time"]) -> _ClockInfo: ...
def monotonic() -> float: ...
def perf_counter() -> float: ...
def process_time() -> float: ...
Expand Down