Debian Codegraph @

jedi/third_party/typeshed/stdlib/time.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import structseq
3 from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only
4 from typing_extensions import TypeAlias
5
6 _TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int]
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
15 altzone: int
16 daylight: int
17 timezone: int
18 tzname: tuple[str, str]
19
20 if sys.platform == "linux":
21 CLOCK_BOOTTIME: Final[int]
22 if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
23 CLOCK_PROF: Final[int] # FreeBSD, NetBSD, OpenBSD
24 CLOCK_UPTIME: Final[int] # FreeBSD, OpenBSD
25
26 if sys.platform != "win32":
27 CLOCK_MONOTONIC: Final[int]
28 CLOCK_MONOTONIC_RAW: Final[int]
29 CLOCK_PROCESS_CPUTIME_ID: Final[int]
30 CLOCK_REALTIME: Final[int]
31 CLOCK_THREAD_CPUTIME_ID: Final[int]
32 if sys.platform != "linux" and sys.platform != "darwin":
33 CLOCK_HIGHRES: Final[int] # Solaris only
34
35 if sys.platform == "darwin":
36 CLOCK_UPTIME_RAW: Final[int]
37 if sys.version_info >= (3, 13):
38 CLOCK_UPTIME_RAW_APPROX: Final[int]
39 CLOCK_MONOTONIC_RAW_APPROX: Final[int]
40
41 if sys.platform == "linux":
42 CLOCK_TAI: Final[int]
43
44 # Constructor takes an iterable of any type, of length between 9 and 11 elements.
45 # However, it always *behaves* like a tuple of 9 elements,
46 # even if an iterable with length >9 is passed.
47 # https://github.com/python/typeshed/pull/6560#discussion_r767162532
48 @final
49 class struct_time(structseq[Any | int], _TimeTuple):
50 if sys.version_info >= (3, 10):
51 __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst")
52
53 @property
54 def tm_year(self) -> int: ...
55 @property
56 def tm_mon(self) -> int: ...
57 @property
58 def tm_mday(self) -> int: ...
59 @property
60 def tm_hour(self) -> int: ...
61 @property
62 def tm_min(self) -> int: ...
63 @property
64 def tm_sec(self) -> int: ...
65 @property
66 def tm_wday(self) -> int: ...
67 @property
68 def tm_yday(self) -> int: ...
69 @property
70 def tm_isdst(self) -> int: ...
71 # These final two properties only exist if a 10- or 11-item sequence was passed to the constructor.
72 @property
73 def tm_zone(self) -> str: ...
74 @property
75 def tm_gmtoff(self) -> int: ...
76
77 def asctime(time_tuple: _TimeTuple | struct_time = ..., /) -> str: ...
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: ...
81 def mktime(time_tuple: _TimeTuple | struct_time, /) -> float: ...
82 def sleep(seconds: _SupportsFloatOrIndex, /) -> None: ...
83 def strftime(format: str, time_tuple: _TimeTuple | struct_time = ..., /) -> str: ...
84 def strptime(data_string: str, format: str = "%a %b %d %H:%M:%S %Y", /) -> struct_time: ...
85 def time() -> float: ...
86
87 if sys.platform != "win32":
88 def tzset() -> None: ... # Unix only
89
90 @type_check_only
91 class _ClockInfo(Protocol):
92 adjustable: bool
93 implementation: str
94 monotonic: bool
95 resolution: float
96
97 def get_clock_info(name: Literal["monotonic", "perf_counter", "process_time", "time", "thread_time"], /) -> _ClockInfo: ...
98 def monotonic() -> float: ...
99 def perf_counter() -> float: ...
100 def process_time() -> float: ...
101
102 if sys.platform != "win32":
103 def clock_getres(clk_id: int, /) -> float: ... # Unix only
104 def clock_gettime(clk_id: int, /) -> float: ... # Unix only
105 def clock_settime(clk_id: int, time: float, /) -> None: ... # Unix only
106
107 if sys.platform != "win32":
108 def clock_gettime_ns(clk_id: int, /) -> int: ...
109 def clock_settime_ns(clock_id: int, time: int, /) -> int: ...
110
111 if sys.platform == "linux":
112 def pthread_getcpuclockid(thread_id: int, /) -> int: ...
113
114 def monotonic_ns() -> int: ...
115 def perf_counter_ns() -> int: ...
116 def process_time_ns() -> int: ...
117 def time_ns() -> int: ...
118 def thread_time() -> float: ...
119 def thread_time_ns() -> int: ...