Skip to content

Commit 7f9b3ea

Browse files
authored
Support for pexpect.spawn(..., logfile=sys.stdout) (python#10976)
1 parent 7ef466e commit 7f9b3ea

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

stubs/pexpect/pexpect/fdpexpect.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
22

3-
from .spawnbase import SpawnBase
3+
from .spawnbase import SpawnBase, _Logfile
44

55
class fdspawn(SpawnBase):
66
args: Incomplete
@@ -17,7 +17,7 @@ class fdspawn(SpawnBase):
1717
timeout: int = 30,
1818
maxread: int = 2000,
1919
searchwindowsize: Incomplete | None = None,
20-
logfile: Incomplete | None = None,
20+
logfile: _Logfile | None = None,
2121
encoding: Incomplete | None = None,
2222
codec_errors: str = "strict",
2323
use_poll: bool = False,

stubs/pexpect/pexpect/popen_spawn.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
22

3-
from .spawnbase import SpawnBase
3+
from .spawnbase import SpawnBase, _Logfile
44

55
class PopenSpawn(SpawnBase):
66
crlf: Incomplete
@@ -13,7 +13,7 @@ class PopenSpawn(SpawnBase):
1313
timeout: int = 30,
1414
maxread: int = 2000,
1515
searchwindowsize: Incomplete | None = None,
16-
logfile: Incomplete | None = None,
16+
logfile: _Logfile | None = None,
1717
cwd: Incomplete | None = None,
1818
env: Incomplete | None = None,
1919
encoding: Incomplete | None = None,

stubs/pexpect/pexpect/pty_spawn.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from _typeshed import Incomplete
22
from collections.abc import Callable
3-
from io import TextIOWrapper
43
from os import _Environ
54

6-
from .spawnbase import SpawnBase
5+
from .spawnbase import SpawnBase, _Logfile
76

87
PY3: Incomplete
98

@@ -22,7 +21,7 @@ class spawn(SpawnBase):
2221
timeout: int = 30,
2322
maxread: int = 2000,
2423
searchwindowsize: int | None = None,
25-
logfile: TextIOWrapper | None = None,
24+
logfile: _Logfile | None = None,
2625
cwd: str | bytes | None = None,
2726
env: _Environ[Incomplete] | None = None,
2827
ignore_sighup: bool = False,

stubs/pexpect/pexpect/pxssh.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ from _typeshed import Incomplete
22

33
from pexpect import ExceptionPexpect, spawn
44

5+
from .spawnbase import _Logfile
6+
57
class ExceptionPxssh(ExceptionPexpect): ...
68

79
class pxssh(spawn):
@@ -19,7 +21,7 @@ class pxssh(spawn):
1921
timeout: int = 30,
2022
maxread: int = 2000,
2123
searchwindowsize: Incomplete | None = None,
22-
logfile: Incomplete | None = None,
24+
logfile: _Logfile | None = None,
2325
cwd: Incomplete | None = None,
2426
env: Incomplete | None = None,
2527
ignore_sighup: bool = True,

stubs/pexpect/pexpect/run.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from _typeshed import Incomplete
22

3+
from pexpect.spawnbase import _Logfile
4+
35
def run(
46
command,
57
timeout: int = 30,
68
withexitstatus: bool = False,
79
events: Incomplete | None = None,
810
extra_args: Incomplete | None = None,
9-
logfile: Incomplete | None = None,
11+
logfile: _Logfile | None = None,
1012
cwd: Incomplete | None = None,
1113
env: Incomplete | None = None,
1214
**kwargs,
@@ -17,7 +19,7 @@ def runu(
1719
withexitstatus: bool = False,
1820
events: Incomplete | None = None,
1921
extra_args: Incomplete | None = None,
20-
logfile: Incomplete | None = None,
22+
logfile: _Logfile | None = None,
2123
cwd: Incomplete | None = None,
2224
env: Incomplete | None = None,
2325
**kwargs,

stubs/pexpect/pexpect/spawnbase.pyi

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import Incomplete
22
from collections.abc import Callable
33
from re import Pattern
4-
from typing import AnyStr
4+
from typing import AnyStr, Protocol
55

66
PY3: bool
77
text_type: Callable[[Incomplete], Incomplete]
@@ -12,6 +12,10 @@ class _NullCoder:
1212
@staticmethod
1313
def decode(b: str, final: bool = False): ...
1414

15+
class _Logfile(Protocol):
16+
def write(self, __s) -> object: ...
17+
def flush(self) -> object: ...
18+
1519
class SpawnBase:
1620
encoding: Incomplete
1721
pid: Incomplete
@@ -32,9 +36,9 @@ class SpawnBase:
3236
child_fd: int
3337
timeout: Incomplete
3438
delimiter: Incomplete
35-
logfile: Incomplete
36-
logfile_read: Incomplete
37-
logfile_send: Incomplete
39+
logfile: _Logfile
40+
logfile_read: _Logfile
41+
logfile_send: _Logfile
3842
maxread: Incomplete
3943
searchwindowsize: Incomplete
4044
delaybeforesend: float
@@ -57,7 +61,7 @@ class SpawnBase:
5761
timeout: int = 30,
5862
maxread: int = 2000,
5963
searchwindowsize: Incomplete | None = None,
60-
logfile: Incomplete | None = None,
64+
logfile: _Logfile | None = None,
6165
encoding: Incomplete | None = None,
6266
codec_errors: str = "strict",
6367
) -> None: ...

0 commit comments

Comments
 (0)