From dfd954c79c6961acb8d10154cf5dd6c7f57f1e49 Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Mon, 5 Feb 2024 22:54:48 -0800 Subject: [PATCH] Bump pexpect to 4.9 (#11287) --- stubs/pexpect/@tests/stubtest_allowlist.txt | 2 + stubs/pexpect/METADATA.toml | 2 +- stubs/pexpect/pexpect/_async.pyi | 28 ++-- stubs/pexpect/pexpect/expect.pyi | 54 +++---- stubs/pexpect/pexpect/fdpexpect.pyi | 36 +++-- stubs/pexpect/pexpect/popen_spawn.pyi | 26 ++-- stubs/pexpect/pexpect/pty_spawn.pyi | 67 +++++--- stubs/pexpect/pexpect/pxssh.pyi | 47 +++--- stubs/pexpect/pexpect/replwrap.pyi | 6 +- stubs/pexpect/pexpect/run.pyi | 34 ++-- stubs/pexpect/pexpect/socket_pexpect.pyi | 35 +++++ stubs/pexpect/pexpect/spawnbase.pyi | 163 ++++++++++++++------ stubs/pexpect/pexpect/utils.pyi | 11 +- 13 files changed, 325 insertions(+), 186 deletions(-) create mode 100644 stubs/pexpect/@tests/stubtest_allowlist.txt create mode 100644 stubs/pexpect/pexpect/socket_pexpect.pyi diff --git a/stubs/pexpect/@tests/stubtest_allowlist.txt b/stubs/pexpect/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..c65fb9a6e --- /dev/null +++ b/stubs/pexpect/@tests/stubtest_allowlist.txt @@ -0,0 +1,2 @@ +# python2 shim +pexpect.utils.InterruptedError diff --git a/stubs/pexpect/METADATA.toml b/stubs/pexpect/METADATA.toml index c484c720f..1cc4d2731 100644 --- a/stubs/pexpect/METADATA.toml +++ b/stubs/pexpect/METADATA.toml @@ -1,2 +1,2 @@ -version = "4.8.*" +version = "4.9.*" upstream_repository = "https://github.com/pexpect/pexpect" diff --git a/stubs/pexpect/pexpect/_async.pyi b/stubs/pexpect/pexpect/_async.pyi index eb2d537cf..18daf1991 100644 --- a/stubs/pexpect/pexpect/_async.pyi +++ b/stubs/pexpect/pexpect/_async.pyi @@ -1,17 +1,19 @@ import asyncio -from _typeshed import Incomplete +from typing import AnyStr, Generic -async def expect_async(expecter, timeout: Incomplete | None = None): ... -async def repl_run_command_async(repl, cmdlines, timeout: int = -1): ... +from .expect import Expecter -class PatternWaiter(asyncio.Protocol): - transport: Incomplete - expecter: Incomplete - fut: Incomplete - def set_expecter(self, expecter) -> None: ... - def found(self, result) -> None: ... - def error(self, exc) -> None: ... - def connection_made(self, transport) -> None: ... - def data_received(self, data) -> None: ... +async def expect_async(expecter: Expecter[AnyStr], timeout: float | None = None) -> int: ... +async def repl_run_command_async(repl, cmdlines, timeout: float | None = -1): ... + +class PatternWaiter(asyncio.Protocol, Generic[AnyStr]): + transport: asyncio.ReadTransport | None + expecter: Expecter[AnyStr] + fut: asyncio.Future[int] + def set_expecter(self, expecter: Expecter[AnyStr]) -> None: ... + def found(self, result: int) -> None: ... + def error(self, exc: BaseException | type[BaseException]) -> None: ... + def connection_made(self, transport: asyncio.BaseTransport) -> None: ... + def data_received(self, data: bytes) -> None: ... def eof_received(self) -> None: ... - def connection_lost(self, exc) -> None: ... + def connection_lost(self, exc: BaseException | type[BaseException] | None) -> None: ... diff --git a/stubs/pexpect/pexpect/expect.pyi b/stubs/pexpect/pexpect/expect.pyi index e7eeabf92..ec9c29b52 100644 --- a/stubs/pexpect/pexpect/expect.pyi +++ b/stubs/pexpect/pexpect/expect.pyi @@ -1,38 +1,38 @@ -from _typeshed import Incomplete -from io import BytesIO, StringIO +import re +from collections.abc import Iterable +from typing import AnyStr, Generic -from .exceptions import EOF, TIMEOUT -from .spawnbase import SpawnBase +from .spawnbase import SpawnBase, _CompiledRePattern, _CompiledStringPattern, _Searcher -class searcher_string: +class searcher_string(Generic[AnyStr]): eof_index: int timeout_index: int longest_string: int - def __init__(self, strings) -> None: ... - match: Incomplete - start: Incomplete - end: Incomplete - def search(self, buffer, freshlen, searchwindowsize: Incomplete | None = None): ... + def __init__(self, strings: Iterable[_CompiledStringPattern[AnyStr]]) -> None: ... + match: AnyStr + start: int + end: int + def search(self, buffer: AnyStr, freshlen: int, searchwindowsize: int | None = None): ... -class searcher_re: +class searcher_re(Generic[AnyStr]): eof_index: int timeout_index: int - def __init__(self, patterns) -> None: ... - start: Incomplete - match: Incomplete - end: Incomplete - def search(self, buffer, freshlen: int, searchwindowsize: int | None = None): ... + def __init__(self, patterns: Iterable[_CompiledRePattern[AnyStr]]) -> None: ... + match: re.Match[AnyStr] + start: int + end: int + def search(self, buffer: AnyStr, freshlen: int, searchwindowsize: int | None = None): ... -class Expecter: - spawn: BytesIO | StringIO - searcher: searcher_re | searcher_string +class Expecter(Generic[AnyStr]): + spawn: SpawnBase[AnyStr] + searcher: _Searcher[AnyStr] searchwindowsize: int | None - lookback: searcher_string | searcher_re | int | None - def __init__(self, spawn: SpawnBase, searcher: searcher_re | searcher_string, searchwindowsize: int = -1) -> None: ... - def do_search(self, window: str, freshlen: int): ... - def existing_data(self): ... - def new_data(self, data: Incomplete): ... - def eof(self, err: Incomplete | None = None) -> int | EOF: ... - def timeout(self, err: object | None = None) -> int | TIMEOUT: ... + lookback: _Searcher[AnyStr] | int | None + def __init__(self, spawn: SpawnBase[AnyStr], searcher: _Searcher[AnyStr], searchwindowsize: int | None = -1) -> None: ... + def do_search(self, window: AnyStr, freshlen: int) -> int: ... + def existing_data(self) -> int: ... + def new_data(self, data: AnyStr) -> int: ... + def eof(self, err: object = None) -> int: ... + def timeout(self, err: object = None) -> int: ... def errored(self) -> None: ... - def expect_loop(self, timeout: int = -1): ... + def expect_loop(self, timeout: float | None = -1) -> int: ... diff --git a/stubs/pexpect/pexpect/fdpexpect.pyi b/stubs/pexpect/pexpect/fdpexpect.pyi index 394c288a3..31a6a0a71 100644 --- a/stubs/pexpect/pexpect/fdpexpect.pyi +++ b/stubs/pexpect/pexpect/fdpexpect.pyi @@ -1,32 +1,36 @@ -from _typeshed import Incomplete +from _typeshed import FileDescriptorLike +from collections.abc import Iterable +from typing import AnyStr from .spawnbase import SpawnBase, _Logfile -class fdspawn(SpawnBase): - args: Incomplete - command: Incomplete - child_fd: Incomplete +__all__ = ["fdspawn"] + +class fdspawn(SpawnBase[AnyStr]): + args: None + command: None + child_fd: int own_fd: bool closed: bool - name: Incomplete - use_poll: Incomplete + name: str + use_poll: bool def __init__( self, - fd, - args: Incomplete | None = None, - timeout: int = 30, + fd: FileDescriptorLike, + args: None = None, + timeout: float | None = 30, maxread: int = 2000, - searchwindowsize: Incomplete | None = None, + searchwindowsize: int | None = None, logfile: _Logfile | None = None, - encoding: Incomplete | None = None, + encoding: str | None = None, codec_errors: str = "strict", use_poll: bool = False, ) -> None: ... def close(self) -> None: ... def isalive(self) -> bool: ... def terminate(self, force: bool = False) -> None: ... - def send(self, s: str | bytes) -> bytes: ... - def sendline(self, s: str | bytes) -> bytes: ... + def send(self, s: str | bytes) -> int: ... + def sendline(self, s: str | bytes) -> int: ... def write(self, s) -> None: ... - def writelines(self, sequence) -> None: ... - def read_nonblocking(self, size: int = 1, timeout: int | None = -1) -> bytes: ... + def writelines(self, sequence: Iterable[str | bytes]) -> None: ... + def read_nonblocking(self, size: int = 1, timeout: float | None = -1) -> AnyStr: ... diff --git a/stubs/pexpect/pexpect/popen_spawn.pyi b/stubs/pexpect/pexpect/popen_spawn.pyi index 88c7d939f..84e524ff5 100644 --- a/stubs/pexpect/pexpect/popen_spawn.pyi +++ b/stubs/pexpect/pexpect/popen_spawn.pyi @@ -1,24 +1,26 @@ -from _typeshed import Incomplete +import subprocess +from _typeshed import StrOrBytesPath +from collections.abc import Callable +from os import _Environ +from typing import AnyStr from .spawnbase import SpawnBase, _Logfile -class PopenSpawn(SpawnBase): - crlf: Incomplete - proc: Incomplete - pid: Incomplete +class PopenSpawn(SpawnBase[AnyStr]): + proc: subprocess.Popen[AnyStr] closed: bool def __init__( self, cmd, - timeout: int = 30, + timeout: float | None = 30, maxread: int = 2000, - searchwindowsize: Incomplete | None = None, + searchwindowsize: int | None = None, logfile: _Logfile | None = None, - cwd: Incomplete | None = None, - env: Incomplete | None = None, - encoding: Incomplete | None = None, + cwd: StrOrBytesPath | None = None, + env: _Environ[str] | None = None, + encoding: str | None = None, codec_errors: str = "strict", - preexec_fn: Incomplete | None = None, + preexec_fn: Callable[[], None] | None = None, ) -> None: ... flag_eof: bool def read_nonblocking(self, size, timeout): ... @@ -26,8 +28,6 @@ class PopenSpawn(SpawnBase): def writelines(self, sequence) -> None: ... def send(self, s): ... def sendline(self, s: str = ""): ... - exitstatus: Incomplete - signalstatus: Incomplete terminated: bool def wait(self): ... def kill(self, sig) -> None: ... diff --git a/stubs/pexpect/pexpect/pty_spawn.pyi b/stubs/pexpect/pexpect/pty_spawn.pyi index 399e7c3af..4c1d7d967 100644 --- a/stubs/pexpect/pexpect/pty_spawn.pyi +++ b/stubs/pexpect/pexpect/pty_spawn.pyi @@ -1,19 +1,26 @@ -from _typeshed import Incomplete +from _typeshed import FileDescriptorOrPath from collections.abc import Callable from os import _Environ +from typing import AnyStr from .spawnbase import SpawnBase, _Logfile -PY3: Incomplete +PY3: bool -class spawn(SpawnBase): +class spawn(SpawnBase[AnyStr]): use_native_pty_fork: bool - STDIN_FILENO: Incomplete - STDOUT_FILENO: Incomplete - STDERR_FILENO: Incomplete + STDIN_FILENO: int + STDOUT_FILENO: int + STDERR_FILENO: int str_last_chars: int - env: Incomplete + cwd: FileDescriptorOrPath | None + env: _Environ[str] + echo: bool + ignore_sighup: bool + command: str + args: list[str] name: str + use_poll: bool def __init__( self, command: str, @@ -22,11 +29,11 @@ class spawn(SpawnBase): maxread: int = 2000, searchwindowsize: int | None = None, logfile: _Logfile | None = None, - cwd: str | bytes | None = None, - env: _Environ[Incomplete] | None = None, + cwd: FileDescriptorOrPath | None = None, + env: _Environ[str] | None = None, ignore_sighup: bool = False, echo: bool = True, - preexec_fn: Callable[[Incomplete], Incomplete] | None = None, + preexec_fn: Callable[[], None] | None = None, encoding: str | None = None, codec_errors: str = "strict", dimensions: tuple[int, int] | None = None, @@ -35,16 +42,16 @@ class spawn(SpawnBase): child_fd: int closed: bool def close(self, force: bool = True) -> None: ... - def isatty(self): ... - def waitnoecho(self, timeout: int = -1): ... - def getecho(self): ... - def setecho(self, state: bool): ... - def read_nonblocking(self, size: int = 1, timeout: int | None = -1) -> bytes: ... + def isatty(self) -> bool: ... + def waitnoecho(self, timeout: float | None = -1) -> None: ... + def getecho(self) -> bool: ... + def setecho(self, state: bool) -> None: ... + def read_nonblocking(self, size: int = 1, timeout: float | None = -1) -> AnyStr: ... def write(self, s: str | bytes) -> None: ... def writelines(self, sequence: list[str | bytes]) -> None: ... - def send(self, s: str | bytes): ... - def sendline(self, s: str | bytes = ""): ... - def sendcontrol(self, char: str): ... + def send(self, s: str | bytes) -> int: ... + def sendline(self, s: str | bytes = "") -> int: ... + def sendcontrol(self, char: str) -> int: ... def sendeof(self) -> None: ... def sendintr(self) -> None: ... @property @@ -52,7 +59,7 @@ class spawn(SpawnBase): @flag_eof.setter def flag_eof(self, value: bool) -> None: ... def eof(self) -> bool: ... - def terminate(self, force: bool = False): ... + def terminate(self, force: bool = False) -> bool: ... status: int | None exitstatus: bool | None signalstatus: int | None @@ -65,8 +72,24 @@ class spawn(SpawnBase): def interact( self, escape_character="\x1d", - input_filter: Callable[[Incomplete], Incomplete] | None = None, - output_filter: Callable[[Incomplete], Incomplete] | None = None, + input_filter: Callable[[AnyStr], AnyStr] | None = None, + output_filter: Callable[[AnyStr], AnyStr] | None = None, ) -> None: ... -def spawnu(*args: str, **kwargs: str): ... +def spawnu( + command: str, + args: list[str] = [], + timeout: float | None = 30, + maxread: int = 2000, + searchwindowsize: int | None = None, + logfile: _Logfile | None = None, + cwd: FileDescriptorOrPath | None = None, + env: _Environ[str] | None = None, + ignore_sighup: bool = False, + echo: bool = True, + preexec_fn: Callable[[], None] | None = None, + encoding: str | None = "utf-8", + codec_errors: str = "strict", + dimensions: tuple[int, int] | None = None, + use_poll: bool = False, +) -> spawn[str]: ... diff --git a/stubs/pexpect/pexpect/pxssh.pyi b/stubs/pexpect/pexpect/pxssh.pyi index a92eec5fd..1cc1fed50 100644 --- a/stubs/pexpect/pexpect/pxssh.pyi +++ b/stubs/pexpect/pexpect/pxssh.pyi @@ -1,33 +1,38 @@ -from _typeshed import Incomplete - -from pexpect import ExceptionPexpect, spawn +from _typeshed import FileDescriptorOrPath +from os import _Environ +from typing import AnyStr, Literal +from .exceptions import ExceptionPexpect +from .pty_spawn import spawn from .spawnbase import _Logfile +__all__ = ["ExceptionPxssh", "pxssh"] + class ExceptionPxssh(ExceptionPexpect): ... -class pxssh(spawn): +class pxssh(spawn[AnyStr]): name: str UNIQUE_PROMPT: str - PROMPT: Incomplete + PROMPT: str PROMPT_SET_SH: str PROMPT_SET_CSH: str - SSH_OPTS: Incomplete + PROMPT_SET_ZSH: str + SSH_OPTS: str force_password: bool - debug_command_string: Incomplete - options: Incomplete + debug_command_string: bool + options: dict[str, str] def __init__( self, - timeout: int = 30, + timeout: float | None = 30, maxread: int = 2000, - searchwindowsize: Incomplete | None = None, + searchwindowsize: int | None = None, logfile: _Logfile | None = None, - cwd: Incomplete | None = None, - env: Incomplete | None = None, + cwd: FileDescriptorOrPath | None = None, + env: _Environ[str] | None = None, ignore_sighup: bool = True, echo: bool = True, - options={}, - encoding: Incomplete | None = None, + options: dict[str, str] = {}, + encoding: str | None = None, codec_errors: str = "strict", debug_command_string: bool = False, use_poll: bool = False, @@ -38,24 +43,24 @@ class pxssh(spawn): def login( self, server, - username: Incomplete | None = None, + username: str | None = None, password: str = "", terminal_type: str = "ansi", original_prompt: str = "[#$]", - login_timeout: int = 10, - port: Incomplete | None = None, + login_timeout: float | None = 10, + port: int | None = None, auto_prompt_reset: bool = True, - ssh_key: Incomplete | None = None, + ssh_key: FileDescriptorOrPath | Literal[True] | None = None, quiet: bool = True, sync_multiplier: int = 1, check_local_ip: bool = True, password_regex: str = "(?i)(?:password:)|(?:passphrase for key)", - ssh_tunnels={}, + ssh_tunnels: dict[str, list[str | int]] = {}, spawn_local_ssh: bool = True, sync_original_prompt: bool = True, - ssh_config: Incomplete | None = None, + ssh_config: FileDescriptorOrPath | None = None, cmd: str = "ssh", ): ... def logout(self) -> None: ... - def prompt(self, timeout: int = -1): ... + def prompt(self, timeout: float | None = -1): ... def set_unique_prompt(self): ... diff --git a/stubs/pexpect/pexpect/replwrap.pyi b/stubs/pexpect/pexpect/replwrap.pyi index a4cadba3d..39f7b35d8 100644 --- a/stubs/pexpect/pexpect/replwrap.pyi +++ b/stubs/pexpect/pexpect/replwrap.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import Incomplete PY3: Incomplete @@ -19,7 +20,8 @@ class REPLWrapper: extra_init_cmd: Incomplete | None = None, ) -> None: ... def set_prompt(self, orig_prompt, prompt_change) -> None: ... - def run_command(self, command, timeout: int = -1, async_: bool = False): ... + def run_command(self, command, timeout: float | None = -1, async_: bool = False): ... -def python(command: str = "python"): ... +def python(command: str = sys.executable): ... def bash(command: str = "bash"): ... +def zsh(command: str = "zsh", args=("--no-rcs", "-V", "+Z")): ... diff --git a/stubs/pexpect/pexpect/run.pyi b/stubs/pexpect/pexpect/run.pyi index 4fe623f37..5a53ecb1e 100644 --- a/stubs/pexpect/pexpect/run.pyi +++ b/stubs/pexpect/pexpect/run.pyi @@ -1,26 +1,28 @@ -from _typeshed import Incomplete +from _typeshed import FileDescriptorOrPath +from os import _Environ +from typing import AnyStr -from pexpect.spawnbase import _Logfile +from .spawnbase import _InputRePattern, _Logfile def run( - command, - timeout: int = 30, + command: str, + timeout: float | None = 30, withexitstatus: bool = False, - events: Incomplete | None = None, - extra_args: Incomplete | None = None, + events: list[tuple[_InputRePattern, AnyStr]] | dict[_InputRePattern, AnyStr] | None = None, + extra_args: None = None, logfile: _Logfile | None = None, - cwd: Incomplete | None = None, - env: Incomplete | None = None, + cwd: FileDescriptorOrPath | None = None, + env: _Environ[str] | None = None, **kwargs, -): ... +) -> AnyStr | tuple[AnyStr, int]: ... def runu( - command, - timeout: int = 30, + command: str, + timeout: float | None = 30, withexitstatus: bool = False, - events: Incomplete | None = None, - extra_args: Incomplete | None = None, + events: list[tuple[_InputRePattern, AnyStr]] | dict[_InputRePattern, AnyStr] | None = None, + extra_args: None = None, logfile: _Logfile | None = None, - cwd: Incomplete | None = None, - env: Incomplete | None = None, + cwd: FileDescriptorOrPath | None = None, + env: _Environ[str] | None = None, **kwargs, -): ... +) -> AnyStr | tuple[AnyStr, int]: ... diff --git a/stubs/pexpect/pexpect/socket_pexpect.pyi b/stubs/pexpect/pexpect/socket_pexpect.pyi new file mode 100644 index 000000000..f3c8d42d0 --- /dev/null +++ b/stubs/pexpect/pexpect/socket_pexpect.pyi @@ -0,0 +1,35 @@ +from collections.abc import Iterable +from socket import socket as Socket +from typing import AnyStr + +from .spawnbase import SpawnBase, _Logfile + +__all__ = ["SocketSpawn"] + +class SocketSpawn(SpawnBase[AnyStr]): + args: None + command: None + socket: Socket + child_fd: int + closed: bool + name: str + use_poll: bool + def __init__( + self, + socket: Socket, + args: None = None, + timeout: float | None = 30, + maxread: int = 2000, + searchwindowsize: int | None = None, + logfile: _Logfile | None = None, + encoding: str | None = None, + codec_errors: str = "strict", + use_poll: bool = False, + ) -> None: ... + def close(self) -> None: ... + def isalive(self) -> bool: ... + def send(self, s: str | bytes) -> int: ... + def sendline(self, s: str | bytes) -> int: ... + def write(self, s: str | bytes) -> None: ... + def writelines(self, sequence: Iterable[str | bytes]) -> None: ... + def read_nonblocking(self, size: int = 1, timeout: float | None = -1) -> AnyStr: ... diff --git a/stubs/pexpect/pexpect/spawnbase.pyi b/stubs/pexpect/pexpect/spawnbase.pyi index b8e5fbb87..d134a1afd 100644 --- a/stubs/pexpect/pexpect/spawnbase.pyi +++ b/stubs/pexpect/pexpect/spawnbase.pyi @@ -1,10 +1,15 @@ -from _typeshed import Incomplete -from collections.abc import Callable -from re import Pattern -from typing import AnyStr, Protocol +from asyncio import ReadTransport +from collections.abc import Awaitable, Callable, Iterable +from re import Match, Pattern +from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload +from typing_extensions import TypeAlias + +from ._async import PatternWaiter +from .exceptions import EOF, TIMEOUT +from .expect import searcher_re, searcher_string PY3: bool -text_type: Callable[[Incomplete], Incomplete] +text_type: type class _NullCoder: @staticmethod @@ -16,68 +21,126 @@ class _Logfile(Protocol): def write(self, __s) -> object: ... def flush(self) -> object: ... -class SpawnBase: - encoding: Incomplete - pid: Incomplete +_ErrorPattern: TypeAlias = type[EOF | TIMEOUT] +_InputStringPattern: TypeAlias = str | bytes | _ErrorPattern +_InputRePattern: TypeAlias = Pattern[str] | Pattern[bytes] | _InputStringPattern +_CompiledStringPattern: TypeAlias = AnyStr | _ErrorPattern +_CompiledRePattern: TypeAlias = Pattern[AnyStr] | _ErrorPattern +_Searcher: TypeAlias = searcher_string[AnyStr] | searcher_re[AnyStr] + +class SpawnBase(Generic[AnyStr]): + encoding: str | None + pid: int | None flag_eof: bool - stdin: Incomplete - stdout: Incomplete - stderr: Incomplete - searcher: Incomplete + stdin: TextIO + stdout: TextIO + stderr: TextIO + searcher: None ignorecase: bool - before: Incomplete - after: Incomplete - match: Incomplete - match_index: Incomplete + before: AnyStr | None + after: _CompiledStringPattern[AnyStr] | None + match: AnyStr | Match[AnyStr] | _ErrorPattern | None + match_index: int | None terminated: bool - exitstatus: Incomplete - signalstatus: Incomplete - status: Incomplete + exitstatus: int | None + signalstatus: int | None + status: int | None child_fd: int - timeout: Incomplete - delimiter: Incomplete - logfile: _Logfile - logfile_read: _Logfile - logfile_send: _Logfile - maxread: Incomplete - searchwindowsize: Incomplete + timeout: float | None + delimiter: type[EOF] + logfile: _Logfile | None + logfile_read: _Logfile | None + logfile_send: _Logfile | None + maxread: int + searchwindowsize: int | None delaybeforesend: float | None delayafterclose: float delayafterterminate: float delayafterread: float softspace: bool - name: Incomplete + name: str closed: bool - codec_errors: Incomplete - string_type: Incomplete - buffer_type: Incomplete - crlf: bytes - allowed_string_types: Incomplete - linesep: Incomplete - write_to_stdout: Incomplete - async_pw_transport: Incomplete + codec_errors: str + string_type: type[AnyStr] + buffer_type: IO[AnyStr] + crlf: AnyStr + allowed_string_types: tuple[type, ...] + linesep: AnyStr + write_to_stdout: Callable[[AnyStr], int] + async_pw_transport: tuple[PatternWaiter[AnyStr], ReadTransport] | None def __init__( self, - timeout: int = 30, + timeout: float | None = 30, maxread: int = 2000, - searchwindowsize: Incomplete | None = None, + searchwindowsize: int | None = None, logfile: _Logfile | None = None, - encoding: Incomplete | None = None, + encoding: str | None = None, codec_errors: str = "strict", ) -> None: ... - buffer: Incomplete - def read_nonblocking(self, size: int = 1, timeout: int | None = None) -> bytes: ... - def compile_pattern_list(self, patterns) -> list[Pattern[AnyStr]]: ... - def expect(self, pattern, timeout: int = -1, searchwindowsize: int = -1, async_: bool = False, **kw) -> int: ... - def expect_list(self, pattern_list, timeout: int = -1, searchwindowsize: int = -1, async_: bool = False, **kw) -> int: ... - def expect_exact(self, pattern_list, timeout: int = -1, searchwindowsize: int = -1, async_: bool = False, **kw) -> int: ... - def expect_loop(self, searcher, timeout: int = -1, searchwindowsize: int = -1) -> int: ... - def read(self, size: int = -1) -> bytes: ... - def readline(self, size: int = -1) -> bytes: ... + @property + def buffer(self) -> AnyStr: ... + @buffer.setter + def buffer(self, value: AnyStr) -> None: ... + def read_nonblocking(self, size: int = 1, timeout: float | None = None) -> AnyStr: ... + def compile_pattern_list(self, patterns: _InputRePattern | list[_InputRePattern]) -> list[_CompiledRePattern[AnyStr]]: ... + @overload + def expect( + self, + pattern: _InputRePattern | list[_InputRePattern], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + async_: Literal[False] = False, + ) -> int: ... + @overload + def expect( + self, + pattern: _InputRePattern | list[_InputRePattern], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + *, + async_: Literal[True], + ) -> Awaitable[int]: ... + @overload + def expect_list( + self, + pattern_list: list[_CompiledRePattern[AnyStr]], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + async_: Literal[False] = False, + ) -> int: ... + @overload + def expect_list( + self, + pattern_list: list[_CompiledRePattern[AnyStr]], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + *, + async_: Literal[True], + ) -> Awaitable[int]: ... + @overload + def expect_exact( + self, + pattern_list: _InputStringPattern | Iterable[_InputStringPattern], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + async_: Literal[False] = False, + ) -> int: ... + @overload + def expect_exact( + self, + pattern_list: _InputStringPattern | Iterable[_InputStringPattern], + timeout: float | None = -1, + searchwindowsize: int | None = -1, + *, + async_: Literal[True], + ) -> Awaitable[int]: ... + def expect_loop(self, searcher: _Searcher[AnyStr], timeout: float | None = -1, searchwindowsize: int | None = -1) -> int: ... + def read(self, size: int = -1) -> AnyStr: ... + def readline(self, size: int = -1) -> AnyStr: ... def __iter__(self): ... - def readlines(self, sizehint: int = -1) -> list[str]: ... - def fileno(self): ... + def readlines(self, sizehint: int = -1) -> list[AnyStr]: ... + def fileno(self) -> int: ... def flush(self) -> None: ... - def isatty(self): ... + def isatty(self) -> bool: ... def __enter__(self): ... def __exit__(self, etype, evalue, tb) -> None: ... diff --git a/stubs/pexpect/pexpect/utils.pyi b/stubs/pexpect/pexpect/utils.pyi index 8394e1d23..285cdb2ce 100644 --- a/stubs/pexpect/pexpect/utils.pyi +++ b/stubs/pexpect/pexpect/utils.pyi @@ -1,9 +1,10 @@ -from _typeshed import Incomplete +from os import _Environ -string_types: Incomplete +InterruptedError: type +string_types: tuple[type, ...] def is_executable_file(path): ... -def which(filename, env: Incomplete | None = None): ... +def which(filename, env: _Environ[str] | None = None): ... def split_command_line(command_line): ... -def select_ignore_interrupts(iwtd, owtd, ewtd, timeout: Incomplete | None = None): ... -def poll_ignore_interrupts(fds, timeout: Incomplete | None = None): ... +def select_ignore_interrupts(iwtd, owtd, ewtd, timeout: float | None = None): ... +def poll_ignore_interrupts(fds, timeout: float | None = None): ...