From 54d4b4e2d241eaaf2ff8b65286ee240f449bfd29 Mon Sep 17 00:00:00 2001 From: Ivan Yordanov Date: Wed, 27 Sep 2023 01:46:59 +0300 Subject: [PATCH] chore(ruff-pylint): manually fix code flagged by "PL" --- hooks/gen_docs/gen_docs_cli_usage.py | 2 +- kpops/component_handlers/helm_wrapper/helm.py | 1 + kpops/utils/dict_differ.py | 6 +++--- kpops/utils/dict_ops.py | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hooks/gen_docs/gen_docs_cli_usage.py b/hooks/gen_docs/gen_docs_cli_usage.py index f03c4fd62..469274745 100644 --- a/hooks/gen_docs/gen_docs_cli_usage.py +++ b/hooks/gen_docs/gen_docs_cli_usage.py @@ -21,7 +21,7 @@ "--output", str(PATH_CLI_COMMANDS_DOC), ] - subprocess.run(typer_args) + subprocess.run(typer_args, check=True, capture_output=True) # Replace wrong title in CLI Usage doc with PATH_CLI_COMMANDS_DOC.open("r") as f: diff --git a/kpops/component_handlers/helm_wrapper/helm.py b/kpops/component_handlers/helm_wrapper/helm.py index 821e26649..bc75011eb 100644 --- a/kpops/component_handlers/helm_wrapper/helm.py +++ b/kpops/component_handlers/helm_wrapper/helm.py @@ -214,6 +214,7 @@ def __execute(self, command: list[str]) -> str: log.debug(f"Executing {' '.join(command)}") process = subprocess.run( command, + check=True, capture_output=True, text=True, ) diff --git a/kpops/utils/dict_differ.py b/kpops/utils/dict_differ.py index 005cd1e71..b5760ed33 100644 --- a/kpops/utils/dict_differ.py +++ b/kpops/utils/dict_differ.py @@ -55,9 +55,9 @@ def from_dicts( d1: dict, d2: dict, ignore: set[str] | None = None, ) -> Iterator[Diff]: for diff_type, keys, changes in diff(d1, d2, ignore=ignore): - if not isinstance(changes, list): - changes = [("", changes)] - for key, change in changes: + if not isinstance(changes_tmp:=changes, list): + changes_tmp = [("", changes)] + for key, change in changes_tmp: yield Diff( DiffType.from_str(diff_type), Diff.__find_changed_key(keys, key), diff --git a/kpops/utils/dict_ops.py b/kpops/utils/dict_ops.py index c52ae8e42..e4adf81cd 100644 --- a/kpops/utils/dict_ops.py +++ b/kpops/utils/dict_ops.py @@ -20,9 +20,8 @@ def update_nested_pair(original_dict: dict, other_dict: Mapping) -> dict: nested_val = original_dict.get(key, {}) if isinstance(nested_val, dict): original_dict[key] = update_nested_pair(nested_val, value) - else: - if key not in original_dict: - original_dict[key] = value + elif key not in original_dict: + original_dict[key] = value return original_dict