From 983bd5f0b4797a3c210b914a34b04284243f824f Mon Sep 17 00:00:00 2001 From: Olivier Ramonat Date: Fri, 27 Oct 2023 17:48:07 +0200 Subject: [PATCH] Fix Run type hinting Also leverage psutil type annotations now that they are available for #648 --- mypy.ini | 3 --- src/e3/anod/spec.py | 4 ++-- src/e3/os/process.py | 2 +- src/e3/vcs/git.py | 5 ++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/mypy.ini b/mypy.ini index 410c6ae5..8317abc8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -49,9 +49,6 @@ ignore_missing_imports = True [mypy-ld.*] ignore_missing_imports = True -[mypy-psutil.*] -ignore_missing_imports = True - [mypy-pytest.*] ignore_missing_imports = True diff --git a/src/e3/anod/spec.py b/src/e3/anod/spec.py index 02cfa7eb..f2b9fd52 100644 --- a/src/e3/anod/spec.py +++ b/src/e3/anod/spec.py @@ -38,7 +38,7 @@ from e3.anod.buildspace import BuildSpace from e3.anod.sandbox import SandBox from e3.env import BaseEnv - from e3.os.process import STDOUT_VALUE, DEVNULL_VALUE, PIPE_VALUE + from e3.os.process import DEVNULL_VALUE, PIPE_VALUE import e3.anod.package import e3.anod.sandbox @@ -544,7 +544,7 @@ def shell( self, *command: str, parse_shebang: bool = True, - output: STDOUT_VALUE | DEVNULL_VALUE | PIPE_VALUE | str | IO | None = None, + output: DEVNULL_VALUE | PIPE_VALUE | str | IO | None = None, python_executable: None = None, **kwargs: Any, ) -> e3.os.process.Run: diff --git a/src/e3/os/process.py b/src/e3/os/process.py index 9befe889..f8ee877d 100644 --- a/src/e3/os/process.py +++ b/src/e3/os/process.py @@ -234,7 +234,7 @@ def __init__( self, cmds: AnyCmdLine, cwd: str | None = None, - output: STDOUT_VALUE | DEVNULL_VALUE | PIPE_VALUE | str | IO | None = PIPE, + output: DEVNULL_VALUE | PIPE_VALUE | str | IO | None = PIPE, error: STDOUT_VALUE | DEVNULL_VALUE | PIPE_VALUE | str | IO | None = STDOUT, input: DEVNULL_VALUE # noqa: A002 | PIPE_VALUE diff --git a/src/e3/vcs/git.py b/src/e3/vcs/git.py index 10e665bd..ec8703a1 100644 --- a/src/e3/vcs/git.py +++ b/src/e3/vcs/git.py @@ -43,7 +43,7 @@ TextIO, ) from collections.abc import Iterator - from e3.os.process import Run, STDOUT_VALUE, DEVNULL_VALUE, PIPE_VALUE + from e3.os.process import Run, DEVNULL_VALUE, PIPE_VALUE Git_Cmd = List[Optional[str]] GIT_LOG_STREAM_VALUE = Literal[-4] @@ -109,8 +109,7 @@ def create(cls, repo_path: str, initial_content_path: str | None = None) -> str: def git_cmd( self, cmd: Git_Cmd, - output: STDOUT_VALUE - | DEVNULL_VALUE + output: DEVNULL_VALUE | PIPE_VALUE | GIT_LOG_STREAM_VALUE | str