Improve PathLike handling for subprocess cmd/env (#5185)

This commit is contained in:
Edgar Handal
2021-04-05 23:32:48 -05:00
committed by GitHub
parent 701e741946
commit 4594164977

View File

@@ -23,10 +23,16 @@ if sys.version_info >= (3, 9):
# reveal_type(e.cmd) # Any, but morally is _CMD
_FILE = Union[None, int, IO[Any]]
_TXT = Union[bytes, str]
# Python 3.6 does't support _CMD being a single PathLike.
# See: https://bugs.python.org/issue31961
_CMD = Union[_TXT, Sequence[AnyPath]]
_ENV = Union[Mapping[bytes, _TXT], Mapping[str, _TXT]]
if sys.version_info < (3, 8):
# Python 3.6 doesn't support _CMD being a single PathLike.
# See: https://bugs.python.org/issue31961
_CMD = Union[_TXT, Sequence[AnyPath]]
else:
_CMD = Union[AnyPath, Sequence[AnyPath]]
if sys.platform == "win32":
_ENV = Mapping[str, str]
else:
_ENV = Union[Mapping[bytes, AnyPath], Mapping[str, AnyPath]]
_S = TypeVar("_S")
_T = TypeVar("_T")