Skip to content

Commit ccdc595

Browse files
committed
[psutil] Annotate Popen.__init__ method
1 parent a566aee commit ccdc595

File tree

1 file changed

+95
-3
lines changed

1 file changed

+95
-3
lines changed

stubs/psutil/psutil/__init__.pyi

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
2-
from _typeshed import Incomplete
3-
from collections.abc import Callable, Iterable, Iterator
2+
from _typeshed import Incomplete, StrOrBytesPath
3+
from collections.abc import Callable, Collection, Iterable, Iterator
44
from contextlib import AbstractContextManager
5+
from subprocess import _CMD, _ENV, _FILE
56
from types import TracebackType
67
from typing import Any, Literal, Protocol, overload, type_check_only
78
from typing_extensions import Self, TypeAlias, deprecated
@@ -204,7 +205,98 @@ class Process:
204205
def net_connections(self, kind: str = "inet") -> list[_ntp.pconn]: ...
205206

206207
class Popen(Process):
207-
def __init__(self, *args, **kwargs) -> None: ...
208+
# sync with subprocess.Popen.__init__:
209+
if sys.version_info >= (3, 11):
210+
def __init__(
211+
self,
212+
args: _CMD,
213+
bufsize: int = -1,
214+
executable: StrOrBytesPath | None = None,
215+
stdin: _FILE | None = None,
216+
stdout: _FILE | None = None,
217+
stderr: _FILE | None = None,
218+
preexec_fn: Callable[[], object] | None = None,
219+
close_fds: bool = True,
220+
shell: bool = False,
221+
cwd: StrOrBytesPath | None = None,
222+
env: _ENV | None = None,
223+
universal_newlines: bool | None = None,
224+
startupinfo: Any | None = None,
225+
creationflags: int = 0,
226+
restore_signals: bool = True,
227+
start_new_session: bool = False,
228+
pass_fds: Collection[int] = (),
229+
*,
230+
text: bool | None = None,
231+
encoding: str | None = None,
232+
errors: str | None = None,
233+
user: str | int | None = None,
234+
group: str | int | None = None,
235+
extra_groups: Iterable[str | int] | None = None,
236+
umask: int = -1,
237+
pipesize: int = -1,
238+
process_group: int | None = None,
239+
) -> None: ...
240+
elif sys.version_info >= (3, 10):
241+
def __init__(
242+
self,
243+
args: _CMD,
244+
bufsize: int = -1,
245+
executable: StrOrBytesPath | None = None,
246+
stdin: _FILE | None = None,
247+
stdout: _FILE | None = None,
248+
stderr: _FILE | None = None,
249+
preexec_fn: Callable[[], object] | None = None,
250+
close_fds: bool = True,
251+
shell: bool = False,
252+
cwd: StrOrBytesPath | None = None,
253+
env: _ENV | None = None,
254+
universal_newlines: bool | None = None,
255+
startupinfo: Any | None = None,
256+
creationflags: int = 0,
257+
restore_signals: bool = True,
258+
start_new_session: bool = False,
259+
pass_fds: Collection[int] = (),
260+
*,
261+
text: bool | None = None,
262+
encoding: str | None = None,
263+
errors: str | None = None,
264+
user: str | int | None = None,
265+
group: str | int | None = None,
266+
extra_groups: Iterable[str | int] | None = None,
267+
umask: int = -1,
268+
pipesize: int = -1,
269+
) -> None: ...
270+
else:
271+
def __init__(
272+
self,
273+
args: _CMD,
274+
bufsize: int = -1,
275+
executable: StrOrBytesPath | None = None,
276+
stdin: _FILE | None = None,
277+
stdout: _FILE | None = None,
278+
stderr: _FILE | None = None,
279+
preexec_fn: Callable[[], object] | None = None,
280+
close_fds: bool = True,
281+
shell: bool = False,
282+
cwd: StrOrBytesPath | None = None,
283+
env: _ENV | None = None,
284+
universal_newlines: bool | None = None,
285+
startupinfo: Any | None = None,
286+
creationflags: int = 0,
287+
restore_signals: bool = True,
288+
start_new_session: bool = False,
289+
pass_fds: Collection[int] = (),
290+
*,
291+
text: bool | None = None,
292+
encoding: str | None = None,
293+
errors: str | None = None,
294+
user: str | int | None = None,
295+
group: str | int | None = None,
296+
extra_groups: Iterable[str | int] | None = None,
297+
umask: int = -1,
298+
) -> None: ...
299+
208300
def __enter__(self) -> Self: ...
209301
def __exit__(
210302
self, exc_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None

0 commit comments

Comments
 (0)