From e8ccb262a612b645fb965bc3217b102ad404f467 Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 29 Jun 2023 16:13:14 -0600 Subject: [PATCH] Fix pre-commit --- salt/modules/chocolatey.py | 16 +++++++--------- tests/pytests/unit/modules/test_chocolatey.py | 4 +--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/salt/modules/chocolatey.py b/salt/modules/chocolatey.py index dc3dd62f651..06794946d55 100644 --- a/salt/modules/chocolatey.py +++ b/salt/modules/chocolatey.py @@ -111,9 +111,7 @@ def _find_chocolatey(): os.path.join( os.environ.get("ProgramData"), "Chocolatey", "bin", "chocolatey.exe" ), - os.path.join( - os.environ.get("ProgramData"), "Chocolatey", "bin", "choco.exe" - ), + os.path.join(os.environ.get("ProgramData"), "Chocolatey", "bin", "choco.exe"), os.path.join( os.environ.get("SystemDrive"), "Chocolatey", "bin", "chocolatey.bat" ), @@ -210,7 +208,7 @@ def bootstrap(force=False, source=None): except CommandExecutionError: choc_path = None if choc_path and not force: - return "Chocolatey found at {}".format(choc_path) + return f"Chocolatey found at {choc_path}" temp_dir = tempfile.gettempdir() @@ -338,7 +336,7 @@ def bootstrap(force=False, source=None): if not os.path.exists(script): raise CommandExecutionError( - "Failed to find Chocolatey installation script: {}".format(script) + f"Failed to find Chocolatey installation script: {script}" ) # Run the Chocolatey bootstrap @@ -380,7 +378,7 @@ def unbootstrap(): if os.path.exists(choco_dir): log.debug("Removing Chocolatey directory: %s", choco_dir) __salt__["file.remove"](path=choco_dir, force=True) - removed.append("Removed Directory: {}".format(choco_dir)) + removed.append(f"Removed Directory: {choco_dir}") else: known_paths = [ os.path.join(os.environ.get("ProgramData"), "Chocolatey"), @@ -390,7 +388,7 @@ def unbootstrap(): if os.path.exists(path): log.debug("Removing Chocolatey directory: %s", path) __salt__["file.remove"](path=path, force=True) - removed.append("Removed Directory: {}".format(path)) + removed.append(f"Removed Directory: {path}") # Delete all Chocolatey environment variables for env_var in __salt__["environ.items"](): @@ -402,14 +400,14 @@ def unbootstrap(): __salt__["environ.setval"]( key=env_var, val=False, false_unsets=True, permanent="HKCU" ) - removed.append("Removed Environment Var: {}".format(env_var)) + removed.append(f"Removed Environment Var: {env_var}") # Remove Chocolatey from the path: for path in __salt__["win_path.get_path"](): if "chocolatey" in path.lower(): log.debug("Removing Chocolatey path item: %s", path) __salt__["win_path.remove"](path=path, rehash=True) - removed.append("Removed Path Item: {}".format(path)) + removed.append(f"Removed Path Item: {path}") return removed diff --git a/tests/pytests/unit/modules/test_chocolatey.py b/tests/pytests/unit/modules/test_chocolatey.py index 2d09185b23f..74c29d36fe8 100644 --- a/tests/pytests/unit/modules/test_chocolatey.py +++ b/tests/pytests/unit/modules/test_chocolatey.py @@ -33,9 +33,7 @@ def chocolatey_path_pd(): @pytest.fixture(scope="module") def choco_path_pd(): - return os.path.join( - os.environ.get("ProgramData"), "Chocolatey", "bin", "choco.exe" - ) + return os.path.join(os.environ.get("ProgramData"), "Chocolatey", "bin", "choco.exe") @pytest.fixture(scope="module")