From 3618162635f21779bb969bf3aaa974a23d0d2236 Mon Sep 17 00:00:00 2001 From: Jean-Louis Fuchs Date: Sun, 3 Mar 2024 16:58:29 +0100 Subject: [PATCH] feat: import `CalledProcessError` for users of `run_command` chore: fix typing of cmd_args --- pyaptly/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyaptly/util.py b/pyaptly/util.py index af6f086..64a041a 100644 --- a/pyaptly/util.py +++ b/pyaptly/util.py @@ -3,8 +3,8 @@ import logging import subprocess from pathlib import Path -from subprocess import DEVNULL, PIPE # noqa: F401 -from typing import Optional, Union +from subprocess import DEVNULL, PIPE, CalledProcessError # noqa: F401 +from typing import Optional, Sequence _DEFAULT_KEYSERVER: str = "hkps://keys.openpgp.org" _PYTEST_KEYSERVER: Optional[str] = None @@ -51,7 +51,7 @@ def is_debug_mode(): return _DEBUG or _PYTEST_DEBUG -def run_command(cmd_args: list[Union[str, Path]], *, decode: bool = True, **kwargs): +def run_command(cmd_args: Sequence[str | Path], *, decode: bool = True, **kwargs): """Instrumented subprocess.run for easier debugging. By default this run command will add `encoding="UTF-8"` to kwargs. Disable @@ -83,7 +83,7 @@ def run_command(cmd_args: list[Union[str, Path]], *, decode: bool = True, **kwar return result -def indent_out(output: Union[bytes, str]) -> str: +def indent_out(output: bytes | str) -> str: """Indent command output for nicer logging-messages. It will convert bytes to strings if need or display the result as bytes if