From d1bcca7ad6c5079232b1fe2d323c8670540b782c Mon Sep 17 00:00:00 2001 From: rusty3699 Date: Fri, 13 Nov 2026 19:13:08 +0530 Subject: [PATCH] Update psutil stubs for 8.0 --- stubs/psutil/@tests/stubtest_allowlist.txt | 4 - .../@tests/stubtest_allowlist_darwin.txt | 6 +- .../@tests/stubtest_allowlist_linux.txt | 3 +- .../@tests/stubtest_allowlist_win32.txt | 3 +- stubs/psutil/METADATA.toml | 2 +- stubs/psutil/psutil/__init__.pyi | 283 ++++++++------ stubs/psutil/psutil/_common.pyi | 95 +---- stubs/psutil/psutil/_enums.pyi | 109 ++++++ stubs/psutil/psutil/_ntuples.pyi | 105 ++++-- stubs/psutil/psutil/_psaix.pyi | 22 +- stubs/psutil/psutil/_psbsd.pyi | 29 +- stubs/psutil/psutil/_pslinux.pyi | 23 +- stubs/psutil/psutil/_psosx.pyi | 24 +- stubs/psutil/psutil/_psposix.pyi | 8 +- stubs/psutil/psutil/_pssunos.pyi | 18 +- stubs/psutil/psutil/_psutil.pyi | 356 ++++++++++++++++++ stubs/psutil/psutil/_psutil_aix.pyi | 58 --- stubs/psutil/psutil/_psutil_bsd.pyi | 145 ------- stubs/psutil/psutil/_psutil_linux.pyi | 49 --- stubs/psutil/psutil/_psutil_osx.pyi | 79 ---- stubs/psutil/psutil/_psutil_sunos.pyi | 63 ---- stubs/psutil/psutil/_psutil_windows.pyi | 105 ------ stubs/psutil/psutil/_pswindows.pyi | 39 +- 23 files changed, 795 insertions(+), 833 deletions(-) create mode 100644 stubs/psutil/psutil/_enums.pyi create mode 100644 stubs/psutil/psutil/_psutil.pyi delete mode 100644 stubs/psutil/psutil/_psutil_aix.pyi delete mode 100644 stubs/psutil/psutil/_psutil_bsd.pyi delete mode 100644 stubs/psutil/psutil/_psutil_linux.pyi delete mode 100644 stubs/psutil/psutil/_psutil_osx.pyi delete mode 100644 stubs/psutil/psutil/_psutil_sunos.pyi delete mode 100644 stubs/psutil/psutil/_psutil_windows.pyi diff --git a/stubs/psutil/@tests/stubtest_allowlist.txt b/stubs/psutil/@tests/stubtest_allowlist.txt index 0ced949877a2..62d3c0ed08b5 100644 --- a/stubs/psutil/@tests/stubtest_allowlist.txt +++ b/stubs/psutil/@tests/stubtest_allowlist.txt @@ -1,7 +1,3 @@ # Stubtest does not support these platforms psutil._psaix -psutil._psbsd psutil._pssunos -psutil._psutil_aix -psutil._psutil_bsd -psutil._psutil_sunos diff --git a/stubs/psutil/@tests/stubtest_allowlist_darwin.txt b/stubs/psutil/@tests/stubtest_allowlist_darwin.txt index f1bc464326a5..def9f38e9a2c 100644 --- a/stubs/psutil/@tests/stubtest_allowlist_darwin.txt +++ b/stubs/psutil/@tests/stubtest_allowlist_darwin.txt @@ -1,9 +1,5 @@ psutil._pslinux psutil._pswindows -psutil._psutil_linux -psutil._psutil_windows # not always available on ARM64, but we test there -psutil.cpu_freq -psutil._psosx.cpu_freq -psutil.__all__ # cpu_freq is only added to __all__ at runtime when it is available +psutil._psbsd.* diff --git a/stubs/psutil/@tests/stubtest_allowlist_linux.txt b/stubs/psutil/@tests/stubtest_allowlist_linux.txt index 5433c30009cc..3d3555be5364 100644 --- a/stubs/psutil/@tests/stubtest_allowlist_linux.txt +++ b/stubs/psutil/@tests/stubtest_allowlist_linux.txt @@ -1,4 +1,3 @@ psutil._psosx psutil._pswindows -psutil._psutil_osx -psutil._psutil_windows +psutil._psbsd diff --git a/stubs/psutil/@tests/stubtest_allowlist_win32.txt b/stubs/psutil/@tests/stubtest_allowlist_win32.txt index 1e781db20233..5b571eefda2b 100644 --- a/stubs/psutil/@tests/stubtest_allowlist_win32.txt +++ b/stubs/psutil/@tests/stubtest_allowlist_win32.txt @@ -1,4 +1,3 @@ psutil._psosx psutil._pslinux -psutil._psutil_osx -psutil._psutil_linux +psutil._psbsd diff --git a/stubs/psutil/METADATA.toml b/stubs/psutil/METADATA.toml index 4700066c4768..6c2de90467d4 100644 --- a/stubs/psutil/METADATA.toml +++ b/stubs/psutil/METADATA.toml @@ -1,4 +1,4 @@ -version = "7.2.2" +version = "8.0.0" upstream-repository = "https://github.com/giampaolo/psutil" [tool.stubtest] diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 6c4fda89160f..6616117e1017 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -4,48 +4,18 @@ from collections.abc import Callable, Collection, Iterable, Iterator from contextlib import AbstractContextManager from subprocess import _CMD, _ENV, _FILE from types import TracebackType -from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only +from typing import Any, Literal, Protocol, overload, type_check_only from typing_extensions import Self, deprecated from psutil._common import ( AIX as AIX, BSD as BSD, - CONN_CLOSE as CONN_CLOSE, - CONN_CLOSE_WAIT as CONN_CLOSE_WAIT, - CONN_CLOSING as CONN_CLOSING, - CONN_ESTABLISHED as CONN_ESTABLISHED, - CONN_FIN_WAIT1 as CONN_FIN_WAIT1, - CONN_FIN_WAIT2 as CONN_FIN_WAIT2, - CONN_LAST_ACK as CONN_LAST_ACK, - CONN_LISTEN as CONN_LISTEN, - CONN_NONE as CONN_NONE, - CONN_SYN_RECV as CONN_SYN_RECV, - CONN_SYN_SENT as CONN_SYN_SENT, - CONN_TIME_WAIT as CONN_TIME_WAIT, FREEBSD as FREEBSD, LINUX as LINUX, MACOS as MACOS, NETBSD as NETBSD, - NIC_DUPLEX_FULL as NIC_DUPLEX_FULL, - NIC_DUPLEX_HALF as NIC_DUPLEX_HALF, - NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN, OPENBSD as OPENBSD, - OSX as OSX, POSIX as POSIX, - POWER_TIME_UNKNOWN as POWER_TIME_UNKNOWN, - POWER_TIME_UNLIMITED as POWER_TIME_UNLIMITED, - STATUS_DEAD as STATUS_DEAD, - STATUS_DISK_SLEEP as STATUS_DISK_SLEEP, - STATUS_IDLE as STATUS_IDLE, - STATUS_LOCKED as STATUS_LOCKED, - STATUS_PARKED as STATUS_PARKED, - STATUS_RUNNING as STATUS_RUNNING, - STATUS_SLEEPING as STATUS_SLEEPING, - STATUS_STOPPED as STATUS_STOPPED, - STATUS_TRACING_STOP as STATUS_TRACING_STOP, - STATUS_WAITING as STATUS_WAITING, - STATUS_WAKING as STATUS_WAKING, - STATUS_ZOMBIE as STATUS_ZOMBIE, SUNOS as SUNOS, WINDOWS as WINDOWS, AccessDenied as AccessDenied, @@ -54,6 +24,12 @@ from psutil._common import ( TimeoutExpired as TimeoutExpired, ZombieProcess as ZombieProcess, ) +from psutil._enums import ( + BatteryTime as BatteryTime, + ConnectionStatus as ConnectionStatus, + NicDuplex as NicDuplex, + ProcessStatus as ProcessStatus, +) from . import _ntuples as _ntp @@ -67,55 +43,28 @@ __all__ = [ # constants "version_info", "__version__", - "STATUS_RUNNING", - "STATUS_IDLE", - "STATUS_SLEEPING", - "STATUS_DISK_SLEEP", - "STATUS_STOPPED", - "STATUS_TRACING_STOP", - "STATUS_ZOMBIE", - "STATUS_DEAD", - "STATUS_WAKING", - "STATUS_LOCKED", - "STATUS_WAITING", - "STATUS_PARKED", - "CONN_ESTABLISHED", - "CONN_SYN_SENT", - "CONN_SYN_RECV", - "CONN_FIN_WAIT1", - "CONN_FIN_WAIT2", - "CONN_TIME_WAIT", - "CONN_CLOSE", - "CONN_CLOSE_WAIT", - "CONN_LAST_ACK", - "CONN_LISTEN", - "CONN_CLOSING", - "CONN_NONE", "AF_LINK", - "NIC_DUPLEX_FULL", - "NIC_DUPLEX_HALF", - "NIC_DUPLEX_UNKNOWN", - "POWER_TIME_UNKNOWN", - "POWER_TIME_UNLIMITED", "BSD", "FREEBSD", "LINUX", "NETBSD", "OPENBSD", "MACOS", - "OSX", "POSIX", "SUNOS", "WINDOWS", "AIX", # classes "Process", + "ProcessSnapshot", "Popen", # functions "pid_exists", "pids", "process_iter", "wait_procs", + "memory_physical", + "memory_swap", "virtual_memory", "swap_memory", "cpu_times", @@ -123,7 +72,6 @@ __all__ = [ "cpu_times_percent", "cpu_count", "cpu_stats", - "cpu_freq", "getloadavg", "net_io_counters", "net_connections", @@ -132,9 +80,47 @@ __all__ = [ "disk_io_counters", "disk_partitions", "disk_usage", - "sensors_battery", "users", "boot_time", + "bytes2human", + "ProcessStatus", + "STATUS_DEAD", + "STATUS_DISK_SLEEP", + "STATUS_IDLE", + "STATUS_LOCKED", + "STATUS_PARKED", + "STATUS_RUNNING", + "STATUS_SLEEPING", + "STATUS_STOPPED", + "STATUS_SUSPENDED", + "STATUS_TRACING_STOP", + "STATUS_UNKNOWN", + "STATUS_WAITING", + "STATUS_WAKE_KILL", + "STATUS_WAKING", + "STATUS_ZOMBIE", + "ConnectionStatus", + "CONN_CLOSE", + "CONN_CLOSE_WAIT", + "CONN_CLOSING", + "CONN_ESTABLISHED", + "CONN_FIN_WAIT1", + "CONN_FIN_WAIT2", + "CONN_LAST_ACK", + "CONN_LISTEN", + "CONN_NONE", + "CONN_SYN_RECV", + "CONN_SYN_SENT", + "CONN_TIME_WAIT", + "NicDuplex", + "NIC_DUPLEX_FULL", + "NIC_DUPLEX_HALF", + "NIC_DUPLEX_UNKNOWN", + "BatteryTime", + "POWER_TIME_UNKNOWN", + "POWER_TIME_UNLIMITED", + "cpu_freq", + "sensors_battery", "heap_info", "heap_trim", ] @@ -184,12 +170,12 @@ elif sys.platform == "win32": ] if sys.platform == "linux": - from ._pslinux import ( - IOPRIO_CLASS_BE as IOPRIO_CLASS_BE, - IOPRIO_CLASS_IDLE as IOPRIO_CLASS_IDLE, - IOPRIO_CLASS_NONE as IOPRIO_CLASS_NONE, - IOPRIO_CLASS_RT as IOPRIO_CLASS_RT, - ) + from ._enums import ProcessIOPriority as ProcessIOPriority, ProcessRlimit as ProcessRlimit + + IOPRIO_CLASS_NONE: ProcessIOPriority + IOPRIO_CLASS_RT: ProcessIOPriority + IOPRIO_CLASS_BE: ProcessIOPriority + IOPRIO_CLASS_IDLE: ProcessIOPriority def sensors_temperatures(fahrenheit: bool = False) -> dict[str, list[_ntp.shwtemp]]: ... def sensors_fans() -> dict[str, list[_ntp.sfan]]: ... PROCFS_PATH: str @@ -211,23 +197,22 @@ if sys.platform == "linux": RLIMIT_STACK: int RLIM_INFINITY: int if sys.platform == "win32": - from ._psutil_windows import ( - ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS as IDLE_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS as NORMAL_PRIORITY_CLASS, - REALTIME_PRIORITY_CLASS as REALTIME_PRIORITY_CLASS, - ) - from ._pswindows import ( - CONN_DELETE_TCB as CONN_DELETE_TCB, - IOPRIO_HIGH as IOPRIO_HIGH, - IOPRIO_LOW as IOPRIO_LOW, - IOPRIO_NORMAL as IOPRIO_NORMAL, - IOPRIO_VERYLOW as IOPRIO_VERYLOW, - win_service_get as win_service_get, - win_service_iter as win_service_iter, - ) + from ._enums import ProcessIOPriority as ProcessIOPriority, ProcessPriority as ProcessPriority + from ._pswindows import WindowsService as WindowsService + + IOPRIO_VERYLOW: ProcessIOPriority + IOPRIO_LOW: ProcessIOPriority + IOPRIO_NORMAL: ProcessIOPriority + IOPRIO_HIGH: ProcessIOPriority + ABOVE_NORMAL_PRIORITY_CLASS: ProcessPriority + BELOW_NORMAL_PRIORITY_CLASS: ProcessPriority + HIGH_PRIORITY_CLASS: ProcessPriority + IDLE_PRIORITY_CLASS: ProcessPriority + NORMAL_PRIORITY_CLASS: ProcessPriority + REALTIME_PRIORITY_CLASS: ProcessPriority + CONN_DELETE_TCB: ConnectionStatus + def win_service_get(name: str) -> WindowsService: ... + def win_service_iter() -> Iterator[WindowsService]: ... # Linux + glibc, Windows, macOS, FreeBSD, NetBSD: def heap_info() -> _ntp.pheap: ... @@ -246,33 +231,105 @@ AF_LINK: int version_info: tuple[int, int, int] __version__: str __author__: str +bytes2human: Callable[[int], str] -_Status: TypeAlias = Literal[ - "running", - "sleeping", - "disk-sleep", - "stopped", - "tracing-stop", - "zombie", - "dead", - "wake-kill", - "waking", - "idle", - "locked", - "waiting", - "suspended", - "parked", -] +STATUS_DEAD: ProcessStatus +STATUS_DISK_SLEEP: ProcessStatus +STATUS_IDLE: ProcessStatus +STATUS_LOCKED: ProcessStatus +STATUS_PARKED: ProcessStatus +STATUS_RUNNING: ProcessStatus +STATUS_SLEEPING: ProcessStatus +STATUS_STOPPED: ProcessStatus +STATUS_SUSPENDED: ProcessStatus +STATUS_TRACING_STOP: ProcessStatus +STATUS_UNKNOWN: ProcessStatus +STATUS_WAITING: ProcessStatus +STATUS_WAKE_KILL: ProcessStatus +STATUS_WAKING: ProcessStatus +STATUS_ZOMBIE: ProcessStatus + +CONN_CLOSE: ConnectionStatus +CONN_CLOSE_WAIT: ConnectionStatus +CONN_CLOSING: ConnectionStatus +CONN_ESTABLISHED: ConnectionStatus +CONN_FIN_WAIT1: ConnectionStatus +CONN_FIN_WAIT2: ConnectionStatus +CONN_LAST_ACK: ConnectionStatus +CONN_LISTEN: ConnectionStatus +CONN_NONE: ConnectionStatus +CONN_SYN_RECV: ConnectionStatus +CONN_SYN_SENT: ConnectionStatus +CONN_TIME_WAIT: ConnectionStatus + +NIC_DUPLEX_FULL: NicDuplex +NIC_DUPLEX_HALF: NicDuplex +NIC_DUPLEX_UNKNOWN: NicDuplex + +POWER_TIME_UNKNOWN: BatteryTime +POWER_TIME_UNLIMITED: BatteryTime + +class ProcessSnapshot: + cmdline: list[str] + cpu_affinity: list[int] + cpu_num: int + cpu_percent: float + cpu_times: _ntp.pcputimes + create_time: float + ctx_switches: _ntp.pctxsw + cwd: str + environ: dict[str, str] + exe: str + gids: _ntp.pgids + io_counters: _ntp.pio + ionice: _ntp.pionice + memory_extras: _ntp.pmem_extras + memory_footprint: _ntp.pfootprint + memory_info: _ntp.pmem + memory_maps: list[_ntp.pmmap_grouped] | list[_ntp.pmmap_ext] + memory_percent: float + name: str + net_connections: list[_ntp.pconn] + nice: int + num_fds: int + num_handles: int + num_threads: int + open_files: list[_ntp.popenfile] + page_faults: _ntp.ppagefaults + pid: int + ppid: int + status: ProcessStatus + terminal: str | None + threads: list[_ntp.pthread] + uids: _ntp.puids + username: str + + def __init__(self, data: dict[str, Any]) -> None: ... + def __eq__(self, other: object) -> bool: ... + __hash__: None # type: ignore[assignment] # unhashable + def __bool__(self) -> bool: ... + def __getattr__(self, name: str) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + def __delattr__(self, name: str) -> None: ... + def as_dict(self) -> dict[str, Any]: ... class Process: + attrs: frozenset[str] def __init__(self, pid: int | None = None) -> None: ... def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... + def __ne__(self, other: object, /) -> bool: ... def __hash__(self) -> int: ... @property def pid(self) -> int: ... - # Only present if attrs argument is passed to process_iter - info: dict[str, Incomplete] + @property + def snapshot(self) -> ProcessSnapshot: ... + + @property + @deprecated("use Process.snapshot.as_dict() instead") + def info(self) -> dict[str, Any]: ... + @info.setter + def info(self, value: dict[str, Any]) -> None: ... + def oneshot(self) -> AbstractContextManager[None]: ... def as_dict( self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value=None @@ -284,7 +341,7 @@ class Process: def name(self) -> str: ... def exe(self) -> str: ... def cmdline(self) -> list[str]: ... - def status(self) -> _Status: ... + def status(self) -> ProcessStatus: ... def username(self) -> str: ... def create_time(self) -> float: ... def cwd(self) -> str: ... @@ -323,6 +380,8 @@ class Process: if sys.platform == "win32": def num_handles(self) -> int: ... + def ctx_switches(self) -> _ntp.pctxsw: ... + @deprecated("use ctx_switches() method instead") def num_ctx_switches(self) -> _ntp.pctxsw: ... def num_threads(self) -> int: ... def threads(self) -> list[_ntp.pthread]: ... @@ -330,8 +389,14 @@ class Process: def cpu_percent(self, interval: float | None = None) -> float: ... def cpu_times(self) -> _ntp.pcputimes: ... def memory_info(self) -> _ntp.pmem: ... + if sys.platform == "linux" or sys.platform == "darwin" or sys.platform == "win32": + def memory_extras(self) -> _ntp.pmem_extras: ... + def memory_footprint(self) -> _ntp.pfootprint: ... + + @deprecated("use memory_footprint() method instead") def memory_full_info(self) -> _ntp.pfullmem: ... def memory_percent(self, memtype: str = "rss") -> float: ... + def page_faults(self) -> _ntp.ppagefaults: ... def open_files(self) -> list[_ntp.popenfile]: ... @deprecated('use "net_connections" method instead') def connections(self, kind: str = "inet") -> list[_ntp.pconn]: ... @@ -457,7 +522,11 @@ def cpu_times_percent(*, percpu: Literal[True]) -> list[_ntp.scputimes]: ... def cpu_stats() -> _ntp.scpustats: ... def getloadavg() -> tuple[float, float, float]: ... -def virtual_memory() -> _ntp.svmem: ... +def memory_physical() -> _ntp.smem: ... +def memory_swap() -> _ntp.sswap: ... +@deprecated("use memory_physical() function instead") +def virtual_memory() -> _ntp.smem: ... +@deprecated("use memory_swap() function instead") def swap_memory() -> _ntp.sswap: ... def disk_usage(path: str) -> _ntp.sdiskusage: ... def disk_partitions(all: bool = False) -> list[_ntp.sdiskpart]: ... diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index e7a974bc77cc..63d7a48188aa 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -1,4 +1,3 @@ -import enum import io import sys import threading @@ -14,7 +13,6 @@ POSIX: Final[bool] WINDOWS: Final[bool] LINUX: Final[bool] MACOS: Final[bool] -OSX: Final[bool] FREEBSD: Final[bool] OPENBSD: Final[bool] NETBSD: Final[bool] @@ -22,50 +20,6 @@ BSD: Final[bool] SUNOS: Final[bool] AIX: Final[bool] -STATUS_RUNNING: Final = "running" -STATUS_SLEEPING: Final = "sleeping" -STATUS_DISK_SLEEP: Final = "disk-sleep" -STATUS_STOPPED: Final = "stopped" -STATUS_TRACING_STOP: Final = "tracing-stop" -STATUS_ZOMBIE: Final = "zombie" -STATUS_DEAD: Final = "dead" -STATUS_WAKE_KILL: Final = "wake-kill" -STATUS_WAKING: Final = "waking" -STATUS_IDLE: Final = "idle" -STATUS_LOCKED: Final = "locked" -STATUS_WAITING: Final = "waiting" -STATUS_SUSPENDED: Final = "suspended" -STATUS_PARKED: Final = "parked" - -CONN_ESTABLISHED: Final = "ESTABLISHED" -CONN_SYN_SENT: Final = "SYN_SENT" -CONN_SYN_RECV: Final = "SYN_RECV" -CONN_FIN_WAIT1: Final = "FIN_WAIT1" -CONN_FIN_WAIT2: Final = "FIN_WAIT2" -CONN_TIME_WAIT: Final = "TIME_WAIT" -CONN_CLOSE: Final = "CLOSE" -CONN_CLOSE_WAIT: Final = "CLOSE_WAIT" -CONN_LAST_ACK: Final = "LAST_ACK" -CONN_LISTEN: Final = "LISTEN" -CONN_CLOSING: Final = "CLOSING" -CONN_NONE: Final = "NONE" - -class NicDuplex(enum.IntEnum): - NIC_DUPLEX_FULL = 2 - NIC_DUPLEX_HALF = 1 - NIC_DUPLEX_UNKNOWN = 0 - -NIC_DUPLEX_FULL: Final = NicDuplex.NIC_DUPLEX_FULL -NIC_DUPLEX_HALF: Final = NicDuplex.NIC_DUPLEX_HALF -NIC_DUPLEX_UNKNOWN: Final = NicDuplex.NIC_DUPLEX_UNKNOWN - -class BatteryTime(enum.IntEnum): - POWER_TIME_UNKNOWN = -1 - POWER_TIME_UNLIMITED = -2 - -POWER_TIME_UNKNOWN: Final = BatteryTime.POWER_TIME_UNKNOWN -POWER_TIME_UNLIMITED: Final = BatteryTime.POWER_TIME_UNLIMITED - ENCODING: Final[str] ENCODING_ERRS: Final[str] @@ -102,9 +56,6 @@ _T = TypeVar("_T") def usage_percent(used: ConvertibleToFloat, total: float, round_: SupportsIndex | None = None) -> float: ... -# returned function has `cache_clear()` attribute: -def memoize(fun: Callable[_P, _R]) -> Callable[_P, _R]: ... - # returned function has `cache_activate(proc)` and `cache_deactivate(proc)` attributes: def memoize_when_activated(fun: Callable[_P, _R]) -> Callable[_P, _R]: ... def isfile_strict(path: StrOrBytesPath) -> bool: ... @@ -137,8 +88,6 @@ def conn_to_ntuple( pid: None = None, ) -> ntp.pconn: ... -def deprecated_method(replacement: str) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... - class _WrapNumbers: lock: threading.Lock cache: dict[str, dict[str, tuple[int, ...]]] @@ -171,13 +120,13 @@ def bcat(fname: FileDescriptorOrPath) -> str: ... @overload def bcat(fname: FileDescriptorOrPath, fallback: _T = ...) -> str | _T: ... -def bytes2human(n: int, format: str = "%(value).1f%(symbol)s") -> str: ... -def get_procfs_path() -> str: ... +def bytes2human(n: int) -> str: ... def decode(s: bytes) -> str: ... -def term_supports_colors(file: SupportsWrite[str] = sys.stdout) -> bool: ... -def hilite(s: str, color: str | None = None, bold: bool = False) -> str: ... +def term_supports_colors(force_color: bool = False) -> bool: ... +def hilite(s: str, color: str | None = None, bold: bool = False, force_color: bool = False) -> str: ... def print_color(s: str, color: str | None = None, bold: bool = False, file: SupportsWrite[str] = sys.stdout) -> None: ... def debug(msg: str | Exception) -> None: ... +def warn(msg: str) -> None: ... __all__ = [ # OS constants @@ -187,51 +136,16 @@ __all__ = [ "NETBSD", "OPENBSD", "MACOS", - "OSX", "POSIX", "SUNOS", "WINDOWS", - # connection constants - "CONN_CLOSE", - "CONN_CLOSE_WAIT", - "CONN_CLOSING", - "CONN_ESTABLISHED", - "CONN_FIN_WAIT1", - "CONN_FIN_WAIT2", - "CONN_LAST_ACK", - "CONN_LISTEN", - "CONN_NONE", - "CONN_SYN_RECV", - "CONN_SYN_SENT", - "CONN_TIME_WAIT", - # net constants - "NIC_DUPLEX_FULL", - "NIC_DUPLEX_HALF", - "NIC_DUPLEX_UNKNOWN", - # process status constants - "STATUS_DEAD", - "STATUS_DISK_SLEEP", - "STATUS_IDLE", - "STATUS_LOCKED", - "STATUS_RUNNING", - "STATUS_SLEEPING", - "STATUS_STOPPED", - "STATUS_SUSPENDED", - "STATUS_TRACING_STOP", - "STATUS_WAITING", - "STATUS_WAKE_KILL", - "STATUS_WAKING", - "STATUS_ZOMBIE", - "STATUS_PARKED", # other constants "ENCODING", "ENCODING_ERRS", "AF_INET6", # utility functions "conn_tmap", - "deprecated_method", "isfile_strict", - "memoize", "parse_environ_block", "path_exists_strict", "usage_percent", @@ -246,6 +160,7 @@ __all__ = [ "bytes2human", "conn_to_ntuple", "debug", + "warn", # shell utils "hilite", "term_supports_colors", diff --git a/stubs/psutil/psutil/_enums.pyi b/stubs/psutil/psutil/_enums.pyi new file mode 100644 index 000000000000..6d2d1879c963 --- /dev/null +++ b/stubs/psutil/psutil/_enums.pyi @@ -0,0 +1,109 @@ +import enum +import sys + +if sys.version_info >= (3, 11): + from enum import StrEnum as StrEnum +else: + class StrEnum(str, enum.Enum): ... # type: ignore[misc] + +class ProcessStatus(StrEnum): + STATUS_DEAD = "dead" + STATUS_DISK_SLEEP = "disk-sleep" + STATUS_IDLE = "idle" + STATUS_LOCKED = "locked" + STATUS_PARKED = "parked" + STATUS_RUNNING = "running" + STATUS_SLEEPING = "sleeping" + STATUS_STOPPED = "stopped" + STATUS_SUSPENDED = "suspended" + STATUS_TRACING_STOP = "tracing-stop" + STATUS_UNKNOWN = "unknown" + STATUS_WAITING = "waiting" + STATUS_WAKE_KILL = "wake-kill" + STATUS_WAKING = "waking" + STATUS_ZOMBIE = "zombie" + +class ConnectionStatus(StrEnum): + CONN_CLOSE = "CLOSE" + CONN_CLOSE_WAIT = "CLOSE_WAIT" + CONN_CLOSING = "CLOSING" + CONN_ESTABLISHED = "ESTABLISHED" + CONN_FIN_WAIT1 = "FIN_WAIT1" + CONN_FIN_WAIT2 = "FIN_WAIT2" + CONN_LAST_ACK = "LAST_ACK" + CONN_LISTEN = "LISTEN" + CONN_NONE = "NONE" + CONN_SYN_RECV = "SYN_RECV" + CONN_SYN_SENT = "SYN_SENT" + CONN_TIME_WAIT = "TIME_WAIT" + if sys.platform == "win32": + CONN_DELETE_TCB = "DELETE_TCB" + if sys.platform == "sunos5": # noqa: Y008 + CONN_BOUND = "BOUND" + CONN_IDLE = "IDLE" + +class NicDuplex(enum.IntEnum): + NIC_DUPLEX_FULL = 2 + NIC_DUPLEX_HALF = 1 + NIC_DUPLEX_UNKNOWN = 0 + +class BatteryTime(enum.IntEnum): + POWER_TIME_UNKNOWN = -1 + POWER_TIME_UNLIMITED = -2 + +if sys.platform == "linux": + class ProcessIOPriority(enum.IntEnum): + IOPRIO_CLASS_NONE = 0 + IOPRIO_CLASS_RT = 1 + IOPRIO_CLASS_BE = 2 + IOPRIO_CLASS_IDLE = 3 + +elif sys.platform == "win32": + class ProcessIOPriority(enum.IntEnum): + IOPRIO_VERYLOW = 0 + IOPRIO_LOW = 1 + IOPRIO_NORMAL = 2 + IOPRIO_HIGH = 3 + + class ProcessPriority(enum.IntEnum): + ABOVE_NORMAL_PRIORITY_CLASS = 32768 + BELOW_NORMAL_PRIORITY_CLASS = 16384 + HIGH_PRIORITY_CLASS = 128 + IDLE_PRIORITY_CLASS = 64 + NORMAL_PRIORITY_CLASS = 32 + REALTIME_PRIORITY_CLASS = 256 + +if sys.platform == "linux": + class ProcessRlimit(enum.IntEnum): + RLIMIT_AS = 9 + RLIMIT_CORE = 4 + RLIMIT_CPU = 0 + RLIMIT_DATA = 2 + RLIMIT_FSIZE = 1 + RLIMIT_LOCKS = 10 + RLIMIT_MEMLOCK = 8 + RLIMIT_MSGQUEUE = 12 + RLIMIT_NICE = 13 + RLIMIT_NOFILE = 7 + RLIMIT_NPROC = 6 + RLIMIT_RSS = 5 + RLIMIT_RTPRIO = 14 + RLIMIT_RTTIME = 15 + RLIMIT_SIGPENDING = 11 + RLIMIT_STACK = 3 + +elif sys.platform != "win32" and sys.platform != "darwin": # Linux or FreeBSD + class ProcessRlimit(enum.IntEnum): + RLIMIT_AS = 10 + RLIMIT_CORE = 4 + RLIMIT_CPU = 0 + RLIMIT_DATA = 2 + RLIMIT_FSIZE = 1 + RLIMIT_MEMLOCK = 6 + RLIMIT_NOFILE = 8 + RLIMIT_NPROC = 7 + RLIMIT_NPTS = 11 + RLIMIT_RSS = 5 + RLIMIT_SBSIZE = 9 + RLIMIT_STACK = 3 + RLIMIT_SWAP = 12 diff --git a/stubs/psutil/psutil/_ntuples.pyi b/stubs/psutil/psutil/_ntuples.pyi index 7e47772cdf77..4439fb3effaa 100644 --- a/stubs/psutil/psutil/_ntuples.pyi +++ b/stubs/psutil/psutil/_ntuples.pyi @@ -3,6 +3,8 @@ from _typeshed import Incomplete from socket import AddressFamily, SocketKind from typing import Any, NamedTuple +from ._enums import ConnectionStatus + # All named tuples are defined in this file, but due to the inability to detect some platforms, # it was decided to store the correct named tuples inside platform-specific files. @@ -51,7 +53,7 @@ class suser(NamedTuple): terminal: str | None host: str | None started: float - pid: str + pid: int | None class sconn(NamedTuple): fd: int @@ -59,7 +61,7 @@ class sconn(NamedTuple): type: SocketKind laddr: addr | tuple[()] raddr: addr | tuple[()] - status: str + status: ConnectionStatus pid: int | None class snicaddr(NamedTuple): @@ -157,13 +159,17 @@ class pctxsw(NamedTuple): voluntary: int involuntary: int +class ppagefaults(NamedTuple): + minor: int + major: int + class pconn(NamedTuple): fd: int family: AddressFamily type: SocketKind laddr: addr raddr: addr - status: str + status: ConnectionStatus class addr(NamedTuple): ip: str @@ -174,9 +180,9 @@ if sys.platform == "linux": # Note: scputimes has different fields depending on exactly how Linux # is setup, but we'll include the "complete" set of fields user: float - nice: float system: float idle: float + nice: float iowait: float irq: float softirq: float @@ -184,7 +190,7 @@ if sys.platform == "linux": guest: float guest_nice: float - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -220,18 +226,29 @@ if sys.platform == "linux": vms: int shared: int text: int - lib: int data: int - dirty: int + + class pmem_extras(NamedTuple): + peak_rss: int + peak_vms: int + rss_anon: int + rss_file: int + rss_shmem: int + swap_anon: int + locked: int + + class pfootprint(NamedTuple): + uss: int + shared: int + pss: int + swap: int class pfullmem(NamedTuple): rss: int vms: int shared: int text: int - lib: int data: int - dirty: int uss: int pss: int swap: int @@ -287,7 +304,7 @@ elif sys.platform == "win32": interrupt: float dpc: float - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -297,30 +314,26 @@ elif sys.platform == "win32": class pmem(NamedTuple): rss: int vms: int - num_page_faults: int - peak_wset: int - wset: int - peak_paged_pool: int + peak_rss: int + peak_vms: int + + class pmem_extras(NamedTuple): + virtual: int + peak_virtual: int paged_pool: int - peak_nonpaged_pool: int nonpaged_pool: int - pagefile: int - peak_pagefile: int - private: int + peak_paged_pool: int + peak_nonpaged_pool: int + + class pfootprint(NamedTuple): + uss: int + shared: int class pfullmem(NamedTuple): rss: int vms: int - num_page_faults: int - peak_wset: int - wset: int - peak_paged_pool: int - paged_pool: int - peak_nonpaged_pool: int - nonpaged_pool: int - pagefile: int - peak_pagefile: int - private: int + peak_rss: int + peak_vms: int uss: int class pmmap_grouped(NamedTuple): @@ -344,11 +357,11 @@ elif sys.platform == "win32": elif sys.platform == "darwin": class scputimes(NamedTuple): user: float - nice: float system: float idle: float + nice: float - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -361,24 +374,40 @@ elif sys.platform == "darwin": class pmem(NamedTuple): rss: int vms: int - pfaults: int - pageins: int + + class pmem_extras(NamedTuple): + phys_footprint: int + peak_phys_footprint: int + + class pfootprint(NamedTuple): + uss: int + shared: int class pfullmem(NamedTuple): rss: int vms: int - pfaults: int - pageins: int uss: int + class pmmap_grouped(NamedTuple): + path: str + rss: int + + class pmmap_ext(NamedTuple): + addr: str + perms: str + path: str + rss: int + else: # See _psbsd.pyi, _pssunos.pyi or _psaix.pyi - # BSD: svmem, scputimes, pmem, pfullmem, pcputimes, pmmap_grouped, pmmap_ext, sdiskio - # SUNOS: scputimes, pcputimes, svmem, pmem, pfullmem, pmmap_grouped, pmmap_ext - # AIX: pmem, pfullmem, scputimes, svmem + # BSD: smem, scputimes, pmem, pfullmem, pcputimes, pmmap_grouped, pmmap_ext, sdiskio + # SUNOS: scputimes, pcputimes, smem, pmem, pfullmem, pmmap_grouped, pmmap_ext + # AIX: pmem, pfullmem, scputimes, smem scputimes = Incomplete class pmem(Any): ... + class pmem_extras(Any): ... + class pfootprint(Any): ... class pfullmem(Any): ... - class svmem(Any): ... + class smem(Any): ... diff --git a/stubs/psutil/psutil/_psaix.pyi b/stubs/psutil/psutil/_psaix.pyi index 195fd25591e2..eade73161846 100644 --- a/stubs/psutil/psutil/_psaix.pyi +++ b/stubs/psutil/psutil/_psaix.pyi @@ -6,19 +6,15 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw from typing import Final, Literal, NamedTuple, ParamSpec, TypeVar, overload from psutil._common import ( - NIC_DUPLEX_FULL as NIC_DUPLEX_FULL, - NIC_DUPLEX_HALF as NIC_DUPLEX_HALF, - NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN, AccessDenied as AccessDenied, NoSuchProcess as NoSuchProcess, ZombieProcess as ZombieProcess, conn_to_ntuple as conn_to_ntuple, - get_procfs_path as get_procfs_path, memoize_when_activated as memoize_when_activated, usage_percent as usage_percent, ) - from . import _ntuples as ntp, _psposix, _psutil_aix + from . import _ntuples as ntp, _psposix, _psutil __extra__all__: Final[list[str]] HAS_THREADS: Final[bool] @@ -42,7 +38,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw idle: float iowait: float - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -52,21 +48,21 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw _P = ParamSpec("_P") _R = TypeVar("_R") - def virtual_memory() -> svmem: ... - def swap_memory() -> ntp.sswap: ... + def memory_physical() -> smem: ... + def memory_swap() -> ntp.sswap: ... def cpu_times() -> scputimes: ... def per_cpu_times() -> list[scputimes]: ... def cpu_count_logical() -> int | None: ... def cpu_count_cores() -> int | None: ... def cpu_stats() -> ntp.scpustats: ... - disk_io_counters = _psutil_aix.disk_io_counters + disk_io_counters = _psutil.disk_io_counters disk_usage = _psposix.disk_usage def disk_partitions(all: bool = False) -> list[ntp.sdiskpart]: ... - net_if_addrs = _psutil_aix.net_if_addrs - net_io_counters = _psutil_aix.net_io_counters + net_if_addrs = _psutil.net_if_addrs + net_io_counters = _psutil.net_io_counters @overload def net_connections(kind: str, _pid: Literal[-1] = -1) -> list[ntp.sconn]: ... @@ -103,10 +99,10 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw def terminal(self) -> str | None: ... def cwd(self) -> str: ... def memory_info(self) -> pmem: ... - memory_full_info = memory_info def status(self) -> str: ... def open_files(self) -> list[ntp.popenfile]: ... def num_fds(self) -> int: ... - def num_ctx_switches(self) -> ntp.pctxsw: ... + def ctx_switches(self) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ... def wait(self, timeout: float | None = None) -> int | None: ... def io_counters(self) -> ntp.pio: ... diff --git a/stubs/psutil/psutil/_psbsd.pyi b/stubs/psutil/psutil/_psbsd.pyi index 7b7a18140705..58235bcc127b 100644 --- a/stubs/psutil/psutil/_psbsd.pyi +++ b/stubs/psutil/psutil/_psbsd.pyi @@ -17,11 +17,10 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw ZombieProcess as ZombieProcess, conn_tmap as conn_tmap, conn_to_ntuple as conn_to_ntuple, - memoize as memoize, usage_percent as usage_percent, ) - from . import _ntuples as ntp, _psposix, _psutil_bsd + from . import _ntuples as ntp, _psposix, _psutil _P = ParamSpec("_P") _R = TypeVar("_R") @@ -30,11 +29,10 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw PROC_STATUSES: Final[dict[int, str]] TCP_STATUSES: Final[dict[int, str]] PAGESIZE: Final[int] - AF_LINK: Final = _psutil_bsd.AF_LINK + AF_LINK: Final = _psutil.AF_LINK HAS_PROC_NUM_THREADS: Final[bool] - kinfo_proc_map: Final[dict[str, int]] - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -49,9 +47,9 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw class scputimes(NamedTuple): user: float - nice: float system: float idle: float + nice: float irq: float class pmem(NamedTuple): @@ -60,6 +58,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw text: int data: int stack: int + peak_rss: int pfullmem = pmem @@ -94,10 +93,10 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw write_time: Incomplete busy_time: Incomplete - def virtual_memory() -> svmem: ... - def swap_memory() -> ntp.sswap: ... - heap_info = _psutil_bsd.heap_info # only FreeBSD and NetBSD - heap_trim = _psutil_bsd.heap_trim # only FreeBSD and NetBSD + def memory_physical() -> smem: ... + def memory_swap() -> ntp.sswap: ... + heap_info = _psutil.heap_info # only FreeBSD and NetBSD + heap_trim = _psutil.heap_trim # only FreeBSD and NetBSD def cpu_times() -> scputimes: ... def per_cpu_times() -> list[scputimes]: ... def cpu_count_logical() -> int | None: ... @@ -106,9 +105,9 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw def disk_partitions(all: bool = False) -> list[ntp.sdiskpart]: ... disk_usage = _psposix.disk_usage - disk_io_counters = _psutil_bsd.disk_io_counters - net_io_counters = _psutil_bsd.net_io_counters - net_if_addrs = _psutil_bsd.net_if_addrs + disk_io_counters = _psutil.disk_io_counters + net_io_counters = _psutil.net_io_counters + net_if_addrs = _psutil.net_if_addrs def net_if_stats() -> dict[str, ntp.snicstats]: ... def net_connections(kind: str) -> list[ntp.sconn]: ... @@ -172,10 +171,10 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw def cpu_times(self) -> ntp.pcputimes: ... def cpu_num(self) -> int: ... # only FreeBSD def memory_info(self) -> pmem: ... - memory_full_info = memory_info def create_time(self, monotonic: bool = False) -> float: ... + def ctx_switches(self) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ... def num_threads(self) -> int: ... - def num_ctx_switches(self) -> ntp.pctxsw: ... def threads(self) -> list[ntp.pthread]: ... def net_connections(self, kind: str = "inet") -> list[ntp.pconn]: ... def wait(self, timeout: float | None = None) -> int | None: ... diff --git a/stubs/psutil/psutil/_pslinux.pyi b/stubs/psutil/psutil/_pslinux.pyi index 34bb16456b44..30c364b08b00 100644 --- a/stubs/psutil/psutil/_pslinux.pyi +++ b/stubs/psutil/psutil/_pslinux.pyi @@ -10,9 +10,6 @@ if sys.platform == "linux": from psutil._common import ( ENCODING as ENCODING, - NIC_DUPLEX_FULL as NIC_DUPLEX_FULL, - NIC_DUPLEX_HALF as NIC_DUPLEX_HALF, - NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN, AccessDenied as AccessDenied, NoSuchProcess as NoSuchProcess, ZombieProcess as ZombieProcess, @@ -20,9 +17,7 @@ if sys.platform == "linux": cat as cat, debug as debug, decode as decode, - get_procfs_path as get_procfs_path, isfile_strict as isfile_strict, - memoize as memoize, memoize_when_activated as memoize_when_activated, open_binary as open_binary, open_text as open_text, @@ -32,7 +27,7 @@ if sys.platform == "linux": usage_percent as usage_percent, ) - from . import _ntuples as ntp, _psposix, _psutil_linux + from . import _ntuples as ntp, _psposix, _psutil _P = ParamSpec("_P") _R = TypeVar("_R") @@ -74,10 +69,10 @@ if sys.platform == "linux": def _scputimes_ntuple(procfs_path: str) -> type[ntp.scputimes]: ... scputimes = ntp.scputimes def calculate_avail_vmem(mems: dict[bytes, int]) -> int: ... - def virtual_memory() -> ntp.svmem: ... - def swap_memory() -> ntp.sswap: ... - heap_info = _psutil_linux.heap_info - heap_trim = _psutil_linux.heap_trim + def memory_physical() -> ntp.smem: ... + def memory_swap() -> ntp.sswap: ... + heap_info = _psutil.heap_info + heap_trim = _psutil.heap_trim def cpu_times() -> ntp.scputimes: ... def per_cpu_times() -> list[ntp.scputimes]: ... def cpu_count_logical() -> int | None: ... @@ -85,7 +80,7 @@ if sys.platform == "linux": def cpu_stats() -> ntp.scpustats: ... def cpu_freq() -> list[ntp.scpufreq]: ... - net_if_addrs = _psutil_linux.net_if_addrs + net_if_addrs = _psutil.net_if_addrs class _Ipv6UnsupportedError(Exception): ... @@ -156,10 +151,12 @@ if sys.platform == "linux": def wait(self, timeout: float | None = None) -> int | None: ... def create_time(self, monotonic: bool = False) -> float: ... def memory_info(self) -> ntp.pmem: ... - def memory_full_info(self) -> ntp.pfullmem: ... + def memory_extras(self) -> ntp.pmem_extras: ... + def memory_footprint(self) -> ntp.pfootprint: ... def memory_maps(self) -> list[tuple[str, str, str, int, int, int, int, int, int, int, int, int, int]]: ... def cwd(self) -> str: ... - def num_ctx_switches(self, _ctxsw_re: re.Pattern[bytes] = ...) -> ntp.pctxsw: ... + def ctx_switches(self, _ctxsw_re: re.Pattern[bytes] = ...) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ... def num_threads(self, _num_threads_re: re.Pattern[bytes] = ...) -> int: ... def threads(self) -> list[ntp.pthread]: ... def nice_get(self) -> int: ... diff --git a/stubs/psutil/psutil/_psosx.pyi b/stubs/psutil/psutil/_psosx.pyi index b8f5cbce2acc..b57a06457863 100644 --- a/stubs/psutil/psutil/_psosx.pyi +++ b/stubs/psutil/psutil/_psosx.pyi @@ -17,7 +17,7 @@ if sys.platform == "darwin": usage_percent as usage_percent, ) - from . import _ntuples as ntp, _psposix, _psutil_osx + from . import _ntuples as ntp, _psposix, _psutil _P = ParamSpec("_P") _R = TypeVar("_R") @@ -27,13 +27,11 @@ if sys.platform == "darwin": AF_LINK: Final[int] TCP_STATUSES: Final[dict[int, str]] PROC_STATUSES: Final[dict[int, str]] - kinfo_proc_map: Final[dict[str, int]] - pidtaskinfo_map: Final[dict[str, int]] - def virtual_memory() -> ntp.svmem: ... - def swap_memory() -> ntp.sswap: ... - heap_info = _psutil_osx.heap_info - heap_trim = _psutil_osx.heap_trim + def memory_physical() -> ntp.smem: ... + def memory_swap() -> ntp.sswap: ... + heap_info = _psutil.heap_info + heap_trim = _psutil.heap_trim def cpu_times() -> ntp.scputimes: ... def per_cpu_times() -> list[ntp.scputimes]: ... def cpu_count_logical() -> int | None: ... @@ -42,12 +40,12 @@ if sys.platform == "darwin": def cpu_freq() -> list[ntp.scpufreq]: ... disk_usage = _psposix.disk_usage - disk_io_counters = _psutil_osx.disk_io_counters + disk_io_counters = _psutil.disk_io_counters def disk_partitions(all: bool = False) -> list[ntp.sdiskpart]: ... def sensors_battery() -> ntp.sbattery | None: ... - net_io_counters = _psutil_osx.net_io_counters - net_if_addrs = _psutil_osx.net_if_addrs + net_io_counters = _psutil.net_io_counters + net_if_addrs = _psutil.net_if_addrs def net_connections(kind: str = "inet") -> list[ntp.sconn]: ... def net_if_stats() -> dict[str, ntp.snicstats]: ... def boot_time() -> float: ... @@ -74,10 +72,12 @@ if sys.platform == "darwin": def gids(self) -> ntp.puids: ... def terminal(self) -> str | None: ... def memory_info(self) -> ntp.pmem: ... - def memory_full_info(self) -> ntp.pfullmem: ... + def memory_extras(self) -> ntp.pmem_extras: ... + def memory_footprint(self) -> ntp.pfootprint: ... def cpu_times(self) -> ntp.pcputimes: ... def create_time(self, monotonic: bool = False) -> float: ... - def num_ctx_switches(self) -> ntp.pctxsw: ... + def ctx_switches(self) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ... def num_threads(self) -> int: ... def open_files(self) -> list[ntp.popenfile]: ... def net_connections(self, kind: str = "inet") -> list[ntp.pconn]: ... diff --git a/stubs/psutil/psutil/_psposix.pyi b/stubs/psutil/psutil/_psposix.pyi index 69694bfa4490..2f021545d6dc 100644 --- a/stubs/psutil/psutil/_psposix.pyi +++ b/stubs/psutil/psutil/_psposix.pyi @@ -8,7 +8,7 @@ from . import _ntuples as ntp def pid_exists(pid: int) -> bool: ... # Sync with `signal.Signals`, but with opposite values: -class Negsignal(enum.IntEnum): +class NegSignal(enum.IntEnum): SIGABRT = -6 SIGFPE = -8 SIGILL = -4 @@ -57,7 +57,7 @@ class Negsignal(enum.IntEnum): if sys.version_info >= (3, 11): SIGSTKFLT = -16 -def negsig_to_enum(num: int) -> int: ... +def negsig_to_enum(num: int) -> NegSignal | int: ... def convert_exit_code(status: int) -> int: ... def wait_pid_posix( pid: int, @@ -80,6 +80,6 @@ if sys.platform == "darwin": else: def disk_usage(path: FileDescriptorOrPath) -> ntp.sdiskusage: ... -def get_terminal_map() -> dict[int, str]: ... +def get_terminal(tty_nr: int) -> str | None: ... -__all__ = ["pid_exists", "wait_pid", "disk_usage", "get_terminal_map"] +__all__ = ["pid_exists", "wait_pid", "disk_usage", "get_terminal"] diff --git a/stubs/psutil/psutil/_pssunos.pyi b/stubs/psutil/psutil/_pssunos.pyi index d1e3b6dba4aa..e23686e9c4d1 100644 --- a/stubs/psutil/psutil/_pssunos.pyi +++ b/stubs/psutil/psutil/_pssunos.pyi @@ -13,7 +13,6 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw NoSuchProcess as NoSuchProcess, ZombieProcess as ZombieProcess, debug as debug, - get_procfs_path as get_procfs_path, isfile_strict as isfile_strict, memoize_when_activated as memoize_when_activated, sockfam_to_enum as sockfam_to_enum, @@ -21,7 +20,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw usage_percent as usage_percent, ) - from . import _ntuples as ntp, _psposix, _psutil_sunos + from . import _ntuples as ntp, _psposix, _psutil _P = ParamSpec("_P") _R = TypeVar("_R") @@ -48,7 +47,7 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw children_user: float children_system: float - class svmem(NamedTuple): + class smem(NamedTuple): total: int available: int percent: float @@ -75,21 +74,21 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw anonymous: Incomplete locked: Incomplete - def virtual_memory() -> svmem: ... - def swap_memory() -> ntp.sswap: ... + def memory_physical() -> smem: ... + def memory_swap() -> ntp.sswap: ... def cpu_times() -> scputimes: ... def per_cpu_times() -> list[scputimes]: ... def cpu_count_logical() -> int | None: ... def cpu_count_cores() -> int | None: ... def cpu_stats() -> ntp.scpustats: ... - disk_io_counters = _psutil_sunos.disk_io_counters + disk_io_counters = _psutil.disk_io_counters disk_usage = _psposix.disk_usage def disk_partitions(all: bool = False) -> list[ntp.sdiskpart]: ... - net_io_counters = _psutil_sunos.net_io_counters - net_if_addrs = _psutil_sunos.net_if_addrs + net_io_counters = _psutil.net_io_counters + net_if_addrs = _psutil.net_if_addrs @overload def net_connections(kind: str, _pid: Literal[-1] = -1) -> list[ntp.sconn]: ... @@ -125,8 +124,9 @@ if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darw def terminal(self) -> str | None: ... def cwd(self) -> str: ... def memory_info(self) -> pmem: ... - memory_full_info = memory_info def status(self) -> str: ... + def ctx_switches(self) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ... def threads(self) -> list[ntp.pthread]: ... def open_files(self) -> list[ntp.popenfile]: ... def net_connections(self, kind: str = "inet") -> list[ntp.pconn]: ... diff --git a/stubs/psutil/psutil/_psutil.pyi b/stubs/psutil/psutil/_psutil.pyi new file mode 100644 index 000000000000..08cecc6f7e48 --- /dev/null +++ b/stubs/psutil/psutil/_psutil.pyi @@ -0,0 +1,356 @@ +import sys + +if sys.platform == "linux": + from collections.abc import Sequence + from typing import Final + + RLIMIT_AS: Final[int] + RLIMIT_CORE: Final[int] + RLIMIT_CPU: Final[int] + RLIMIT_DATA: Final[int] + RLIMIT_FSIZE: Final[int] + RLIMIT_MEMLOCK: Final[int] + RLIMIT_NOFILE: Final[int] + RLIMIT_NPROC: Final[int] + RLIMIT_RSS: Final[int] + RLIMIT_STACK: Final[int] + RLIMIT_LOCKS: Final[int] + RLIMIT_MSGQUEUE: Final[int] + RLIMIT_NICE: Final[int] + RLIMIT_RTPRIO: Final[int] + RLIMIT_RTTIME: Final[int] + RLIMIT_SIGPENDING: Final[int] + RLIM_INFINITY: Final[int] + + version: Final[int] + DUPLEX_FULL: Final[int] + DUPLEX_HALF: Final[int] + DUPLEX_UNKNOWN: Final[int] + + class ZombieProcessError(Exception): ... + + def getpagesize() -> int: ... + def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... + def net_if_flags(nic_name: str, /) -> list[str]: ... + def net_if_is_running(nic_name: str, /) -> bool: ... + def net_if_mtu(nic_name: str, /) -> int: ... + def proc_priority_get(pid: int, /) -> int: ... + def proc_priority_set(pid: int, priority: int, /) -> None: ... + def users() -> list[tuple[str, str, str, float, int]]: ... + def proc_ioprio_get(pid: int, /) -> tuple[int, int]: ... + def proc_ioprio_set(pid: int, ioclass: int, iodata: int, /) -> None: ... + def proc_cpu_affinity_get(pid: int, /) -> list[int]: ... + def proc_cpu_affinity_set(pid: int, cpu_set: Sequence[int], /) -> None: ... + def disk_partitions(mtab_path: str, /) -> list[tuple[str, str, str, str]]: ... + def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements + def heap_info() -> tuple[int, int]: ... + def heap_trim() -> bool: ... + def linux_sysinfo() -> tuple[int, int, int, int, int, int, int]: ... + def check_pid_range(pid: int, /) -> None: ... + def set_debug(value: bool, /) -> None: ... + +elif sys.platform == "win32": + from _typeshed import Incomplete + from collections.abc import Sequence + from socket import AddressFamily, SocketKind + from typing import Final + + version: Final[int] + ABOVE_NORMAL_PRIORITY_CLASS: Final = 32768 + BELOW_NORMAL_PRIORITY_CLASS: Final = 16384 + HIGH_PRIORITY_CLASS: Final = 128 + IDLE_PRIORITY_CLASS: Final = 64 + NORMAL_PRIORITY_CLASS: Final = 32 + REALTIME_PRIORITY_CLASS: Final = 256 + MIB_TCP_STATE_CLOSED: Final = 1 + MIB_TCP_STATE_CLOSING: Final = 9 + MIB_TCP_STATE_CLOSE_WAIT: Final = 8 + MIB_TCP_STATE_LISTEN: Final = 2 + MIB_TCP_STATE_ESTAB: Final = 5 + MIB_TCP_STATE_SYN_SENT: Final = 3 + MIB_TCP_STATE_SYN_RCVD: Final = 4 + MIB_TCP_STATE_FIN_WAIT1: Final = 6 + MIB_TCP_STATE_FIN_WAIT2: Final = 7 + MIB_TCP_STATE_LAST_ACK: Final = 10 + MIB_TCP_STATE_TIME_WAIT: Final = 11 + MIB_TCP_STATE_DELETE_TCB: Final = 12 + PSUTIL_CONN_NONE: Final = 128 + INFINITE: Final[int] + ERROR_ACCESS_DENIED: Final = 5 + ERROR_INVALID_NAME: Final = 123 + ERROR_SERVICE_DOES_NOT_EXIST: Final = 1060 + ERROR_PRIVILEGE_NOT_HELD: Final = 1314 + WINVER: Final[int] + WINDOWS_VISTA: Final = 60 + WINDOWS_7: Final = 61 + WINDOWS_8: Final = 62 + WINDOWS_8_1: Final = 63 + WINDOWS_10: Final = 100 + + class TimeoutAbandoned(Exception): ... + class TimeoutExpired(Exception): ... + + def proc_cmdline(pid: int, use_peb: bool = True) -> list[str]: ... + def proc_cpu_affinity_get(pid: int, /) -> int: ... + def proc_cpu_affinity_set(pid: int, mask: int, /) -> None: ... + def proc_cwd(pid: int, /) -> str: ... + def proc_environ(pid: int, /) -> str: ... + def proc_exe(pid: int, /) -> str: ... + def proc_io_counters(pid: int, /) -> tuple[int, int, int, int, int, int]: ... + def proc_io_priority_get(pid: int, /) -> int: ... + def proc_io_priority_set(pid: int, priority: int, /) -> None: ... + def proc_kill(pid: int, /) -> None: ... + def proc_memory_info(pid: int, /) -> tuple[int, int, int, int, int, int, int, int, int, int]: ... + def proc_memory_footprint(pid: int, /) -> dict[str, int]: ... + def proc_memory_maps(pid: int, /) -> list[tuple[int, str, str, int]]: ... + def proc_num_handles(pid: int, /) -> int: ... + def proc_open_files(pid: int, /) -> list[str]: ... + def proc_ppid(pid: int, /) -> int: ... + def proc_priority_get(pid: int, /) -> int: ... + def proc_priority_set(pid: int, priority: int, /) -> None: ... + def proc_suspend_or_resume(pid: int, suspend: bool | None, /) -> None: ... + def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... + def proc_times(pid: int, /) -> tuple[float, float, float]: ... + def proc_username(pid: int, /) -> tuple[str, str]: ... + def proc_wait(pid: int, timeout: int, /) -> int | None: ... + def proc_oneshot(pid: int, /) -> dict[str, Incomplete]: ... + def boot_time() -> float: ... + def cpu_count_cores() -> int | None: ... + def cpu_count_logical() -> int | None: ... + def cpu_freq() -> tuple[int, int]: ... + def cpu_stats() -> tuple[int, int, int, int]: ... + def cpu_times() -> tuple[float, float, float]: ... + def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... + def disk_partitions(all: bool, /) -> list[tuple[str, str, str, str]]: ... + def disk_usage(path: str, /) -> tuple[int, int, int]: ... + def drive_devices() -> list[str]: ... + def getloadavg() -> tuple[float, float, float]: ... + def getpagesize() -> int: ... + def swap_percent() -> float: ... + def init_loadavg_counter() -> None: ... + def heap_info() -> tuple[int, int, int]: ... + def heap_trim() -> int: ... + def net_connections( + pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / + ) -> list[tuple[int, int, int, tuple[str | None, int], tuple[str | None, int], int, int]]: ... + def net_if_addrs() -> list[tuple[str, int, str, str | None, None, None]]: ... + def net_if_stats() -> dict[str, tuple[bool, int, int, int]]: ... + def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... + def per_cpu_times() -> list[tuple[float, float, float, float, float]]: ... + def pid_exists(pid: int, /) -> bool: ... + def pids() -> list[int]: ... + def ppid_map() -> dict[int, int]: ... + def sensors_battery() -> tuple[int, int, int, int]: ... + def users() -> list[tuple[str, str | None, float]]: ... + def winservice_enumerate() -> list[tuple[str, str]]: ... + def winservice_query_config(service_name: str, /) -> tuple[str, str, str, str]: ... + def winservice_query_descr(service_name: str, /) -> str: ... + def winservice_query_status(service_name: str, /) -> tuple[str, int] | str: ... + def winservice_start(service_name: str, /) -> None: ... + def winservice_stop(service_name: str, /) -> None: ... + def GetPerformanceInfo() -> dict[str, Incomplete]: ... + def check_pid_range(pid: int, /) -> None: ... + def set_debug(value: bool, /) -> None: ... + +elif sys.platform == "darwin": + from _typeshed import Incomplete, StrOrBytesPath + from collections.abc import Sequence + from socket import AddressFamily, SocketKind + from typing import Final, TypeVar + + _T = TypeVar("_T") + + AF_LINK: Final = 18 + NODEV: Final = -1 + + def getpagesize() -> int: ... + def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... + def net_if_flags(nic_name: str, /) -> list[str]: ... + def net_if_is_running(nic_name: str, /) -> bool: ... + def net_if_mtu(nic_name: str, /) -> int: ... + def proc_priority_get(pid: int, /) -> int: ... + def proc_priority_set(pid: int, priority: int, /) -> None: ... + def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements + def users() -> list[tuple[str, str, str, float, int]]: ... + def proc_is_zombie(pid: int, /) -> bool: ... + + version: Final[int] + SIDL: Final = 1 + SRUN: Final = 2 + SSLEEP: Final = 3 + SSTOP: Final = 4 + SZOMB: Final = 5 + TCPS_CLOSED: Final = 0 + TCPS_CLOSING: Final = 7 + TCPS_CLOSE_WAIT: Final = 5 + TCPS_LISTEN: Final = 1 + TCPS_ESTABLISHED: Final = 4 + TCPS_SYN_SENT: Final = 2 + TCPS_SYN_RECEIVED: Final = 3 + TCPS_FIN_WAIT_1: Final = 6 + TCPS_FIN_WAIT_2: Final = 9 + TCPS_LAST_ACK: Final = 8 + TCPS_TIME_WAIT: Final = 10 + PSUTIL_CONN_NONE: Final = 128 + + class ZombieProcessError(Exception): ... + + def proc_cmdline(pid: int, /) -> list[str]: ... + def proc_cwd(pid: int, /) -> str: ... + def proc_environ(pid: int, /) -> str: ... + def proc_exe(pid: int, /) -> str: ... + def proc_oneshot_kinfo(pid: int, /) -> dict[str, Incomplete]: ... + def proc_memory_footprint(pid: int, /) -> dict[str, Incomplete]: ... + def proc_name(pid: int, /) -> str: ... + def proc_net_connections( + pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / + ) -> list[ + tuple[int, int, int, tuple[str | None, int], tuple[str | None, int] | tuple[()], int] + | tuple[int, int, int, str, str, int] + ]: ... + def proc_num_fds(pid: int, /) -> int: ... + def proc_open_files(pid: int, /) -> list[tuple[str, int]]: ... + def proc_oneshot_pidtaskinfo(pid: int, /) -> dict[str, Incomplete]: ... + def proc_memory_extras(pid: int, /) -> dict[str, Incomplete]: ... + def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... + def boot_time() -> float: ... + def cpu_count_cores() -> int | None: ... + def cpu_count_logical() -> int | None: ... + def cpu_freq() -> tuple[int, int, int]: ... + def cpu_times() -> tuple[float, float, float, float]: ... + def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... + def disk_partitions() -> list[tuple[str, str, str, str]]: ... + def disk_usage_used(mount_point: StrOrBytesPath, default: _T, /) -> int | _T: ... + def heap_info() -> tuple[int, int]: ... + def heap_trim() -> None: ... + def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... + def per_cpu_times() -> list[tuple[float, float, float, float]]: ... + def pids() -> list[int]: ... + def sensors_battery() -> tuple[int, int, int]: ... + def memory_physical() -> dict[str, Incomplete]: ... + def memory_swap() -> dict[str, Incomplete]: ... + def check_pid_range(pid: int, /) -> None: ... + def set_debug(value: bool, /) -> None: ... + +else: + # BSD, SunOS and AIX. These platforms are not exercised by typeshed CI. + from _typeshed import Incomplete + from collections.abc import Sequence + from socket import AddressFamily, SocketKind + from typing import Final, overload + + AF_LINK: Final[int] + NODEV: Final[int] + PRNODEV: Final[int] + RLIMIT_AS: Final[int] # only FreeBSD + RLIMIT_CORE: Final[int] # only FreeBSD + RLIMIT_CPU: Final[int] # only FreeBSD + RLIMIT_DATA: Final[int] # only FreeBSD + RLIMIT_FSIZE: Final[int] # only FreeBSD + RLIMIT_MEMLOCK: Final[int] # only FreeBSD + RLIMIT_NOFILE: Final[int] # only FreeBSD + RLIMIT_NPROC: Final[int] # only FreeBSD + RLIMIT_RSS: Final[int] # only FreeBSD + RLIMIT_STACK: Final[int] # only FreeBSD + RLIMIT_SWAP: Final[int] # only FreeBSD + RLIMIT_SBSIZE: Final[int] # only FreeBSD + RLIMIT_NPTS: Final[int] # only FreeBSD + RLIM_INFINITY: Final[int] # only FreeBSD + + version: Final[int] + SIDL: Final[int] + SRUN: Final[int] + SSLEEP: Final[int] + SSTOP: Final[int] + SZOMB: Final[int] + SWAIT: Final[int] + SLOCK: Final[int] + SDEAD: Final[int] + SONPROC: Final[int] + SSUSPENDED: Final[int] + SACTIVE: Final[int] + SSWAP: Final[int] + TCPS_CLOSED: Final[int] + TCPS_CLOSING: Final[int] + TCPS_CLOSE_WAIT: Final[int] + TCPS_LISTEN: Final[int] + TCPS_ESTABLISHED: Final[int] + TCPS_SYN_SENT: Final[int] + TCPS_SYN_RECEIVED: Final[int] + TCPS_SYN_RCVD: Final[int] + TCPS_FIN_WAIT_1: Final[int] + TCPS_FIN_WAIT_2: Final[int] + TCPS_LAST_ACK: Final[int] + TCPS_TIME_WAIT: Final[int] + TCPS_IDLE: Final[int] + TCPS_BOUND: Final[int] + PSUTIL_CONN_NONE: Final = 128 + + class ZombieProcessError(Exception): ... + + def getpagesize() -> int: ... + def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... + def net_if_flags(nic_name: str, /) -> list[str]: ... + def net_if_is_running(nic_name: str, /) -> bool: ... + def net_if_mtu(nic_name: str, /) -> int: ... + def proc_priority_get(pid: int, /) -> int: ... + def proc_priority_set(pid: int, priority: int, /) -> None: ... + def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... + def users() -> list[tuple[str, str, str, float, int | None]]: ... + def proc_is_zombie(pid: int, /) -> bool: ... + def proc_cmdline(pid: int, /) -> list[str]: ... + def proc_cwd(pid: int, /) -> str: ... + def proc_environ(pid: int, procfs_path: str = ..., /) -> dict[str, str]: ... + def proc_name(pid: int, procfs_path: str = ..., /) -> str: ... + def proc_name_and_args(pid: int, procfs_path: str, /) -> tuple[str, list[str] | None]: ... + def proc_args(pid: int, /) -> list[str]: ... + def proc_num_fds(pid: int, /) -> int: ... + def proc_oneshot_kinfo(pid: int, /) -> dict[str, Incomplete]: ... + def proc_oneshot(pid: int, procfs_path: str = ..., /) -> dict[str, Incomplete]: ... + def proc_open_files(pid: int, /) -> list[tuple[str, int]]: ... + def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... + def proc_query_thread(pid: int, tid: int, procfs_path: str, /) -> tuple[float, float]: ... + def proc_num_threads(pid: int, /) -> int: ... + def proc_cpu_affinity_get(pid: int, /) -> list[int]: ... + def proc_cpu_affinity_set(pid: int, cpu_set: Sequence[int], /) -> None: ... + def proc_exe(pid: int, /) -> str: ... + def proc_getrlimit(pid: int, resource: int, /) -> tuple[int, int]: ... + def proc_setrlimit(pid: int, resource: int, soft: int, hard: int, /) -> None: ... + def proc_memory_maps(pid: int, procfs_path: str = ..., /) -> list[tuple[Incomplete, ...]]: ... + def proc_net_connections( + pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / + ) -> list[tuple[Incomplete, ...]]: ... + def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[Incomplete, ...]: ... + def proc_cpu_num(pid: int, procfs_path: str, /) -> int: ... + def proc_cpu_times(pid: int, procfs_path: str = ..., /) -> tuple[float, float, float, float]: ... + def proc_cred(pid: int, procfs_path: str = ..., /) -> tuple[Incomplete, ...]: ... + def proc_io_counters(pid: int, /) -> tuple[int, int, int, int]: ... + def proc_num_ctx_switches(pid: int, procfs_path: str = ..., /) -> tuple[int, int]: ... + def proc_page_faults(pid: int, procfs_path: str = ..., /) -> tuple[int, int]: ... + def boot_time() -> float: ... + def cpu_count_cores() -> int | None: ... + def cpu_count_logical() -> int | None: ... + def cpu_stats() -> tuple[Incomplete, ...]: ... + def cpu_times() -> tuple[float, float, float, float, float]: ... + def disk_io_counters() -> dict[str, tuple[Incomplete, ...]]: ... + def disk_partitions() -> list[tuple[str, str, str, str]]: ... + def memory_physical() -> dict[str, Incomplete]: ... + def memory_swap() -> dict[str, Incomplete]: ... + def net_connections(*args) -> list[tuple[Incomplete, ...]]: ... + def net_if_stats() -> dict[str, tuple[bool, int, int, int]]: ... + def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... + def per_cpu_times() -> list[tuple[float, float, float, float, float]]: ... + def pids() -> list[int]: ... + def heap_info() -> tuple[int, int]: ... + def heap_trim() -> None: ... + + @overload + def cpu_freq() -> int: ... + @overload + def cpu_freq(core: int, /) -> tuple[int, str]: ... + + def cpu_topology() -> str | None: ... + def sensors_battery() -> tuple[int, int, int]: ... + def sensors_cpu_temperature(core: int, /) -> tuple[int, int]: ... + def check_pid_range(pid: int, /) -> None: ... + def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_aix.pyi b/stubs/psutil/psutil/_psutil_aix.pyi deleted file mode 100644 index 17977e3eadcb..000000000000 --- a/stubs/psutil/psutil/_psutil_aix.pyi +++ /dev/null @@ -1,58 +0,0 @@ -import sys - -# sys.platform.startswith("aix"): -if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": - from typing import Final - - AF_LINK: Final = 18 - - def getpagesize() -> int: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... - def net_if_flags(nic_name: str, /) -> list[str]: ... - def net_if_is_running(nic_name: str, /) -> bool: ... - def net_if_mtu(nic_name: str, /) -> int: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - - version: Final[int] - SIDL: Final[int] - SZOMB: Final[int] - SACTIVE: Final[int] - SSWAP: Final[int] - SSTOP: Final[int] - TCPS_CLOSED: Final[int] - TCPS_CLOSING: Final[int] - TCPS_CLOSE_WAIT: Final[int] - TCPS_LISTEN: Final[int] - TCPS_ESTABLISHED: Final[int] - TCPS_SYN_SENT: Final[int] - TCPS_SYN_RCVD: Final[int] - TCPS_FIN_WAIT_1: Final[int] - TCPS_FIN_WAIT_2: Final[int] - TCPS_LAST_ACK: Final[int] - TCPS_TIME_WAIT: Final[int] - PSUTIL_CONN_NONE: Final = 128 - - def proc_args(pid: int, /) -> list[str]: ... - def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[int, int, int, float, int, int, int, int]: ... - def proc_cpu_times(pid: int, procfs_path: str, /) -> tuple[float, float, float, float]: ... - def proc_cred(pid: int, procfs_path: str, /) -> tuple[int, int, int, int, int, int]: ... - def proc_environ(pid: int, /) -> dict[str, str]: ... - def proc_name(pid: int, procfs_path: str, /) -> str: ... - def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... - def proc_io_counters(pid: int, /) -> tuple[int, int, int, int]: ... - def proc_num_ctx_switches(requested_pid: int, /) -> tuple[int, int]: ... - def boot_time() -> float: ... - def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... - def disk_partitions() -> list[tuple[str, str, str, str]]: ... - def per_cpu_times() -> list[tuple[float, float, float, float]]: ... - def swap_mem() -> tuple[int, int, int, int]: ... - def virtual_mem() -> tuple[int, int, int, int, int]: ... - def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... - def cpu_stats() -> tuple[int, int, int, int]: ... - def net_connections( - requested_pid: int, / - ) -> list[tuple[int, int, int, str | tuple[str, int], str | tuple[str, int] | tuple[()], int, int]]: ... - def net_if_stats(nic_name: str, /) -> tuple[bool, int]: ... # It's actually list of 2 elements - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_bsd.pyi b/stubs/psutil/psutil/_psutil_bsd.pyi deleted file mode 100644 index 9aabf5116d03..000000000000 --- a/stubs/psutil/psutil/_psutil_bsd.pyi +++ /dev/null @@ -1,145 +0,0 @@ -import sys - -# sys.platform.startswith(("freebsd", "midnightbsd", "openbsd", "netbsd")): -if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": - from collections.abc import Sequence - from socket import AddressFamily, SocketKind - from typing import Final, overload - - AF_LINK: Final[int] - RLIMIT_AS: Final[int] # only FreeBSD - RLIMIT_CORE: Final[int] # only FreeBSD - RLIMIT_CPU: Final[int] # only FreeBSD - RLIMIT_DATA: Final[int] # only FreeBSD - RLIMIT_FSIZE: Final[int] # only FreeBSD - RLIMIT_MEMLOCK: Final[int] # only FreeBSD - RLIMIT_NOFILE: Final[int] # only FreeBSD - RLIMIT_NPROC: Final[int] # only FreeBSD - RLIMIT_RSS: Final[int] # only FreeBSD - RLIMIT_STACK: Final[int] # only FreeBSD - RLIMIT_SWAP: Final[int] # only FreeBSD - RLIMIT_SBSIZE: Final[int] # only FreeBSD - RLIMIT_NPTS: Final[int] # only FreeBSD - RLIM_INFINITY: Final[int] # only FreeBSD - - def getpagesize() -> int: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... - def net_if_flags(nic_name: str, /) -> list[str]: ... - def net_if_is_running(nic_name: str, /) -> bool: ... - def net_if_mtu(nic_name: str, /) -> int: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements - def proc_is_zombie(pid: int, /) -> bool: ... - - version: Final[int] - SIDL: Final[int] - SRUN: Final[int] - SSLEEP: Final[int] - SSTOP: Final[int] - SZOMB: Final[int] - SWAIT: Final[int] # only FreeBSD - SLOCK: Final[int] # only FreeBSD - SDEAD: Final[int] # only OpenBSD and NetBSD - SONPROC: Final[int] # only OpenBSD and NetBSD - SSUSPENDED: Final[int] # only NetBSD - TCPS_CLOSED: Final[int] - TCPS_CLOSING: Final[int] - TCPS_CLOSE_WAIT: Final[int] - TCPS_LISTEN: Final[int] - TCPS_ESTABLISHED: Final[int] - TCPS_SYN_SENT: Final[int] - TCPS_SYN_RECEIVED: Final[int] - TCPS_FIN_WAIT_1: Final[int] - TCPS_FIN_WAIT_2: Final[int] - TCPS_LAST_ACK: Final[int] - TCPS_TIME_WAIT: Final[int] - PSUTIL_CONN_NONE: Final = 128 - - def proc_cmdline(pid: int, /) -> list[str]: ... - def proc_cwd(pid: int, /) -> str: ... - def proc_environ(pid: int, /) -> dict[str, str]: ... - def proc_name(pid: int, /) -> str: ... - def proc_num_fds(pid: int, /) -> int: ... - def proc_oneshot_info( - pid: int, / - ) -> tuple[ - int, - int, - int, - int, - int, - int, - int, - int, - int, - float, - int, - int, - int, - int, - float, - float, - float, - float, - int, - int, - int, - int, - int, - int, - str, - ]: ... - def proc_open_files(pid: int, /) -> list[tuple[str, int]]: ... - def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... - def proc_num_threads(pid: int, /) -> int: ... # only FreeBSD and NetBSD - def proc_cpu_affinity_get(pid: int, /) -> list[int]: ... # only FreeBSD - def proc_cpu_affinity_set(pid: int, cpu_set: Sequence[int], /) -> None: ... # only FreeBSD - def proc_exe(pid: int, /) -> str: ... # only FreeBSD - def proc_getrlimit(pid: int, resource: int, /) -> tuple[int, int]: ... # only FreeBSD - def proc_memory_maps(pid: int, /) -> list[tuple[str, str, str, int, int, int, int]]: ... # only FreeBSD - def proc_net_connections( # only FreeBSD - pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / - ) -> list[tuple[int, int, int, tuple[str, int], tuple[str, int] | tuple[()], int] | tuple[int, int, int, str, str, int]]: ... - def proc_setrlimit(pid: int, resource: int, soft: int, hard: int, /) -> None: ... # only FreeBSD - def boot_time() -> float: ... - def cpu_count_logical() -> int | None: ... - def cpu_stats() -> tuple[int, ...]: ... # tuple's length depends on OS - def cpu_times() -> tuple[float, float, float, float, float]: ... - def disk_io_counters() -> dict[str, tuple[int, ...]]: ... # tuple's length depends on OS - def disk_partitions() -> list[tuple[str, str, str, str]]: ... - - @overload # for FreeBSD - def net_connections( - af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / - ) -> list[ - tuple[int, int, int, tuple[str, int], tuple[str, int] | tuple[()], int, int] | tuple[int, int, int, str, str, int, int] - ]: ... - @overload # for OpenBSD - def net_connections( - pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / - ) -> list[ - tuple[int, int, int, tuple[str, int], tuple[str, int] | tuple[()], int, int] | tuple[int, int, int, str, str, int, int] - ]: ... - @overload # for NetBSD - def net_connections(pid: int, kind: str, /) -> list[tuple[int, int, int, str, str, int, int]]: ... - - def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... - def per_cpu_times() -> list[tuple[float, float, float, float, float]]: ... - def pids() -> list[int]: ... - def swap_mem() -> tuple[int, int, int, int, int]: ... - def heap_info() -> tuple[int, int]: ... # only FreeBSD and NetBSD - def heap_trim() -> None: ... # only FreeBSD and NetBSD - def users() -> list[tuple[str, str, str, float, int | None]]: ... # returns None only in OpenBSD - def virtual_mem() -> tuple[int, ...]: ... # tuple's length depends on OS - - @overload - def cpu_freq() -> int: ... # only OpenBSD - @overload - def cpu_freq(core: int, /) -> tuple[int, str]: ... # only FreeBSD - - def cpu_topology() -> str | None: ... # only FreeBSD - def sensors_battery() -> tuple[int, int, int]: ... # only FreeBSD - def sensors_cpu_temperature(core: int, /) -> tuple[int, int]: ... # only FreeBSD - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_linux.pyi b/stubs/psutil/psutil/_psutil_linux.pyi deleted file mode 100644 index d24279961311..000000000000 --- a/stubs/psutil/psutil/_psutil_linux.pyi +++ /dev/null @@ -1,49 +0,0 @@ -import sys - -if sys.platform == "linux": - from collections.abc import Sequence - from typing import Final - - RLIMIT_AS: Final[int] - RLIMIT_CORE: Final[int] - RLIMIT_CPU: Final[int] - RLIMIT_DATA: Final[int] - RLIMIT_FSIZE: Final[int] - RLIMIT_MEMLOCK: Final[int] - RLIMIT_NOFILE: Final[int] - RLIMIT_NPROC: Final[int] - RLIMIT_RSS: Final[int] - RLIMIT_STACK: Final[int] - RLIMIT_LOCKS: Final[int] - RLIMIT_MSGQUEUE: Final[int] - RLIMIT_NICE: Final[int] - RLIMIT_RTPRIO: Final[int] - RLIMIT_RTTIME: Final[int] - RLIMIT_SIGPENDING: Final[int] - RLIM_INFINITY: Final[int] - - def getpagesize() -> int: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... - def net_if_flags(nic_name: str, /) -> list[str]: ... - def net_if_is_running(nic_name: str, /) -> bool: ... - def net_if_mtu(nic_name: str, /) -> int: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - def users() -> list[tuple[str, str, str, float, int]]: ... - - version: Final[int] - DUPLEX_FULL: Final[int] - DUPLEX_HALF: Final[int] - DUPLEX_UNKNOWN: Final[int] - - def proc_ioprio_get(pid: int, /) -> tuple[int, int]: ... - def proc_ioprio_set(pid: int, ioclass: int, iodata: int, /) -> None: ... - def proc_cpu_affinity_get(pid: int, /) -> list[int]: ... - def proc_cpu_affinity_set(pid: int, cpu_set: Sequence[int], /) -> None: ... - def disk_partitions(mtab_path: str, /) -> list[tuple[str, str, str, str]]: ... - def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements - def heap_info() -> tuple[int, int]: ... - def heap_trim() -> bool: ... - def linux_sysinfo() -> tuple[int, int, int, int, int, int, int]: ... - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_osx.pyi b/stubs/psutil/psutil/_psutil_osx.pyi deleted file mode 100644 index 2ea2baca3d05..000000000000 --- a/stubs/psutil/psutil/_psutil_osx.pyi +++ /dev/null @@ -1,79 +0,0 @@ -import sys - -if sys.platform == "darwin": - from _typeshed import StrOrBytesPath - from collections.abc import Sequence - from socket import AddressFamily, SocketKind - from typing import Final, TypeVar - - _T = TypeVar("_T") - - AF_LINK: Final = 18 - - def getpagesize() -> int: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... - def net_if_flags(nic_name: str, /) -> list[str]: ... - def net_if_is_running(nic_name: str, /) -> bool: ... - def net_if_mtu(nic_name: str, /) -> int: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - def net_if_duplex_speed(nic_name: str, /) -> tuple[int, int]: ... # It's actually list of 2 elements - def users() -> list[tuple[str, str, str, float, int]]: ... - def proc_is_zombie(pid: int, /) -> bool: ... - - version: Final[int] - SIDL: Final = 1 - SRUN: Final = 2 - SSLEEP: Final = 3 - SSTOP: Final = 4 - SZOMB: Final = 5 - TCPS_CLOSED: Final = 0 - TCPS_CLOSING: Final = 7 - TCPS_CLOSE_WAIT: Final = 5 - TCPS_LISTEN: Final = 1 - TCPS_ESTABLISHED: Final = 4 - TCPS_SYN_SENT: Final = 2 - TCPS_SYN_RECEIVED: Final = 3 - TCPS_FIN_WAIT_1: Final = 6 - TCPS_FIN_WAIT_2: Final = 9 - TCPS_LAST_ACK: Final = 8 - TCPS_TIME_WAIT: Final = 10 - PSUTIL_CONN_NONE: Final = 128 - - def proc_cmdline(pid: int, /) -> list[str]: ... - def proc_cwd(pid: int, /) -> str: ... - def proc_environ(pid: int, /) -> str: ... - def proc_exe(pid: int, /) -> str: ... - def proc_kinfo_oneshot(pid: int, /) -> tuple[int, int, int, int, int, int, int, float, int, str]: ... - def proc_memory_uss(pid: int, /) -> int: ... - def proc_name(pid: int, /) -> str: ... - def proc_net_connections( - pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / - ) -> list[ - tuple[int, int, int, tuple[str | None, int], tuple[str | None, int] | tuple[()], int] - | tuple[int, int, int, str, str, int] - ]: ... - def proc_num_fds(pid: int, /) -> int: ... - def proc_open_files(pid: int, /) -> list[tuple[str, int]]: ... - def proc_pidtaskinfo_oneshot(pid: int, /) -> tuple[float, float, int, int, int, int, int, int]: ... - def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... - def boot_time() -> float: ... - def cpu_count_cores() -> int | None: ... - def cpu_count_logical() -> int | None: ... - def cpu_freq() -> tuple[int, int, int]: ... - def cpu_stats() -> tuple[int, int, int, int, int]: ... - def cpu_times() -> tuple[float, float, float, float]: ... - def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... - def disk_partitions() -> list[tuple[str, str, str, str]]: ... - def disk_usage_used(mount_point: StrOrBytesPath, default: _T, /) -> int | _T: ... - def has_cpu_freq() -> bool: ... - def heap_info() -> tuple[int, int]: ... - def heap_trim() -> None: ... - def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... - def per_cpu_times() -> list[tuple[float, float, float, float]]: ... - def pids() -> list[int]: ... - def sensors_battery() -> tuple[int, int, int]: ... - def swap_mem() -> tuple[int, int, int, int, int]: ... - def virtual_mem() -> tuple[int, int, int, int, int, int]: ... - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_sunos.pyi b/stubs/psutil/psutil/_psutil_sunos.pyi deleted file mode 100644 index fe56efa827ba..000000000000 --- a/stubs/psutil/psutil/_psutil_sunos.pyi +++ /dev/null @@ -1,63 +0,0 @@ -import sys - -# sys.platform.startswith(("sunos", "solaris")): -if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": - from typing import Final - - AF_LINK: Final[int] - - def getpagesize() -> int: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, str | None, str | None]]: ... - def net_if_flags(nic_name: str, /) -> list[str]: ... - def net_if_is_running(nic_name: str, /) -> bool: ... - def net_if_mtu(nic_name: str, /) -> int: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - def users() -> list[tuple[str, str, str, float, int]]: ... - - version: Final[int] - # They could be different between different versions of SunOS/Solaris: - SSLEEP: Final[int] - SRUN: Final[int] - SZOMB: Final[int] - SSTOP: Final[int] - SIDL: Final[int] - SONPROC: Final[int] - SWAIT: Final[int] - PRNODEV: Final[int] - TCPS_CLOSED: Final[int] - TCPS_CLOSING: Final[int] - TCPS_CLOSE_WAIT: Final[int] - TCPS_LISTEN: Final[int] - TCPS_ESTABLISHED: Final[int] - TCPS_SYN_SENT: Final[int] - TCPS_SYN_RCVD: Final[int] - TCPS_FIN_WAIT_1: Final[int] - TCPS_FIN_WAIT_2: Final[int] - TCPS_LAST_ACK: Final[int] - TCPS_TIME_WAIT: Final[int] - TCPS_IDLE: Final[int] - TCPS_BOUND: Final[int] - PSUTIL_CONN_NONE: Final = 128 - - def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[int, int, int, float, int, int, int, int, int, int, int, int]: ... - def proc_cpu_num(pid: int, procfs_path: str, /) -> int: ... - def proc_cpu_times(pid: int, procfs_path: str, /) -> tuple[float, float, float, float]: ... - def proc_cred(pid: int, procfs_path: str, /) -> tuple[int, int, int, int, int, int]: ... - def proc_environ(pid: int, procfs_path: str, /) -> dict[str, str]: ... - def proc_memory_maps(pid: int, procfs_path: str, /) -> list[tuple[int, int, str, str, int, int, int]]: ... - def proc_name_and_args(pid: int, procfs_path: str, /) -> tuple[str, list[str] | None]: ... - def proc_num_ctx_switches(pid: int, procfs_path: str, /) -> tuple[int, int]: ... - def query_process_thread(pid: int, tid: int, procfs_path: str, /) -> tuple[float, float]: ... - def boot_time() -> float: ... - def cpu_count_cores() -> int | None: ... - def cpu_stats() -> tuple[int, int, int, int]: ... - def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... - def disk_partitions() -> list[tuple[str, str, str, str]]: ... - def net_connections(pid: int, /) -> list[tuple[int, int, int, tuple[str, int], tuple[str, int] | tuple[()], int, int]]: ... - def net_if_stats() -> dict[str, tuple[bool, int, int, int]]: ... - def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... - def per_cpu_times() -> list[tuple[float, float, float, float]]: ... - def swap_mem() -> tuple[int, int]: ... - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_psutil_windows.pyi b/stubs/psutil/psutil/_psutil_windows.pyi deleted file mode 100644 index f48ed77998b2..000000000000 --- a/stubs/psutil/psutil/_psutil_windows.pyi +++ /dev/null @@ -1,105 +0,0 @@ -import sys - -if sys.platform == "win32": - from collections.abc import Sequence - from socket import AddressFamily, SocketKind - from typing import Final - - version: Final[int] - ABOVE_NORMAL_PRIORITY_CLASS: Final = 32768 - BELOW_NORMAL_PRIORITY_CLASS: Final = 16384 - HIGH_PRIORITY_CLASS: Final = 128 - IDLE_PRIORITY_CLASS: Final = 64 - NORMAL_PRIORITY_CLASS: Final = 32 - REALTIME_PRIORITY_CLASS: Final = 256 - MIB_TCP_STATE_CLOSED: Final = 1 - MIB_TCP_STATE_CLOSING: Final = 9 - MIB_TCP_STATE_CLOSE_WAIT: Final = 8 - MIB_TCP_STATE_LISTEN: Final = 2 - MIB_TCP_STATE_ESTAB: Final = 5 - MIB_TCP_STATE_SYN_SENT: Final = 3 - MIB_TCP_STATE_SYN_RCVD: Final = 4 - MIB_TCP_STATE_FIN_WAIT1: Final = 6 - MIB_TCP_STATE_FIN_WAIT2: Final = 7 - MIB_TCP_STATE_LAST_ACK: Final = 10 - MIB_TCP_STATE_TIME_WAIT: Final = 11 - MIB_TCP_STATE_DELETE_TCB: Final = 12 - PSUTIL_CONN_NONE: Final = 128 - INFINITE: Final[int] - ERROR_ACCESS_DENIED: Final = 5 - ERROR_INVALID_NAME: Final = 123 - ERROR_SERVICE_DOES_NOT_EXIST: Final = 1060 - ERROR_PRIVILEGE_NOT_HELD: Final = 1314 - WINVER: Final[int] - WINDOWS_VISTA: Final = 60 - WINDOWS_7: Final = 61 - WINDOWS_8: Final = 62 - WINDOWS_8_1: Final = 63 - WINDOWS_10: Final = 100 - - class TimeoutAbandoned(Exception): ... - class TimeoutExpired(Exception): ... - - def proc_cmdline(pid: int, use_peb: bool = True) -> list[str]: ... - def proc_cpu_affinity_get(pid: int, /) -> int: ... - def proc_cpu_affinity_set(pid: int, mask: int, /) -> None: ... - def proc_cwd(pid: int, /) -> str: ... - def proc_environ(pid: int, /) -> str: ... - def proc_exe(pid: int, /) -> str: ... - def proc_io_counters(pid: int, /) -> tuple[int, int, int, int, int, int]: ... - def proc_io_priority_get(pid: int, /) -> int: ... - def proc_io_priority_set(pid: int, priority: int, /) -> None: ... - def proc_is_suspended(pid: int, /) -> bool: ... - def proc_kill(pid: int, /) -> None: ... - def proc_memory_info(pid: int, /) -> tuple[int, int, int, int, int, int, int, int, int, int]: ... - def proc_memory_maps(pid: int, /) -> list[tuple[int, str, str, int]]: ... - def proc_memory_uss(pid: int, /) -> int: ... - def proc_num_handles(pid: int, /) -> int: ... - def proc_open_files(pid: int, /) -> list[str]: ... - def proc_priority_get(pid: int, /) -> int: ... - def proc_priority_set(pid: int, priority: int, /) -> None: ... - def proc_suspend_or_resume(pid: int, suspend: bool | None, /) -> None: ... - def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... - def proc_times(pid: int, /) -> tuple[float, float, float]: ... - def proc_username(pid: int, /) -> tuple[str, str]: ... - def proc_wait(pid: int, timeout: int, /) -> int | None: ... - def proc_info( - pid: int, / - ) -> tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int]: ... - def uptime() -> float: ... - def cpu_count_cores() -> int | None: ... - def cpu_count_logical() -> int | None: ... - def cpu_freq() -> tuple[int, int]: ... - def cpu_stats() -> tuple[int, int, int, int]: ... - def cpu_times() -> tuple[float, float, float]: ... - def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... - def disk_partitions(all: bool, /) -> list[tuple[str, str, str, str]]: ... - def disk_usage(path: str, /) -> tuple[int, int, int]: ... - def getloadavg() -> tuple[float, float, float]: ... - def getpagesize() -> int: ... - def swap_percent() -> float: ... - def init_loadavg_counter() -> None: ... - def heap_info() -> tuple[int, int, int]: ... - def heap_trim() -> int: ... - def net_connections( - pid: int, af_filter: Sequence[AddressFamily | int | None], type_filter: Sequence[SocketKind | int | None], / - ) -> list[tuple[int, int, int, tuple[str | None, int], tuple[str | None, int], int, int]]: ... - def net_if_addrs() -> list[tuple[str, int, str, str | None, None, None]]: ... - def net_if_stats() -> dict[str, tuple[bool, int, int, int]]: ... - def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... - def per_cpu_times() -> list[tuple[float, float, float, float, float]]: ... - def pid_exists(pid: int, /) -> bool: ... - def pids() -> list[int]: ... - def ppid_map() -> dict[int, int]: ... - def sensors_battery() -> tuple[int, int, int, int]: ... - def users() -> list[tuple[str, str | None, float]]: ... - def virtual_mem() -> tuple[int, int, int, int]: ... - def winservice_enumerate() -> list[tuple[str, str]]: ... - def winservice_query_config(service_name: str, /) -> tuple[str, str, str, str]: ... - def winservice_query_descr(service_name: str, /) -> str: ... - def winservice_query_status(service_name: str, /) -> tuple[str, int] | str: ... - def winservice_start(service_name: str, /) -> None: ... - def winservice_stop(service_name: str, /) -> None: ... - def QueryDosDevice(device_path: str, /) -> str: ... - def check_pid_range(pid: int, /) -> None: ... - def set_debug(value: bool, /) -> None: ... diff --git a/stubs/psutil/psutil/_pswindows.pyi b/stubs/psutil/psutil/_pswindows.pyi index 8d9d89e1d783..fb87fbacb0d1 100644 --- a/stubs/psutil/psutil/_pswindows.pyi +++ b/stubs/psutil/psutil/_pswindows.pyi @@ -6,7 +6,7 @@ if sys.platform == "win32": from signal import Signals from typing import Final, Literal, ParamSpec, TypedDict, TypeVar, overload, type_check_only - from psutil import _psutil_windows + from psutil import _psutil from psutil._common import ( ENCODING as ENCODING, AccessDenied as AccessDenied, @@ -16,12 +16,11 @@ if sys.platform == "win32": conn_to_ntuple as conn_to_ntuple, debug as debug, isfile_strict as isfile_strict, - memoize as memoize, memoize_when_activated as memoize_when_activated, parse_environ_block as parse_environ_block, usage_percent as usage_percent, ) - from psutil._psutil_windows import ( + from psutil._psutil import ( ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS, @@ -45,12 +44,12 @@ if sys.platform == "win32": # These noqas workaround https://github.com/astral-sh/ruff/issues/10874 class Priority(enum.IntEnum): - ABOVE_NORMAL_PRIORITY_CLASS = _psutil_windows.ABOVE_NORMAL_PRIORITY_CLASS - BELOW_NORMAL_PRIORITY_CLASS = _psutil_windows.BELOW_NORMAL_PRIORITY_CLASS - HIGH_PRIORITY_CLASS = _psutil_windows.HIGH_PRIORITY_CLASS - IDLE_PRIORITY_CLASS = _psutil_windows.IDLE_PRIORITY_CLASS - NORMAL_PRIORITY_CLASS = _psutil_windows.NORMAL_PRIORITY_CLASS - REALTIME_PRIORITY_CLASS = _psutil_windows.REALTIME_PRIORITY_CLASS + ABOVE_NORMAL_PRIORITY_CLASS = _psutil.ABOVE_NORMAL_PRIORITY_CLASS + BELOW_NORMAL_PRIORITY_CLASS = _psutil.BELOW_NORMAL_PRIORITY_CLASS + HIGH_PRIORITY_CLASS = _psutil.HIGH_PRIORITY_CLASS + IDLE_PRIORITY_CLASS = _psutil.IDLE_PRIORITY_CLASS + NORMAL_PRIORITY_CLASS = _psutil.NORMAL_PRIORITY_CLASS + REALTIME_PRIORITY_CLASS = _psutil.REALTIME_PRIORITY_CLASS class IOPriority(enum.IntEnum): IOPRIO_VERYLOW = 0 @@ -70,12 +69,12 @@ if sys.platform == "win32": def convert_dos_path(s: str) -> str: ... def getpagesize() -> int: ... - def virtual_memory() -> ntp.svmem: ... - def swap_memory() -> ntp.sswap: ... + def memory_physical() -> ntp.smem: ... + def memory_swap() -> ntp.sswap: ... - heap_info = _psutil_windows.heap_info - heap_trim = _psutil_windows.heap_trim - disk_io_counters = _psutil_windows.disk_io_counters + heap_info = _psutil.heap_info + heap_trim = _psutil.heap_trim + disk_io_counters = _psutil.disk_io_counters def disk_usage(path: str) -> ntp.sdiskusage: ... def disk_partitions(all: bool) -> list[ntp.sdiskpart]: ... @@ -126,9 +125,9 @@ if sys.platform == "win32": def description(self) -> str: ... def as_dict(self) -> _WindowsServiceAttrs: ... - pids = _psutil_windows.pids - pid_exists = _psutil_windows.pid_exists - ppid_map = _psutil_windows.ppid_map + pids = _psutil.pids + pid_exists = _psutil.pid_exists + ppid_map = _psutil.ppid_map def is_permission_err(exc: OSError) -> bool: ... @@ -152,7 +151,8 @@ if sys.platform == "win32": def environ(self) -> dict[str, str]: ... def ppid(self) -> int: ... def memory_info(self) -> ntp.pmem: ... - def memory_full_info(self) -> ntp.pfullmem: ... + def memory_extras(self) -> ntp.pmem_extras: ... + def memory_footprint(self) -> ntp.pfootprint: ... def memory_maps(self) -> Iterator[tuple[str, str, str, int]]: ... def kill(self) -> None: ... def send_signal(self, sig: Literal[Signals.SIGTERM, Signals.CTRL_C_EVENT, Signals.CTRL_BREAK_EVENT]) -> None: ... @@ -176,4 +176,5 @@ if sys.platform == "win32": def cpu_affinity_get(self) -> list[int]: ... def cpu_affinity_set(self, value: Iterable[int]) -> None: ... def num_handles(self) -> int: ... - def num_ctx_switches(self) -> ntp.pctxsw: ... + def ctx_switches(self) -> ntp.pctxsw: ... + def page_faults(self) -> ntp.ppagefaults: ...