diff --git a/stubs/psutil/psutil/_pssunos.pyi b/stubs/psutil/psutil/_pssunos.pyi index 3080720cca60..2676147f64bb 100644 --- a/stubs/psutil/psutil/_pssunos.pyi +++ b/stubs/psutil/psutil/_pssunos.pyi @@ -1,129 +1,151 @@ -from _typeshed import Incomplete -from typing import NamedTuple - -from psutil._common import ( - AF_INET6 as AF_INET6, - AccessDenied as AccessDenied, - 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, - socktype_to_enum as socktype_to_enum, - usage_percent as usage_percent, -) - -__extra__all__: Incomplete -PAGE_SIZE: Incomplete -AF_LINK: Incomplete -IS_64_BIT: Incomplete -CONN_IDLE: str -CONN_BOUND: str -PROC_STATUSES: Incomplete -TCP_STATUSES: Incomplete -proc_info_map: Incomplete - -class scputimes(NamedTuple): - user: Incomplete - system: Incomplete - idle: Incomplete - iowait: Incomplete - -class pcputimes(NamedTuple): - user: Incomplete - system: Incomplete - children_user: Incomplete - children_system: Incomplete - -class svmem(NamedTuple): - total: Incomplete - available: Incomplete - percent: Incomplete - used: Incomplete - free: Incomplete - -class pmem(NamedTuple): - rss: Incomplete - vms: Incomplete - -pfullmem = pmem - -class pmmap_grouped(NamedTuple): - path: Incomplete - rss: Incomplete - anonymous: Incomplete - locked: Incomplete - -pmmap_ext: Incomplete - -def virtual_memory(): ... -def swap_memory(): ... -def cpu_times(): ... -def per_cpu_times(): ... -def cpu_count_logical(): ... -def cpu_count_cores(): ... -def cpu_stats(): ... - -disk_io_counters: Incomplete -disk_usage: Incomplete - -def disk_partitions(all: bool = ...): ... - -net_io_counters: Incomplete -net_if_addrs: Incomplete - -def net_connections(kind, _pid: int = ...): ... -def net_if_stats(): ... -def boot_time(): ... -def users(): ... -def pids(): ... -def pid_exists(pid): ... -def wrap_exceptions(fun): ... - -class Process: - 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 create_time(self): ... - def num_threads(self): ... - def nice_get(self): ... - def nice_set(self, value): ... - def ppid(self): ... - def uids(self): ... - def gids(self): ... - def cpu_times(self): ... - def cpu_num(self): ... - def terminal(self): ... - def cwd(self): ... - def memory_info(self): ... - memory_full_info: Incomplete - def status(self): ... - def threads(self): ... - def open_files(self): ... - def net_connections(self, kind: str = ...): ... - - class nt_mmap_grouped(NamedTuple): +import sys + +# sys.platform.startswith(("sunos", "solaris")): +if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + from _typeshed import Incomplete + from collections.abc import Callable + from typing import Final, Literal, NamedTuple, TypeVar, overload + from typing_extensions import ParamSpec + + from psutil._common import ( + AF_INET6 as AF_INET6, + ENCODING as ENCODING, + AccessDenied as AccessDenied, + 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, + socktype_to_enum as socktype_to_enum, + usage_percent as usage_percent, + ) + + from . import _common, _psposix, _psutil_sunos + + _P = ParamSpec("_P") + _R = TypeVar("_R") + + __extra__all__: Final[list[str]] + PAGE_SIZE: Final[int] + AF_LINK: Final[int] + IS_64_BIT: Final[bool] + CONN_IDLE: Final = "IDLE" + CONN_BOUND: Final = "BOUND" + PROC_STATUSES: Final[dict[int, str]] + TCP_STATUSES: Final[dict[int, str]] + proc_info_map: Final[dict[str, int]] + + class scputimes(NamedTuple): + user: float + system: float + idle: float + iowait: float + + class pcputimes(NamedTuple): + user: float + system: float + children_user: float + children_system: float + + class svmem(NamedTuple): + total: int + available: int + percent: float + used: int + free: int + + class pmem(NamedTuple): + rss: int + vms: int + + pfullmem = pmem + + class pmmap_grouped(NamedTuple): path: Incomplete rss: Incomplete - anon: Incomplete + anonymous: Incomplete locked: Incomplete - class nt_mmap_ext(NamedTuple): + class pmmap_ext(NamedTuple): addr: Incomplete perms: Incomplete path: Incomplete rss: Incomplete - anon: Incomplete + anonymous: Incomplete locked: Incomplete - def memory_maps(self): ... - def num_fds(self): ... - def num_ctx_switches(self): ... - def wait(self, timeout: Incomplete | None = ...): ... + 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: ... + + disk_io_counters = _psutil_sunos.disk_io_counters + disk_usage = _psposix.disk_usage + + def disk_partitions(all: bool = False) -> list[_common.sdiskpart]: ... + + net_io_counters = _psutil_sunos.net_io_counters + net_if_addrs = _psutil_sunos.net_if_addrs + + @overload + def net_connections(kind: str, _pid: Literal[-1] = -1) -> list[_common.sconn]: ... + @overload + def net_connections(kind: str, _pid: int = -1) -> list[_common.pconn]: ... + def net_if_stats() -> dict[str, _common.snicstats]: ... + def boot_time() -> float: ... + def users() -> list[_common.suser]: ... + def pids() -> list[int]: ... + def pid_exists(pid: int) -> bool: ... + def wrap_exceptions(fun: Callable[_P, _R]) -> Callable[_P, _R]: ... + + class Process: + __slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "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] | None: ... + def environ(self) -> dict[str, str]: ... + def create_time(self) -> float: ... + def num_threads(self) -> int: ... + def nice_get(self) -> int: ... + def nice_set(self, value: int) -> None: ... + def ppid(self) -> int: ... + def uids(self) -> _common.puids: ... + def gids(self) -> _common.puids: ... + def cpu_times(self) -> _common.pcputimes: ... + def cpu_num(self) -> int: ... + def terminal(self) -> str | None: ... + def cwd(self) -> str: ... + def memory_info(self) -> pmem: ... + memory_full_info = memory_info + def status(self) -> str: ... + def threads(self) -> list[_common.pthread]: ... + def open_files(self) -> list[_common.popenfile]: ... + def net_connections(self, kind: str = "inet") -> list[_common.pconn]: ... + + class nt_mmap_grouped(NamedTuple): + path: Incomplete + rss: Incomplete + anon: Incomplete + locked: Incomplete + + class nt_mmap_ext(NamedTuple): + addr: Incomplete + perms: Incomplete + path: Incomplete + rss: Incomplete + anon: Incomplete + locked: Incomplete + + def memory_maps(self) -> list[tuple[str, str, str, int, int, int]]: ... + def num_fds(self) -> int: ... + def num_ctx_switches(self) -> _common.pctxsw: ... + def wait(self, timeout: float | None = None): ... diff --git a/stubs/psutil/psutil/_psutil_osx.pyi b/stubs/psutil/psutil/_psutil_osx.pyi index 712d0fa93401..e6bef26354da 100644 --- a/stubs/psutil/psutil/_psutil_osx.pyi +++ b/stubs/psutil/psutil/_psutil_osx.pyi @@ -8,8 +8,7 @@ if sys.platform == "darwin": _T = TypeVar("_T") - # TODO: Add POSIX constants and check their aviability (see psutil_posix_add_constants) - AF_LINK: Incomplete + AF_LINK: Final = 18 def getpagesize() -> int: ... def net_if_addrs(): ... diff --git a/stubs/psutil/psutil/_psutil_sunos.pyi b/stubs/psutil/psutil/_psutil_sunos.pyi index 9539ebed9f37..b98853632d27 100644 --- a/stubs/psutil/psutil/_psutil_sunos.pyi +++ b/stubs/psutil/psutil/_psutil_sunos.pyi @@ -1,59 +1,64 @@ -from _typeshed import Incomplete +import sys -# TODO: Add POSIX constants and check their aviability (see psutil_posix_add_constants) -AF_LINK: Incomplete +# sys.platform.startswith(("sunos", "solaris")): +if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + from _typeshed import Incomplete + from typing import Final -def getpagesize() -> int: ... -def net_if_addrs(): ... -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[Incomplete, ...]]: ... + AF_LINK: Final[int] -version: Incomplete -SSLEEP: Incomplete -SRUN: Incomplete -SZOMB: Incomplete -SSTOP: Incomplete -SIDL: Incomplete -SONPROC: Incomplete -SWAIT: Incomplete -PRNODEV: Incomplete -TCPS_CLOSED: Incomplete -TCPS_CLOSING: Incomplete -TCPS_CLOSE_WAIT: Incomplete -TCPS_LISTEN: Incomplete -TCPS_ESTABLISHED: Incomplete -TCPS_SYN_SENT: Incomplete -TCPS_SYN_RCVD: Incomplete -TCPS_FIN_WAIT_1: Incomplete -TCPS_FIN_WAIT_2: Incomplete -TCPS_LAST_ACK: Incomplete -TCPS_TIME_WAIT: Incomplete -TCPS_IDLE: Incomplete -TCPS_BOUND: Incomplete -PSUTIL_CONN_NONE: Incomplete + def getpagesize() -> int: ... + def net_if_addrs(): ... + 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[Incomplete, ...]]: ... -def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[Incomplete, ...]: ... -def proc_cpu_num(pid: int, procfs_path: str, /): ... -def proc_cpu_times(pid: int, procfs_path: str, /): ... -def proc_cred(pid: int, procfs_path: str, /): ... -def proc_environ(pid: int, procfs_path: str, /): ... -def proc_memory_maps(pid: int, procfs_path: str, /): ... -def proc_name_and_args(pid: int, procfs_path: str, /): ... -def proc_num_ctx_switches(pid: int, procfs_path: str, /): ... -def query_process_thread(pid: int, tid: int, procfs_path: str, /): ... -def boot_time(): ... -def cpu_count_cores(): ... -def cpu_stats(): ... -def disk_io_counters(): ... -def disk_partitions(): ... -def net_connections(pid: int, /): ... -def net_if_stats(): ... -def net_io_counters(): ... -def per_cpu_times(): ... -def swap_mem(): ... -def check_pid_range(pid: int, /): ... -def set_debug(value: bool, /) -> None: ... + 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: ...