diff --git a/stubs/psutil/psutil/_psosx.pyi b/stubs/psutil/psutil/_psosx.pyi index af30947aaa79..59793069531b 100644 --- a/stubs/psutil/psutil/_psosx.pyi +++ b/stubs/psutil/psutil/_psosx.pyi @@ -1,109 +1,119 @@ -from _typeshed import Incomplete -from typing import NamedTuple - -from psutil._common import ( - AccessDenied as AccessDenied, - NoSuchProcess as NoSuchProcess, - ZombieProcess as ZombieProcess, - conn_tmap as conn_tmap, - conn_to_ntuple as conn_to_ntuple, - isfile_strict as isfile_strict, - parse_environ_block as parse_environ_block, - usage_percent as usage_percent, -) - -__extra__all__: Incomplete -PAGESIZE: Incomplete -AF_LINK: Incomplete -TCP_STATUSES: Incomplete -PROC_STATUSES: Incomplete -kinfo_proc_map: Incomplete -pidtaskinfo_map: Incomplete - -class scputimes(NamedTuple): - user: float - nice: float - system: float - idle: float - -class svmem(NamedTuple): - total: int - available: int - percent: float - used: int - free: int - active: int - inactive: int - wired: int - -class pmem(NamedTuple): - rss: Incomplete - vms: Incomplete - pfaults: Incomplete - pageins: Incomplete - -class pfullmem(NamedTuple): - rss: Incomplete - vms: Incomplete - pfaults: Incomplete - pageins: Incomplete - uss: Incomplete - -def virtual_memory() -> svmem: ... -def swap_memory(): ... -def cpu_times(): ... -def per_cpu_times(): ... -def cpu_count_logical(): ... -def cpu_count_cores() -> int | None: ... -def cpu_stats(): ... -def cpu_freq(): ... - -disk_usage: Incomplete -disk_io_counters: Incomplete - -def disk_partitions(all: bool = False): ... -def sensors_battery(): ... - -net_io_counters: Incomplete -net_if_addrs: Incomplete - -def net_connections(kind: str = "inet"): ... -def net_if_stats(): ... -def boot_time(): ... -def users(): ... -def pids(): ... - -pid_exists: Incomplete - -def is_zombie(pid): ... -def wrap_exceptions(fun): ... - -class Process: - __slots__ = ["_cache", "_name", "_ppid", "pid"] - pid: Incomplete - def __init__(self, pid) -> None: ... - def oneshot_enter(self) -> None: ... - def oneshot_exit(self) -> None: ... - def name(self): ... - def exe(self): ... - def cmdline(self): ... - def environ(self): ... - def ppid(self): ... - def cwd(self): ... - def uids(self): ... - def gids(self): ... - def terminal(self): ... - def memory_info(self): ... - def memory_full_info(self): ... - def cpu_times(self): ... - def create_time(self): ... - def num_ctx_switches(self): ... - def num_threads(self): ... - def open_files(self): ... - def net_connections(self, kind: str = "inet"): ... - def num_fds(self): ... - def wait(self, timeout=None): ... - def nice_get(self): ... - def nice_set(self, value): ... - def status(self): ... - def threads(self): ... +import sys + +if sys.platform == "darwin": + from collections.abc import Callable + from typing import Final, NamedTuple, TypeVar + from typing_extensions import ParamSpec + + from psutil._common import ( + AccessDenied as AccessDenied, + NoSuchProcess as NoSuchProcess, + ZombieProcess as ZombieProcess, + conn_tmap as conn_tmap, + conn_to_ntuple as conn_to_ntuple, + isfile_strict as isfile_strict, + memoize_when_activated as memoize_when_activated, + parse_environ_block as parse_environ_block, + usage_percent as usage_percent, + ) + + from . import _common, _psposix, _psutil_osx, _psutil_posix + + _P = ParamSpec("_P") + _R = TypeVar("_R") + + __extra__all__: Final[list[str]] + PAGESIZE: Final[int] + 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]] + + class scputimes(NamedTuple): + user: float + nice: float + system: float + idle: float + + class svmem(NamedTuple): + total: int + available: int + percent: float + used: int + free: int + active: int + inactive: int + wired: int + + class pmem(NamedTuple): + rss: int + vms: int + pfaults: int + pageins: int + + class pfullmem(NamedTuple): + rss: int + vms: int + pfaults: int + pageins: int + uss: int + + def virtual_memory() -> svmem: ... + def swap_memory() -> _common.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() -> _common.scpustats: ... + def cpu_freq() -> list[_common.scpufreq]: ... + + disk_usage = _psposix.disk_usage + disk_io_counters = _psutil_osx.disk_io_counters + + def disk_partitions(all: bool = False) -> list[_common.sdiskpart]: ... + def sensors_battery() -> _common.sbattery | None: ... + + net_io_counters = _psutil_osx.net_io_counters + net_if_addrs = _psutil_posix.net_if_addrs + + def net_connections(kind: str = "inet") -> list[_common.sconn]: ... + def net_if_stats() -> dict[str, _common.snicstats]: ... + def boot_time() -> float: ... + def users() -> list[_common.suser]: ... + def pids() -> list[int]: ... + + pid_exists = _psposix.pid_exists + + def is_zombie(pid: int) -> bool: ... + def wrap_exceptions(fun: Callable[_P, _R]) -> Callable[_P, _R]: ... + + class Process: + __slots__ = ["_cache", "_name", "_ppid", "pid"] + pid: int + def __init__(self, pid: int) -> None: ... + def oneshot_enter(self) -> None: ... + def oneshot_exit(self) -> None: ... + def name(self) -> str: ... + def exe(self) -> str: ... + def cmdline(self) -> list[str]: ... + def environ(self) -> dict[str, str]: ... + def ppid(self) -> int: ... + def cwd(self) -> str: ... + def uids(self) -> _common.puids: ... + def gids(self) -> _common.puids: ... + def terminal(self) -> str | None: ... + def memory_info(self) -> pmem: ... + def memory_full_info(self) -> pfullmem: ... + def cpu_times(self) -> _common.pcputimes: ... + def create_time(self) -> float: ... + def num_ctx_switches(self) -> _common.pctxsw: ... + def num_threads(self) -> int: ... + def open_files(self) -> list[_common.popenfile]: ... + def net_connections(self, kind: str = "inet"): ... + def num_fds(self) -> int: ... + def wait(self, timeout: float | None = None): ... + def nice_get(self): ... + def nice_set(self, value): ... + def status(self) -> str: ... + def threads(self) -> list[_common.pthread]: ... diff --git a/stubs/psutil/psutil/_psutil_osx.pyi b/stubs/psutil/psutil/_psutil_osx.pyi index 2f2b1a397f70..b14656b97130 100644 --- a/stubs/psutil/psutil/_psutil_osx.pyi +++ b/stubs/psutil/psutil/_psutil_osx.pyi @@ -1,49 +1,64 @@ -PSUTIL_CONN_NONE: int -SIDL: int -SRUN: int -SSLEEP: int -SSTOP: int -SZOMB: int -TCPS_CLOSED: int -TCPS_CLOSE_WAIT: int -TCPS_CLOSING: int -TCPS_ESTABLISHED: int -TCPS_FIN_WAIT_1: int -TCPS_FIN_WAIT_2: int -TCPS_LAST_ACK: int -TCPS_LISTEN: int -TCPS_SYN_RECEIVED: int -TCPS_SYN_SENT: int -TCPS_TIME_WAIT: int -version: int +import sys -def boot_time(*args, **kwargs): ... -def check_pid_range(pid: int, /) -> None: ... -def cpu_count_cores(*args, **kwargs): ... -def cpu_count_logical(*args, **kwargs): ... -def cpu_freq(*args, **kwargs): ... -def cpu_stats(*args, **kwargs): ... -def cpu_times(*args, **kwargs): ... -def disk_io_counters(*args, **kwargs): ... -def disk_partitions(*args, **kwargs): ... -def disk_usage_used(*args, **kwargs): ... -def net_io_counters(*args, **kwargs): ... -def per_cpu_times(*args, **kwargs): ... -def pids(*args, **kwargs): ... -def proc_cmdline(*args, **kwargs): ... -def proc_net_connections(*args, **kwargs): ... -def proc_cwd(*args, **kwargs): ... -def proc_environ(*args, **kwargs): ... -def proc_exe(*args, **kwargs): ... -def proc_kinfo_oneshot(*args, **kwargs): ... -def proc_memory_uss(*args, **kwargs): ... -def proc_name(*args, **kwargs): ... -def proc_num_fds(*args, **kwargs): ... -def proc_open_files(*args, **kwargs): ... -def proc_pidtaskinfo_oneshot(*args, **kwargs): ... -def proc_threads(*args, **kwargs): ... -def sensors_battery(*args, **kwargs): ... -def set_debug(*args, **kwargs): ... -def swap_mem(*args, **kwargs): ... -def users(*args, **kwargs): ... -def virtual_mem(*args, **kwargs): ... +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") + + 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 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 users() -> list[tuple[str, str, str, float, 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/_pswindows.pyi b/stubs/psutil/psutil/_pswindows.pyi index 9c30a783a27e..fd23474b773c 100644 --- a/stubs/psutil/psutil/_pswindows.pyi +++ b/stubs/psutil/psutil/_pswindows.pyi @@ -33,7 +33,7 @@ if sys.platform == "win32": from . import _common - __extra__all__: list[str] + __extra__all__: Final[list[str]] CONN_DELETE_TCB: Final = "DELETE_TCB" ERROR_PARTIAL_COPY: Final = 299 PYPY: Final[bool]