From 81264a3b6c1e2beddfd5f1326273edfc73235a5e Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 27 Oct 2024 17:49:06 +0100 Subject: [PATCH] Code quality --- secret_loader/__init__.py | 7 +++++-- test/test_init.py | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/secret_loader/__init__.py b/secret_loader/__init__.py index d00a31e..310999b 100644 --- a/secret_loader/__init__.py +++ b/secret_loader/__init__.py @@ -206,11 +206,14 @@ class SecretLoader: ) return self._convert_pass_process_result_to_password( - process.returncode, process.stdout + process.returncode, + process.stdout, ) def _convert_pass_process_result_to_password( - self, returncode: int, stdout: bytes + self, + returncode: int, + stdout: bytes, ) -> str | None: if returncode != 0: return None diff --git a/test/test_init.py b/test/test_init.py index d3f563f..655917f 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -1,6 +1,7 @@ -import secret_loader import pytest +import secret_loader + def test_hardcoded(): loader = secret_loader.SecretLoader(ENV_KEY_PREFIX='TEST', KEY='VALUE') @@ -37,10 +38,12 @@ def test_fail_hardcoded_prefix_with_trailing_underscore(): def test_lookup_unknown_or_fail(): loader = secret_loader.SecretLoader( - ENV_KEY_PREFIX='TEST', PASS_STORE_SUBFOLDER='test' + ENV_KEY_PREFIX='TEST', + PASS_STORE_SUBFOLDER='test', # noqa: S106 ) with pytest.raises( - ValueError, match='Failed to load secret with key:.*UNKNOWN.*' + ValueError, + match='Failed to load secret with key:.*UNKNOWN.*', ) as e: assert loader.load_or_fail('UNKNOWN') @@ -51,8 +54,8 @@ def test_lookup_unknown_or_fail(): def test_convert_process(): loader = secret_loader.SecretLoader() - assert loader._convert_pass_process_result_to_password(1, b'') is None + assert loader._convert_pass_process_result_to_password(1, b'') is None # noqa: SLF001 assert ( - loader._convert_pass_process_result_to_password(0, b'Hello\nWorld') == 'Hello' + loader._convert_pass_process_result_to_password(0, b'Hello\nWorld') == 'Hello' # noqa: SLF001 ) - assert loader._convert_pass_process_result_to_password(0, b'') == '' + assert loader._convert_pass_process_result_to_password(0, b'') == '' # noqa: SLF001