From f77fc44c2657c7099b5bb3900cdaaeccc029193d Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 25 Sep 2021 15:40:03 +0300 Subject: [PATCH 1/2] Improves `Popen` types in `psutil` --- stubs/psutil/psutil/__init__.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 41aa0041cf70..1665c161a327 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, ContextManager, Iterable, Iterator +from typing import Any, Callable, ContextManager, Iterable, Iterator, TypeVar from ._common import ( AIX as AIX, @@ -160,13 +160,13 @@ class Process: def kill(self) -> None: ... def wait(self, timeout: int | None = ...) -> int: ... +_Popen = TypeVar('_Popen', bound='Popen') + class Popen(Process): def __init__(self, *args, **kwargs) -> None: ... - def __dir__(self): ... - def __enter__(self): ... - def __exit__(self, *args, **kwargs): ... - def __getattribute__(self, name): ... - def wait(self, timeout: Any | None = ...): ... + def __enter__(self: _Popen) -> _Popen: ... + def __exit__(self, *args, **kwargs) -> None: ... + def __getattribute__(self, name: str) -> Any: ... def pids() -> list[int]: ... def pid_exists(pid: int) -> bool: ... From 1570f38e15ab435939deeec2487690af02cc850f Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 25 Sep 2021 15:45:51 +0300 Subject: [PATCH 2/2] Update __init__.pyi --- stubs/psutil/psutil/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 1665c161a327..881cce6309c1 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -160,7 +160,7 @@ class Process: def kill(self) -> None: ... def wait(self, timeout: int | None = ...) -> int: ... -_Popen = TypeVar('_Popen', bound='Popen') +_Popen = TypeVar("_Popen", bound="Popen") class Popen(Process): def __init__(self, *args, **kwargs) -> None: ...