Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/gevent/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = "25.9.*"
upstream_repository = "https://github.com/gevent/gevent"
requires = ["types-greenlet", "types-psutil"]
requires = ["types-greenlet", "types-psutil>=7.2.0"]

[tool.stubtest]
# Run stubtest on all platforms, since there is some platform specific stuff
Expand Down
13 changes: 1 addition & 12 deletions stubs/gevent/gevent/events.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys
from collections.abc import Callable, Mapping, Sequence
from types import ModuleType
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias

from gevent.hub import Hub
from greenlet import greenlet as greenlet_t
from psutil._ntuples import pmem

_T = TypeVar("_T")
# FIXME: While it would be nice to import Interface from zope.interface here so the
Expand All @@ -17,17 +17,6 @@ Interface: TypeAlias = Any

def implementer(interface: Interface, /) -> Callable[[_T], _T]: ...

# this is copied from types-psutil, it would be nice if we could just import this
# but it doesn't seem like we can...
if sys.platform == "linux":
from psutil._pslinux import pmem
elif sys.platform == "darwin":
from psutil._psosx import pmem
elif sys.platform == "win32":
from psutil._pswindows import pmem
else:
class pmem(Any): ...

subscribers: list[Callable[[Any], object]]

@type_check_only
Expand Down
3 changes: 0 additions & 3 deletions stubs/psutil/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ psutil._psutil_aix
psutil._psutil_bsd
psutil._psutil_sunos

# Test utilities
psutil.tests.*

# process_iter is enhanced with cache_clear method that's not detected by stubtest
psutil.process_iter
2 changes: 1 addition & 1 deletion stubs/psutil/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "7.1.3"
version = "7.2.0"
upstream_repository = "https://github.com/giampaolo/psutil"

[tool.stubtest]
Expand Down
118 changes: 46 additions & 72 deletions stubs/psutil/psutil/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,19 @@ from psutil._common import (
NoSuchProcess as NoSuchProcess,
TimeoutExpired as TimeoutExpired,
ZombieProcess as ZombieProcess,
pconn,
pcputimes,
pctxsw,
pgids,
pionice,
popenfile,
pthread,
puids,
sconn,
scpufreq,
scpustats,
sdiskio,
sdiskpart,
sdiskusage,
sfan,
shwtemp,
snetio,
snicaddr,
snicstats,
sswap,
suser,
)

from . import _ntuples as _ntp

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,
)
def sensors_temperatures(fahrenheit: bool = ...) -> dict[str, list[shwtemp]]: ...
def sensors_fans() -> dict[str, list[sfan]]: ...
def sensors_temperatures(fahrenheit: bool = False) -> dict[str, list[_ntp.shwtemp]]: ...
def sensors_fans() -> dict[str, list[_ntp.sfan]]: ...
PROCFS_PATH: str
RLIMIT_AS: int
RLIMIT_CORE: int
Expand Down Expand Up @@ -121,28 +102,19 @@ if sys.platform == "win32":
win_service_iter as win_service_iter,
)

# Linux + glibc, Windows, macOS, FreeBSD, NetBSD:
def heap_info() -> _ntp.pheap: ...
def heap_trim() -> None: ...

if sys.platform == "linux":
from ._pslinux import pfullmem, pmem, scputimes, sensors_battery as sensors_battery, svmem
from ._pslinux import sensors_battery as sensors_battery
elif sys.platform == "darwin":
from ._psosx import pfullmem, pmem, scputimes, sensors_battery as sensors_battery, svmem
from ._psosx import sensors_battery as sensors_battery
elif sys.platform == "win32":
from ._pswindows import pfullmem, pmem, scputimes, sensors_battery as sensors_battery, svmem
from ._pswindows import sensors_battery as sensors_battery
else:
scputimes = Incomplete

class pmem(Any): ...
class pfullmem(Any): ...
class svmem(Any): ...

def sensors_battery(): ...

if sys.platform == "linux":
from ._pslinux import pio
elif sys.platform == "win32":
from ._pswindows import pio
else:
from ._common import pio

AF_LINK: int
version_info: tuple[int, int, int]
__version__: str
Expand Down Expand Up @@ -191,45 +163,45 @@ class Process:
def cwd(self) -> str: ...
def nice(self, value: int | None = None) -> int: ...
if sys.platform != "win32":
def uids(self) -> puids: ...
def gids(self) -> pgids: ...
def uids(self) -> _ntp.puids: ...
def gids(self) -> _ntp.pgids: ...
def terminal(self) -> str: ...
def num_fds(self) -> int: ...
if sys.platform != "darwin":
def io_counters(self) -> pio: ...
def ionice(self, ioclass: int | None = None, value: int | None = None) -> pionice: ...
def io_counters(self) -> _ntp.pio: ...
def ionice(self, ioclass: int | None = None, value: int | None = None) -> _ntp.pionice: ...
@overload
def cpu_affinity(self, cpus: None = None) -> list[int]: ...
@overload
def cpu_affinity(self, cpus: list[int]) -> None: ...
def memory_maps(self, grouped: bool = True) -> list[Incomplete]: ...
if sys.platform == "linux":
def rlimit(self, resource: int, limits: tuple[int, int] | None = ...) -> tuple[int, int]: ...
def rlimit(self, resource: int, limits: tuple[int, int] | None = None) -> tuple[int, int]: ...
def cpu_num(self) -> int: ...

def environ(self) -> dict[str, str]: ...
if sys.platform == "win32":
def num_handles(self) -> int: ...

def num_ctx_switches(self) -> pctxsw: ...
def num_ctx_switches(self) -> _ntp.pctxsw: ...
def num_threads(self) -> int: ...
def threads(self) -> list[pthread]: ...
def threads(self) -> list[_ntp.pthread]: ...
def children(self, recursive: bool = False) -> list[Process]: ...
def cpu_percent(self, interval: float | None = None) -> float: ...
def cpu_times(self) -> pcputimes: ...
def memory_info(self) -> pmem: ...
def memory_full_info(self) -> pfullmem: ...
def cpu_times(self) -> _ntp.pcputimes: ...
def memory_info(self) -> _ntp.pmem: ...
def memory_full_info(self) -> _ntp.pfullmem: ...
def memory_percent(self, memtype: str = "rss") -> float: ...
def open_files(self) -> list[popenfile]: ...
def open_files(self) -> list[_ntp.popenfile]: ...
@deprecated('use "net_connections" method instead')
def connections(self, kind: str = "inet") -> list[pconn]: ...
def connections(self, kind: str = "inet") -> list[_ntp.pconn]: ...
def send_signal(self, sig: int) -> None: ...
def suspend(self) -> None: ...
def resume(self) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
def wait(self, timeout: float | None = None) -> int: ...
def net_connections(self, kind: str = "inet") -> list[pconn]: ...
def net_connections(self, kind: str = "inet") -> list[_ntp.pconn]: ...

class Popen(Process):
def __init__(self, *args, **kwargs) -> None: ...
Expand Down Expand Up @@ -257,41 +229,43 @@ def wait_procs(
) -> tuple[list[Process], list[Process]]: ...
def cpu_count(logical: bool = True) -> int | None: ...
@overload
def cpu_freq(percpu: Literal[False] = False) -> scpufreq: ...
def cpu_freq(percpu: Literal[False] = False) -> _ntp.scpufreq: ...
@overload
def cpu_freq(percpu: Literal[True]) -> list[scpufreq]: ...
def cpu_freq(percpu: Literal[True]) -> list[_ntp.scpufreq]: ...
@overload
def cpu_times(percpu: Literal[False] = False) -> scputimes: ...
def cpu_times(percpu: Literal[False] = False) -> _ntp.scputimes: ...
@overload
def cpu_times(percpu: Literal[True]) -> list[scputimes]: ...
def cpu_times(percpu: Literal[True]) -> list[_ntp.scputimes]: ...
@overload
def cpu_percent(interval: float | None = None, percpu: Literal[False] = False) -> float: ...
@overload
def cpu_percent(interval: float | None, percpu: Literal[True]) -> list[float]: ...
@overload
def cpu_percent(*, percpu: Literal[True]) -> list[float]: ...
@overload
def cpu_times_percent(interval: float | None = None, percpu: Literal[False] = False) -> scputimes: ...
def cpu_times_percent(interval: float | None = None, percpu: Literal[False] = False) -> _ntp.scputimes: ...
@overload
def cpu_times_percent(interval: float | None, percpu: Literal[True]) -> list[scputimes]: ...
def cpu_times_percent(interval: float | None, percpu: Literal[True]) -> list[_ntp.scputimes]: ...
@overload
def cpu_times_percent(*, percpu: Literal[True]) -> list[scputimes]: ...
def cpu_stats() -> scpustats: ...
def cpu_times_percent(*, percpu: Literal[True]) -> list[_ntp.scputimes]: ...
def cpu_stats() -> _ntp.scpustats: ...
def getloadavg() -> tuple[float, float, float]: ...
def virtual_memory() -> svmem: ...
def swap_memory() -> sswap: ...
def disk_usage(path: str) -> sdiskusage: ...
def disk_partitions(all: bool = False) -> list[sdiskpart]: ...
def virtual_memory() -> _ntp.svmem: ...
def swap_memory() -> _ntp.sswap: ...
def disk_usage(path: str) -> _ntp.sdiskusage: ...
def disk_partitions(all: bool = False) -> list[_ntp.sdiskpart]: ...

# TODO: Incorrect sdiskio for BSD systems:
@overload
def disk_io_counters(perdisk: Literal[False] = False, nowrap: bool = True) -> sdiskio | None: ...
def disk_io_counters(perdisk: Literal[False] = False, nowrap: bool = True) -> _ntp.sdiskio | None: ...
@overload
def disk_io_counters(perdisk: Literal[True], nowrap: bool = True) -> dict[str, sdiskio]: ...
def disk_io_counters(perdisk: Literal[True], nowrap: bool = True) -> dict[str, _ntp.sdiskio]: ...
@overload
def net_io_counters(pernic: Literal[False] = False, nowrap: bool = True) -> snetio: ...
def net_io_counters(pernic: Literal[False] = False, nowrap: bool = True) -> _ntp.snetio: ...
@overload
def net_io_counters(pernic: Literal[True], nowrap: bool = True) -> dict[str, snetio]: ...
def net_connections(kind: str = "inet") -> list[sconn]: ...
def net_if_addrs() -> dict[str, list[snicaddr]]: ...
def net_if_stats() -> dict[str, snicstats]: ...
def net_io_counters(pernic: Literal[True], nowrap: bool = True) -> dict[str, _ntp.snetio]: ...
def net_connections(kind: str = "inet") -> list[_ntp.sconn]: ...
def net_if_addrs() -> dict[str, list[_ntp.snicaddr]]: ...
def net_if_stats() -> dict[str, _ntp.snicstats]: ...
def boot_time() -> float: ...
def users() -> list[suser]: ...
def users() -> list[_ntp.suser]: ...
Loading