Skip to content

Commit 750d366

Browse files
authored
Add missing annotations for psutil (#6124)
1 parent 88cb22e commit 750d366

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

stubs/psutil/psutil/__init__.pyi

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import Any, Callable, ContextManager, Iterable, Iterator, TypeVar
2+
from typing import Any, Callable, ContextManager, Iterable, Iterator, Tuple, TypeVar
33

44
from ._common import (
55
AIX as AIX,
@@ -97,6 +97,16 @@ if sys.platform == "win32":
9797
win_service_iter as win_service_iter,
9898
)
9999

100+
if sys.platform == "linux":
101+
from ._pslinux import pfullmem, pmem
102+
elif sys.platform == "darwin":
103+
from ._psosx import pfullmem, pmem
104+
elif sys.platform == "win32":
105+
from ._pswindows import pfullmem, pmem
106+
else:
107+
pmem = Any
108+
pfullmem = Any
109+
100110
if sys.platform == "linux":
101111
PROCFS_PATH: str
102112
AF_LINK: int
@@ -106,20 +116,22 @@ __author__: str
106116

107117
class Process:
108118
def __init__(self, pid: int | None = ...) -> None: ...
109-
def __eq__(self, other) -> bool: ...
110-
def __ne__(self, other) -> bool: ...
119+
def __eq__(self, other: object) -> bool: ...
120+
def __ne__(self, other: object) -> bool: ...
111121
def __hash__(self) -> int: ...
112122
@property
113123
def pid(self) -> int: ...
114124
def oneshot(self) -> ContextManager[None]: ...
115-
def as_dict(self, attrs: Any | None = ..., ad_value: Any | None = ...): ...
125+
def as_dict(
126+
self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
127+
) -> dict[str, Any]: ...
116128
def parent(self) -> Process: ...
117129
def parents(self) -> list[Process]: ...
118130
def is_running(self) -> bool: ...
119131
def ppid(self) -> int: ...
120132
def name(self) -> str: ...
121133
def exe(self) -> str: ...
122-
def cmdline(self): ...
134+
def cmdline(self) -> list[str]: ...
123135
def status(self) -> int: ...
124136
def username(self) -> str: ...
125137
def create_time(self) -> float: ...
@@ -148,9 +160,9 @@ class Process:
148160
def children(self, recursive: bool = ...) -> list[Process]: ...
149161
def cpu_percent(self, interval: float | None = ...) -> float: ...
150162
def cpu_times(self) -> pcputimes: ...
151-
def memory_info(self): ...
152-
def memory_info_ex(self): ...
153-
def memory_full_info(self): ...
163+
def memory_info(self) -> pmem: ...
164+
def memory_info_ex(self) -> pmem: ...
165+
def memory_full_info(self) -> pfullmem: ...
154166
def memory_percent(self, memtype: str = ...) -> float: ...
155167
if sys.platform != "darwin":
156168
def memory_maps(self, grouped: bool = ...): ...
@@ -173,7 +185,9 @@ class Popen(Process):
173185

174186
def pids() -> list[int]: ...
175187
def pid_exists(pid: int) -> bool: ...
176-
def process_iter(attrs: Any | None = ..., ad_value: Any | None = ...) -> Iterator[Process]: ...
188+
def process_iter(
189+
attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
190+
) -> Iterator[Process]: ...
177191
def wait_procs(
178192
procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ...
179193
) -> tuple[list[Process], list[Process]]: ...

0 commit comments

Comments
 (0)