Skip to content

Commit 0a5816c

Browse files
committed
Try to fix type errors on versions prior to 3.8
1 parent 95c375c commit 0a5816c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd2/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Enum,
1717
)
1818
from typing import (
19+
TYPE_CHECKING,
1920
Any,
2021
Callable,
2122
Dict,
@@ -37,6 +38,13 @@
3738
CompleterFunc,
3839
)
3940

41+
if TYPE_CHECKING: # pragma: no cover
42+
import cmd2 # noqa: F401
43+
44+
PopenTextIO = subprocess.Popen[str]
45+
else:
46+
PopenTextIO = subprocess.Popen
47+
4048
_T = TypeVar('_T')
4149

4250

@@ -578,7 +586,7 @@ class ProcReader:
578586
If neither are pipes, then the process will run normally and no output will be captured.
579587
"""
580588

581-
def __init__(self, proc: subprocess.Popen[str], stdout: Union[StdSim, TextIO], stderr: Union[StdSim, TextIO]) -> None:
589+
def __init__(self, proc: PopenTextIO, stdout: Union[StdSim, TextIO], stderr: Union[StdSim, TextIO]) -> None:
582590
"""
583591
ProcReader initializer
584592
:param proc: the Popen process being read from

0 commit comments

Comments
 (0)