Skip to content

Commit a1d94e7

Browse files
authored
[psutil] Complete common POSIX logic (#15094)
1 parent 61f2be3 commit a1d94e7

File tree

11 files changed

+77
-25
lines changed

11 files changed

+77
-25
lines changed

stubs/psutil/psutil/_psaix.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw
108108
def open_files(self) -> list[_common.popenfile]: ...
109109
def num_fds(self) -> int: ...
110110
def num_ctx_switches(self) -> _common.pctxsw: ...
111-
def wait(self, timeout: float | None = None): ...
111+
def wait(self, timeout: float | None = None) -> int | None: ...
112112
def io_counters(self) -> _common.pio: ...

stubs/psutil/psutil/_psbsd.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw
177177
def num_ctx_switches(self) -> _common.pctxsw: ...
178178
def threads(self) -> list[_common.pthread]: ...
179179
def net_connections(self, kind: str = "inet") -> list[_common.pconn]: ...
180-
def wait(self, timeout: float | None = None): ...
180+
def wait(self, timeout: float | None = None) -> int | None: ...
181181
def nice_get(self) -> int: ...
182182
def nice_set(self, value: int) -> None: ...
183183
def status(self) -> str: ...

stubs/psutil/psutil/_pslinux.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ if sys.platform == "linux":
260260
def io_counters(self) -> pio: ...
261261
def cpu_times(self) -> pcputimes: ...
262262
def cpu_num(self) -> int: ...
263-
def wait(self, timeout: float | None = None): ...
263+
def wait(self, timeout: float | None = None) -> int | None: ...
264264
def create_time(self, monotonic: bool = False) -> float: ...
265265
def memory_info(self) -> pmem: ...
266266
def memory_full_info(self) -> pfullmem: ...

stubs/psutil/psutil/_psosx.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if sys.platform == "darwin":
110110
def open_files(self) -> list[_common.popenfile]: ...
111111
def net_connections(self, kind: str = "inet"): ...
112112
def num_fds(self) -> int: ...
113-
def wait(self, timeout: float | None = None): ...
113+
def wait(self, timeout: float | None = None) -> int | None: ...
114114
def nice_get(self): ...
115115
def nice_set(self, value): ...
116116
def status(self) -> str: ...

stubs/psutil/psutil/_psposix.pyi

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,73 @@
1+
import enum
12
import sys
2-
from _typeshed import FileDescriptorOrPath, StrOrBytesPath
3+
from _typeshed import FileDescriptorOrPath, Incomplete, StrOrBytesPath, Unused
4+
from collections.abc import Callable
35

46
from ._common import sdiskusage
57

68
def pid_exists(pid: int) -> bool: ...
9+
10+
# Sync with `signal.Signals`, but with opposite values:
11+
class Negsignal(enum.IntEnum):
12+
SIGABRT = -6
13+
SIGFPE = -8
14+
SIGILL = -4
15+
SIGINT = -2
16+
SIGSEGV = -11
17+
SIGTERM = -15
18+
19+
if sys.platform == "win32":
20+
SIGBREAK = -21
21+
CTRL_C_EVENT = 0
22+
CTRL_BREAK_EVENT = -1
23+
else:
24+
SIGALRM = -14
25+
SIGBUS = -7
26+
SIGCHLD = -17
27+
SIGCONT = -18
28+
SIGHUP = -1
29+
SIGIO = -29
30+
SIGIOT = -6
31+
SIGKILL = -9
32+
SIGPIPE = -13
33+
SIGPROF = -27
34+
SIGQUIT = -3
35+
SIGSTOP = -19
36+
SIGSYS = -31
37+
SIGTRAP = -5
38+
SIGTSTP = -20
39+
SIGTTIN = -21
40+
SIGTTOU = -22
41+
SIGURG = -23
42+
SIGUSR1 = -10
43+
SIGUSR2 = -12
44+
SIGVTALRM = -26
45+
SIGWINCH = -28
46+
SIGXCPU = -24
47+
SIGXFSZ = -25
48+
if sys.platform != "linux":
49+
SIGEMT = -7
50+
SIGINFO = -29
51+
if sys.platform != "darwin":
52+
SIGCLD = -17
53+
SIGPOLL = -29
54+
SIGPWR = -30
55+
SIGRTMAX = -64
56+
SIGRTMIN = -34
57+
if sys.version_info >= (3, 11):
58+
SIGSTKFLT = -16
59+
60+
def negsig_to_enum(num: int) -> int: ...
761
def wait_pid(
862
pid: int,
963
timeout: float | None = None,
1064
proc_name: str | None = None,
11-
_waitpid=...,
12-
_timer=...,
13-
_min=...,
14-
_sleep=...,
15-
_pid_exists=...,
16-
): ...
65+
_waitpid: Unused = ...,
66+
_timer: Callable[[], float] = ...,
67+
_min: Callable[..., Incomplete] = ...,
68+
_sleep: Callable[[float], None] = ...,
69+
_pid_exists: Callable[[int], bool] = ...,
70+
) -> int | None: ...
1771

1872
if sys.platform == "darwin":
1973
def disk_usage(path: StrOrBytesPath) -> sdiskusage: ...

stubs/psutil/psutil/_pssunos.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw
148148
def memory_maps(self) -> list[tuple[str, str, str, int, int, int]]: ...
149149
def num_fds(self) -> int: ...
150150
def num_ctx_switches(self) -> _common.pctxsw: ...
151-
def wait(self, timeout: float | None = None): ...
151+
def wait(self, timeout: float | None = None) -> int | None: ...

stubs/psutil/psutil/_psutil_aix.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw
77
AF_LINK: Final = 18
88

99
def getpagesize() -> int: ...
10-
def net_if_addrs(): ...
10+
def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ...
1111
def net_if_flags(nic_name: str, /) -> list[str]: ...
1212
def net_if_is_running(nic_name: str, /) -> bool: ...
1313
def net_if_mtu(nic_name: str, /) -> int: ...

stubs/psutil/psutil/_psutil_bsd.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw
2323
RLIM_INFINITY: Final[int] # only FreeBSD
2424

2525
def getpagesize() -> int: ...
26-
def net_if_addrs(): ...
26+
def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ...
2727
def net_if_flags(nic_name: str, /) -> list[str]: ...
2828
def net_if_is_running(nic_name: str, /) -> bool: ...
2929
def net_if_mtu(nic_name: str, /) -> int: ...
3030
def proc_priority_get(pid: int, /) -> int: ...
3131
def proc_priority_set(pid: int, priority: int, /) -> None: ...
32-
def net_if_duplex_speed(nic_name: str, /): ...
32+
def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements
3333
def proc_is_zombie(pid: int, /) -> bool: ...
3434

3535
version: Final[int]

stubs/psutil/psutil/_psutil_linux.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import sys
22

33
if sys.platform == "linux":
4-
from _typeshed import Incomplete
54
from collections.abc import Sequence
65
from typing import Final
76

@@ -24,13 +23,13 @@ if sys.platform == "linux":
2423
RLIM_INFINITY: Final[int]
2524

2625
def getpagesize() -> int: ...
27-
def net_if_addrs(): ...
26+
def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ...
2827
def net_if_flags(nic_name: str, /) -> list[str]: ...
2928
def net_if_is_running(nic_name: str, /) -> bool: ...
3029
def net_if_mtu(nic_name: str, /) -> int: ...
3130
def proc_priority_get(pid: int, /) -> int: ...
3231
def proc_priority_set(pid: int, priority: int, /) -> None: ...
33-
def users() -> list[tuple[Incomplete, ...]]: ...
32+
def users() -> list[tuple[str, str, str, float, int]]: ...
3433

3534
version: Final[int]
3635
DUPLEX_FULL: Final[int]

stubs/psutil/psutil/_psutil_osx.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22

33
if sys.platform == "darwin":
4-
from _typeshed import Incomplete, StrOrBytesPath
4+
from _typeshed import StrOrBytesPath
55
from collections.abc import Sequence
66
from socket import AddressFamily, SocketKind
77
from typing import Final, TypeVar
@@ -11,14 +11,14 @@ if sys.platform == "darwin":
1111
AF_LINK: Final = 18
1212

1313
def getpagesize() -> int: ...
14-
def net_if_addrs(): ...
14+
def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ...
1515
def net_if_flags(nic_name: str, /) -> list[str]: ...
1616
def net_if_is_running(nic_name: str, /) -> bool: ...
1717
def net_if_mtu(nic_name: str, /) -> int: ...
1818
def proc_priority_get(pid: int, /) -> int: ...
1919
def proc_priority_set(pid: int, priority: int, /) -> None: ...
20-
def net_if_duplex_speed(nic_name: str, /): ...
21-
def users() -> list[tuple[Incomplete, ...]]: ...
20+
def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements
21+
def users() -> list[tuple[str, str, str, float, int]]: ...
2222
def proc_is_zombie(pid: int, /) -> bool: ...
2323

2424
version: Final[int]

0 commit comments

Comments
 (0)