Skip to content

Commit 12a91ec

Browse files
committed
[psutil] Complete common POSIX logic
1 parent e80d84d commit 12a91ec

File tree

11 files changed

+70
-24
lines changed

11 files changed

+70
-24
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: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,67 @@
1+
import enum
12
import sys
2-
from _typeshed import FileDescriptorOrPath, StrOrBytesPath
3+
from _typeshed import FileDescriptorOrPath, 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+
SIGALRM = -14
19+
SIGBUS = -7
20+
SIGCHLD = -17
21+
SIGCONT = -18
22+
SIGHUP = -1
23+
SIGIO = -29
24+
SIGIOT = 6
25+
SIGKILL = -9
26+
SIGPIPE = -13
27+
SIGPROF = -27
28+
SIGQUIT = -3
29+
SIGSTOP = -19
30+
SIGSYS = -31
31+
SIGTRAP = -5
32+
SIGTSTP = -20
33+
SIGTTIN = -21
34+
SIGTTOU = -22
35+
SIGURG = -23
36+
SIGUSR1 = -10
37+
SIGUSR2 = -12
38+
SIGVTALRM = -26
39+
SIGWINCH = -28
40+
SIGXCPU = -24
41+
SIGXFSZ = -25
42+
if sys.platform != "linux":
43+
SIGEMT = -7
44+
SIGINFO = -29
45+
if sys.platform != "darwin":
46+
SIGCLD = -17
47+
SIGPOLL = -29
48+
SIGPWR = -30
49+
SIGRTMAX = -64
50+
SIGRTMIN = -34
51+
if sys.version_info >= (3, 11):
52+
SIGSTKFLT = -16
53+
54+
def negsig_to_enum(num: int) -> int: ...
755
def wait_pid(
856
pid: int,
957
timeout: float | None = None,
1058
proc_name: str | None = None,
11-
_waitpid=...,
12-
_timer=...,
59+
_waitpid: Unused = ...,
60+
_timer: Callable[[], float] = ...,
1361
_min=...,
14-
_sleep=...,
15-
_pid_exists=...,
16-
): ...
62+
_sleep: Callable[[float], None] = ...,
63+
_pid_exists: Callable[[int], bool] = ...,
64+
) -> int | None: ...
1765

1866
if sys.platform == "darwin":
1967
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)