diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index fd471cb2a..371f5de8b 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -47,6 +47,7 @@ from ._common import ( NoSuchProcess as NoSuchProcess, TimeoutExpired as TimeoutExpired, ZombieProcess as ZombieProcess, + _Status, pconn, pcputimes, pctxsw, @@ -132,7 +133,7 @@ class Process: def name(self) -> str: ... def exe(self) -> str: ... def cmdline(self) -> list[str]: ... - def status(self) -> int: ... + def status(self) -> _Status: ... def username(self) -> str: ... def create_time(self) -> float: ... def cwd(self) -> str: ... diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index 22b08bdb3..dda1cee06 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -2,6 +2,7 @@ import enum from _typeshed import StrOrBytesPath, SupportsWrite from socket import AddressFamily, SocketKind from typing import Any, Callable, NamedTuple, TypeVar, overload +from typing_extensions import Literal POSIX: bool WINDOWS: bool @@ -14,20 +15,39 @@ NETBSD: bool BSD: bool SUNOS: bool AIX: bool -STATUS_RUNNING: str -STATUS_SLEEPING: str -STATUS_DISK_SLEEP: str -STATUS_STOPPED: str -STATUS_TRACING_STOP: str -STATUS_ZOMBIE: str -STATUS_DEAD: str -STATUS_WAKE_KILL: str -STATUS_WAKING: str -STATUS_IDLE: str -STATUS_LOCKED: str -STATUS_WAITING: str -STATUS_SUSPENDED: str -STATUS_PARKED: str + +STATUS_RUNNING: Literal["running"] +STATUS_SLEEPING: Literal["sleeping"] +STATUS_DISK_SLEEP: Literal["disk-sleep"] +STATUS_STOPPED: Literal["stopped"] +STATUS_TRACING_STOP: Literal["tracing-stop"] +STATUS_ZOMBIE: Literal["zombie"] +STATUS_DEAD: Literal["dead"] +STATUS_WAKE_KILL: Literal["wake-kill"] +STATUS_WAKING: Literal["waking"] +STATUS_IDLE: Literal["idle"] +STATUS_LOCKED: Literal["locked"] +STATUS_WAITING: Literal["waiting"] +STATUS_SUSPENDED: Literal["suspended"] +STATUS_PARKED: Literal["parked"] + +_Status = Literal[ + "running", + "sleeping", + "disk-sleep", + "stopped", + "tracing-stop", + "zombie", + "dead", + "wake-kill", + "waking", + "idle", + "locked", + "waiting", + "suspended", + "parked", +] + CONN_ESTABLISHED: str CONN_SYN_SENT: str CONN_SYN_RECV: str