Skip to content

Commit c15ee07

Browse files
committed
[psutil] Complete Windows stubs
1 parent 5c8b7fc commit c15ee07

File tree

5 files changed

+335
-294
lines changed

5 files changed

+335
-294
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
psutil._pslinux
22
psutil._psosx
3-
43
psutil._psutil_linux
54
psutil._psutil_osx
65
psutil._psutil_posix

stubs/psutil/psutil/__init__.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import sys
22
from _typeshed import Incomplete
33
from collections.abc import Callable, Iterable, Iterator
44
from contextlib import AbstractContextManager
5+
from types import TracebackType
56
from typing import Any, Literal, Protocol, overload, type_check_only
67
from typing_extensions import Self, TypeAlias, deprecated
78

@@ -230,7 +231,9 @@ class Process:
230231
class Popen(Process):
231232
def __init__(self, *args, **kwargs) -> None: ...
232233
def __enter__(self) -> Self: ...
233-
def __exit__(self, *args: object, **kwargs: object) -> None: ...
234+
def __exit__(
235+
self, exc_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
236+
) -> None: ...
234237
def __getattribute__(self, name: str) -> Any: ...
235238
def __dir__(self) -> list[str]: ...
236239

stubs/psutil/psutil/_common.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def memoize_when_activated(fun: _Func) -> _Func: ...
251251
def isfile_strict(path: StrOrBytesPath) -> bool: ...
252252
def path_exists_strict(path: StrOrBytesPath) -> bool: ...
253253
def supports_ipv6() -> bool: ...
254-
def parse_environ_block(data): ...
254+
def parse_environ_block(data: str) -> dict[str, str]: ...
255255
def sockfam_to_enum(num: int) -> AddressFamily: ...
256256
def socktype_to_enum(num: int) -> SocketKind: ...
257257
@overload
Lines changed: 100 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,103 @@
1-
from typing import Final
1+
import sys
22

3-
ABOVE_NORMAL_PRIORITY_CLASS: Final = 32768
4-
BELOW_NORMAL_PRIORITY_CLASS: Final = 16384
5-
ERROR_ACCESS_DENIED: int
6-
ERROR_INVALID_NAME: int
7-
ERROR_PRIVILEGE_NOT_HELD: int
8-
ERROR_SERVICE_DOES_NOT_EXIST: int
9-
HIGH_PRIORITY_CLASS: Final = 128
10-
IDLE_PRIORITY_CLASS: Final = 64
11-
INFINITE: int
12-
MIB_TCP_STATE_CLOSED: int
13-
MIB_TCP_STATE_CLOSE_WAIT: int
14-
MIB_TCP_STATE_CLOSING: int
15-
MIB_TCP_STATE_DELETE_TCB: int
16-
MIB_TCP_STATE_ESTAB: int
17-
MIB_TCP_STATE_FIN_WAIT1: int
18-
MIB_TCP_STATE_FIN_WAIT2: int
19-
MIB_TCP_STATE_LAST_ACK: int
20-
MIB_TCP_STATE_LISTEN: int
21-
MIB_TCP_STATE_SYN_RCVD: int
22-
MIB_TCP_STATE_SYN_SENT: int
23-
MIB_TCP_STATE_TIME_WAIT: int
24-
NORMAL_PRIORITY_CLASS: Final = 32
25-
PSUTIL_CONN_NONE: int
26-
REALTIME_PRIORITY_CLASS: Final = 256
27-
WINDOWS_10: int
28-
WINDOWS_7: int
29-
WINDOWS_8: int
30-
WINDOWS_8_1: int
31-
WINDOWS_VISTA: int
32-
WINVER: int
33-
version: int
3+
if sys.platform == "win32":
4+
from collections.abc import Sequence
5+
from socket import AddressFamily, SocketKind
6+
from typing import Final
347

35-
class TimeoutAbandoned(Exception): ...
36-
class TimeoutExpired(Exception): ...
8+
version: Final[int]
9+
ABOVE_NORMAL_PRIORITY_CLASS: Final = 32768
10+
BELOW_NORMAL_PRIORITY_CLASS: Final = 16384
11+
HIGH_PRIORITY_CLASS: Final = 128
12+
IDLE_PRIORITY_CLASS: Final = 64
13+
NORMAL_PRIORITY_CLASS: Final = 32
14+
REALTIME_PRIORITY_CLASS: Final = 256
15+
MIB_TCP_STATE_CLOSED: Final = 1
16+
MIB_TCP_STATE_CLOSING: Final = 9
17+
MIB_TCP_STATE_CLOSE_WAIT: Final = 8
18+
MIB_TCP_STATE_LISTEN: Final = 2
19+
MIB_TCP_STATE_ESTAB: Final = 5
20+
MIB_TCP_STATE_SYN_SENT: Final = 3
21+
MIB_TCP_STATE_SYN_RCVD: Final = 4
22+
MIB_TCP_STATE_FIN_WAIT1: Final = 6
23+
MIB_TCP_STATE_FIN_WAIT2: Final = 7
24+
MIB_TCP_STATE_LAST_ACK: Final = 10
25+
MIB_TCP_STATE_TIME_WAIT: Final = 11
26+
MIB_TCP_STATE_DELETE_TCB: Final = 12
27+
PSUTIL_CONN_NONE: Final = 128
28+
INFINITE: Final[int]
29+
ERROR_ACCESS_DENIED: Final = 5
30+
ERROR_INVALID_NAME: Final = 123
31+
ERROR_SERVICE_DOES_NOT_EXIST: Final = 1060
32+
ERROR_PRIVILEGE_NOT_HELD: Final = 1314
33+
WINVER: Final[int]
34+
WINDOWS_VISTA: Final = 60
35+
WINDOWS_7: Final = 61
36+
WINDOWS_8: Final = 62
37+
WINDOWS_8_1: Final = 63
38+
WINDOWS_10: Final = 100
3739

38-
def QueryDosDevice(*args, **kwargs): ... # incomplete
39-
def boot_time(*args, **kwargs): ... # incomplete
40-
def check_pid_range(pid: int, /) -> None: ...
41-
def cpu_count_cores(*args, **kwargs): ... # incomplete
42-
def cpu_count_logical(*args, **kwargs): ... # incomplete
43-
def cpu_freq(*args, **kwargs): ... # incomplete
44-
def cpu_stats(*args, **kwargs): ... # incomplete
45-
def cpu_times(*args, **kwargs): ... # incomplete
46-
def disk_io_counters(*args, **kwargs): ... # incomplete
47-
def disk_partitions(*args, **kwargs): ... # incomplete
48-
def disk_usage(*args, **kwargs): ... # incomplete
49-
def getloadavg(*args, **kwargs): ... # incomplete
50-
def getpagesize(*args, **kwargs): ... # incomplete
51-
def init_loadavg_counter(*args, **kwargs): ... # incomplete
52-
def net_connections(*args, **kwargs): ... # incomplete
53-
def net_if_addrs(*args, **kwargs): ... # incomplete
54-
def net_if_stats(*args, **kwargs): ... # incomplete
55-
def net_io_counters(*args, **kwargs): ... # incomplete
56-
def per_cpu_times(*args, **kwargs): ... # incomplete
57-
def pid_exists(*args, **kwargs): ... # incomplete
58-
def pids(*args, **kwargs): ... # incomplete
59-
def ppid_map(*args, **kwargs): ... # incomplete
60-
def proc_cmdline(*args, **kwargs): ... # incomplete
61-
def proc_cpu_affinity_get(*args, **kwargs): ... # incomplete
62-
def proc_cpu_affinity_set(*args, **kwargs): ... # incomplete
63-
def proc_cwd(*args, **kwargs): ... # incomplete
64-
def proc_environ(*args, **kwargs): ... # incomplete
65-
def proc_exe(*args, **kwargs): ... # incomplete
66-
def proc_info(*args, **kwargs): ... # incomplete
67-
def proc_io_counters(*args, **kwargs): ... # incomplete
68-
def proc_io_priority_get(*args, **kwargs): ... # incomplete
69-
def proc_io_priority_set(*args, **kwargs): ... # incomplete
70-
def proc_is_suspended(*args, **kwargs): ... # incomplete
71-
def proc_kill(*args, **kwargs): ... # incomplete
72-
def proc_memory_info(*args, **kwargs): ... # incomplete
73-
def proc_memory_maps(*args, **kwargs): ... # incomplete
74-
def proc_memory_uss(*args, **kwargs): ... # incomplete
75-
def proc_num_handles(*args, **kwargs): ... # incomplete
76-
def proc_open_files(*args, **kwargs): ... # incomplete
77-
def proc_priority_get(*args, **kwargs): ... # incomplete
78-
def proc_priority_set(*args, **kwargs): ... # incomplete
79-
def proc_suspend_or_resume(*args, **kwargs): ... # incomplete
80-
def proc_threads(*args, **kwargs): ... # incomplete
81-
def proc_times(*args, **kwargs): ... # incomplete
82-
def proc_username(*args, **kwargs): ... # incomplete
83-
def proc_wait(*args, **kwargs): ... # incomplete
84-
def sensors_battery(*args, **kwargs): ... # incomplete
85-
def set_debug(*args, **kwargs): ... # incomplete
86-
def swap_percent(*args, **kwargs): ... # incomplete
87-
def users(*args, **kwargs): ... # incomplete
88-
def virtual_mem(*args, **kwargs): ... # incomplete
89-
def winservice_enumerate(*args, **kwargs): ... # incomplete
90-
def winservice_query_config(*args, **kwargs): ... # incomplete
91-
def winservice_query_descr(*args, **kwargs): ... # incomplete
92-
def winservice_query_status(*args, **kwargs): ... # incomplete
93-
def winservice_start(*args, **kwargs): ... # incomplete
94-
def winservice_stop(*args, **kwargs): ... # incomplete
40+
class TimeoutAbandoned(Exception): ...
41+
class TimeoutExpired(Exception): ...
42+
43+
def proc_cmdline(pid: int, use_peb: bool = True) -> list[str]: ...
44+
def proc_cpu_affinity_get(pid: int, /) -> int: ...
45+
def proc_cpu_affinity_set(pid: int, mask: int, /) -> None: ...
46+
def proc_cwd(pid: int, /) -> str: ...
47+
def proc_environ(pid: int, /) -> str: ...
48+
def proc_exe(pid: int, /) -> str: ...
49+
def proc_io_counters(pid: int, /) -> tuple[int, int, int, int, int, int]: ...
50+
def proc_io_priority_get(pid: int, /) -> int: ...
51+
def proc_io_priority_set(pid: int, priority: int, /) -> None: ...
52+
def proc_is_suspended(pid: int, /) -> bool: ...
53+
def proc_kill(pid: int, /) -> None: ...
54+
def proc_memory_info(pid: int, /) -> tuple[int, int, int, int, int, int, int, int, int, int]: ...
55+
def proc_memory_maps(pid: int, /) -> list[tuple[int, str, str, int]]: ...
56+
def proc_memory_uss(pid: int, /) -> int: ...
57+
def proc_num_handles(pid: int, /) -> int: ...
58+
def proc_open_files(pid: int, /) -> list[str]: ...
59+
def proc_priority_get(pid: int, /) -> int: ...
60+
def proc_priority_set(pid: int, priority: int, /) -> None: ...
61+
def proc_suspend_or_resume(pid: int, suspend: bool | None, /) -> None: ...
62+
def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ...
63+
def proc_times(pid: int, /) -> tuple[float, float, float]: ...
64+
def proc_username(pid: int, /) -> tuple[str, str]: ...
65+
def proc_wait(pid: int, timeout: int, /) -> int | None: ...
66+
def proc_info(
67+
pid: int, /
68+
) -> tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int]: ...
69+
def uptime() -> float: ...
70+
def cpu_count_cores() -> int | None: ...
71+
def cpu_count_logical() -> int | None: ...
72+
def cpu_freq() -> tuple[int, int]: ...
73+
def cpu_stats() -> tuple[int, int, int, int]: ...
74+
def cpu_times() -> tuple[float, float, float]: ...
75+
def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ...
76+
def disk_partitions(all: bool, /) -> list[tuple[str, str, str, str]]: ...
77+
def disk_usage(path: str, /) -> tuple[int, int, int]: ...
78+
def getloadavg() -> tuple[float, float, float]: ...
79+
def getpagesize() -> int: ...
80+
def swap_percent() -> float: ...
81+
def init_loadavg_counter() -> None: ...
82+
def net_connections(
83+
pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], /
84+
) -> list[tuple[int, int, int, tuple[str | None, int], tuple[str | None, int], int, int]]: ...
85+
def net_if_addrs() -> list[tuple[str, int, str, str | None, None, None]]: ...
86+
def net_if_stats() -> dict[str, tuple[bool, int, int, int]]: ...
87+
def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ...
88+
def per_cpu_times() -> list[tuple[float, float, float, float, float]]: ...
89+
def pid_exists(pid: int, /) -> bool: ...
90+
def pids() -> list[int]: ...
91+
def ppid_map() -> dict[int, int]: ...
92+
def sensors_battery() -> tuple[int, int, int, int]: ...
93+
def users() -> list[tuple[str, str | None, float]]: ...
94+
def virtual_mem() -> tuple[int, int, int, int]: ...
95+
def winservice_enumerate() -> list[tuple[str, str]]: ...
96+
def winservice_query_config(service_name: str, /) -> tuple[str, str, str, str]: ...
97+
def winservice_query_descr(service_name: str, /) -> str: ...
98+
def winservice_query_status(service_name: str, /) -> tuple[str, int] | str: ...
99+
def winservice_start(service_name: str, /) -> None: ...
100+
def winservice_stop(service_name: str, /) -> None: ...
101+
def QueryDosDevice(device_path: str, /) -> str: ...
102+
def check_pid_range(pid: int, /) -> None: ...
103+
def set_debug(value: bool, /) -> None: ...

0 commit comments

Comments
 (0)