Skip to content

Fix e3.os.process typing #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/e3/os/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
from e3.os.fs import which
from e3.text import bytes_as_str


if TYPE_CHECKING:
from typing import cast, Any, IO, List, Literal, NoReturn, Union
from typing import cast, Any, IO, Literal, NoReturn, Union

CmdLine = List[str]
AnyCmdLine = Union[List[CmdLine], CmdLine]
CmdLine = list[str]
AnyCmdLine = Union[list[CmdLine], CmdLine]
STDOUT_VALUE = Literal[-1]
PIPE_VALUE = Literal[-2]
DEVNULL_VALUE = Literal[-3]
Expand Down Expand Up @@ -671,12 +670,11 @@ def __init__(self, name: Any, mode: str = "r"):
# this is a file descriptor
self.fd = name

def get_command(self) -> str | None:
def get_command(self) -> str | bytes | None:
"""Return the command to run to create the pipe."""
if self.fd == subprocess.PIPE:
if self.fd == subprocess.PIPE and isinstance(self.name, (str, bytes)):
return self.name[1:]
else:
return None
return None

def close(self) -> None:
"""Close the file if needed."""
Expand Down