Skip to content

Commit f29f456

Browse files
committed
subprocess: Improve bytes-related types
Backport of python/typeshed@b9eab63
1 parent ea75f1d commit f29f456

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/libvcs/_internal/subprocess.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from .dataclasses import SkipDefaultFieldsReprMixin
6161

6262
if TYPE_CHECKING:
63+
from _typeshed import ReadableBuffer
6364
from typing_extensions import TypeAlias
6465

6566

@@ -79,7 +80,7 @@ def __init__(self, output: str, *args: object) -> None:
7980
Mapping[str, StrOrBytesPath],
8081
]
8182
_FILE: "TypeAlias" = Union[None, int, IO[Any]]
82-
_TXT: "TypeAlias" = Union[bytes, str]
83+
_InputString: "TypeAlias" = Union["ReadableBuffer", str]
8384
#: Command
8485
_CMD: "TypeAlias" = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
8586

@@ -438,7 +439,7 @@ def run(
438439
check: bool = ...,
439440
encoding: Optional[str] = ...,
440441
errors: Optional[str] = ...,
441-
input: Optional[str] = ...,
442+
input: Optional["_InputString"] = ...,
442443
text: Literal[True],
443444
) -> subprocess.CompletedProcess[str]: ...
444445

@@ -451,7 +452,7 @@ def run(
451452
check: bool = ...,
452453
encoding: str,
453454
errors: Optional[str] = ...,
454-
input: Optional[str] = ...,
455+
input: Optional["_InputString"] = ...,
455456
text: Optional[bool] = ...,
456457
) -> subprocess.CompletedProcess[str]: ...
457458

@@ -464,7 +465,7 @@ def run(
464465
check: bool = ...,
465466
encoding: Optional[str] = ...,
466467
errors: str,
467-
input: Optional[str] = ...,
468+
input: Optional["_InputString"] = ...,
468469
text: Optional[bool] = ...,
469470
) -> subprocess.CompletedProcess[str]: ...
470471

@@ -478,7 +479,7 @@ def run(
478479
check: bool = ...,
479480
encoding: Optional[str] = ...,
480481
errors: Optional[str] = ...,
481-
input: Optional[str] = ...,
482+
input: Optional["_InputString"] = ...,
482483
text: Optional[bool] = ...,
483484
) -> subprocess.CompletedProcess[str]: ...
484485

@@ -491,7 +492,7 @@ def run(
491492
check: bool = ...,
492493
encoding: None = ...,
493494
errors: None = ...,
494-
input: Optional[bytes] = ...,
495+
input: Optional["ReadableBuffer"] = ...,
495496
text: Literal[None, False] = ...,
496497
) -> subprocess.CompletedProcess[bytes]: ...
497498

@@ -503,7 +504,7 @@ def run(
503504
check: bool = False,
504505
encoding: Optional[str] = None,
505506
errors: Optional[str] = None,
506-
input: Optional[Union[str, bytes]] = None,
507+
input: Optional[Union["_InputString", "ReadableBuffer"]] = None,
507508
text: Optional[bool] = None,
508509
timeout: Optional[float] = None,
509510
**kwargs: Any,

0 commit comments

Comments
 (0)