diff --git a/nixosModules/clanCore/zerotier/generate.py b/nixosModules/clanCore/zerotier/generate.py index 1df7ea168..d7678d587 100644 --- a/nixosModules/clanCore/zerotier/generate.py +++ b/nixosModules/clanCore/zerotier/generate.py @@ -167,7 +167,7 @@ def create_identity() -> Identity: tmpdir = Path(d) private = tmpdir / "identity.secret" public = tmpdir / "identity.public" - subprocess.run(["zerotier-idtool", "generate", private, public]) + subprocess.run(["zerotier-idtool", "generate", private, public], check=True) return Identity(tmpdir) diff --git a/nixosModules/clanCore/zerotier/genmoon.py b/nixosModules/clanCore/zerotier/genmoon.py index 4f48a90aa..b440d4c3e 100644 --- a/nixosModules/clanCore/zerotier/genmoon.py +++ b/nixosModules/clanCore/zerotier/genmoon.py @@ -24,7 +24,7 @@ def main() -> None: f.write(json.dumps(moon_json)) f.flush() Path(moons_d).mkdir(parents=True, exist_ok=True) - subprocess.run(["zerotier-idtool", "genmoon", f.name], cwd=moons_d) + subprocess.run(["zerotier-idtool", "genmoon", f.name], cwd=moons_d, check=True) if __name__ == "__main__": diff --git a/pkgs/clan-cli/clan_cli/facts/cli.py b/pkgs/clan-cli/clan_cli/facts/cli.py index 836a4326d..9009da79d 100644 --- a/pkgs/clan-cli/clan_cli/facts/cli.py +++ b/pkgs/clan-cli/clan_cli/facts/cli.py @@ -60,7 +60,7 @@ Examples: $ clan facts list [MACHINE] Will list facts for the specified machine. - + For more detailed information, visit: {help_hyperlink("secrets", "https://docs.clan.lol/getting-started/secrets")} """ ), @@ -89,7 +89,7 @@ Examples: $ clan facts generate Will generate facts for all machines. - + $ clan facts generate [MACHINE] Will generate facts for the specified machine. @@ -124,7 +124,7 @@ Examples: $ clan facts upload [MACHINE] Will upload secrets to a specific machine. - + For more detailed information, visit: {help_hyperlink("secrets", "https://docs.clan.lol/getting-started/secrets")} """ ), diff --git a/pkgs/clan-cli/clan_cli/facts/generate.py b/pkgs/clan-cli/clan_cli/facts/generate.py index d16d2df10..b2ba5b6e5 100644 --- a/pkgs/clan-cli/clan_cli/facts/generate.py +++ b/pkgs/clan-cli/clan_cli/facts/generate.py @@ -32,7 +32,7 @@ def read_multiline_input(prompt: str = "Finish with Ctrl-D") -> str: Read multi-line input from stdin. """ print(prompt, flush=True) - proc = subprocess.run(["cat"], stdout=subprocess.PIPE, text=True) + proc = subprocess.run(["cat"], stdout=subprocess.PIPE, text=True, check=False) log.info("Input received. Processing...") return proc.stdout diff --git a/pkgs/clan-cli/clan_cli/facts/secret_modules/password_store.py b/pkgs/clan-cli/clan_cli/facts/secret_modules/password_store.py index 06f03fc51..f99543b46 100644 --- a/pkgs/clan-cli/clan_cli/facts/secret_modules/password_store.py +++ b/pkgs/clan-cli/clan_cli/facts/secret_modules/password_store.py @@ -62,6 +62,7 @@ class SecretStore(SecretStoreBase): ], ), stdout=subprocess.PIPE, + check=False, ).stdout.strip() ) for symlink in Path(password_store).glob(f"machines/{self.machine.name}/**/*"): @@ -81,6 +82,7 @@ class SecretStore(SecretStoreBase): ], ), stdout=subprocess.PIPE, + check=False, ).stdout.strip() ) diff --git a/pkgs/clan-cli/clan_cli/profiler.py b/pkgs/clan-cli/clan_cli/profiler.py index 1ef9f9eac..c36b316d9 100644 --- a/pkgs/clan-cli/clan_cli/profiler.py +++ b/pkgs/clan-cli/clan_cli/profiler.py @@ -15,14 +15,14 @@ cProfile Output Columns Explanation: - ncalls: The number of calls to the function. This includes both direct and indirect (recursive) calls. -- tottime: The total time spent in the given function alone, excluding time spent in calls to sub-functions. +- tottime: The total time spent in the given function alone, excluding time spent in calls to sub-functions. This measures the function's own overhead and execution time. - percall (first instance): Represents the average time spent in the function per call, calculated as tottime divided by ncalls. This value excludes time spent in sub-function calls, focusing on the function's own processing time. -- cumtime: The cumulative time spent in this function and all the sub-functions it calls (both directly and indirectly). - This includes all execution time within the function, from the start of its invocation to its return, +- cumtime: The cumulative time spent in this function and all the sub-functions it calls (both directly and indirectly). + This includes all execution time within the function, from the start of its invocation to its return, including all calls to other functions and the time those calls take. - percall (second instance): Represents the average time per call, including time spent in this function and in all sub-function calls. diff --git a/pkgs/clan-cli/clan_cli/ssh/cli.py b/pkgs/clan-cli/clan_cli/ssh/cli.py index d017a85bf..b01b4e253 100644 --- a/pkgs/clan-cli/clan_cli/ssh/cli.py +++ b/pkgs/clan-cli/clan_cli/ssh/cli.py @@ -51,7 +51,7 @@ def ssh( cmd_args.insert(0, "torify") cmd = nix_shell(packages, cmd_args) - subprocess.run(cmd) + subprocess.run(cmd, check=True) def qrcode_scan(picture_file: str) -> str: diff --git a/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py b/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py index 158d1c59f..e1c6630e0 100644 --- a/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py +++ b/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py @@ -88,6 +88,7 @@ class SecretStore(SecretStoreBase): ], ), stdout=subprocess.PIPE, + check=False, ).stdout.strip() ) shared_dir = Path(self._password_store_dir) / self.entry_prefix / "shared" @@ -114,6 +115,7 @@ class SecretStore(SecretStoreBase): ], ), stdout=subprocess.PIPE, + check=False, ).stdout.strip() ) diff --git a/pkgs/clan-cli/tests/fixtures_flakes.py b/pkgs/clan-cli/tests/fixtures_flakes.py index 02547afe0..e9d37bf91 100644 --- a/pkgs/clan-cli/tests/fixtures_flakes.py +++ b/pkgs/clan-cli/tests/fixtures_flakes.py @@ -243,6 +243,7 @@ def test_flake( ["git", "diff", "--exit-code", "./sops"], cwd=temporary_home / "test_flake", stderr=sp.PIPE, + check=False, ) if git_proc.returncode != 0: log.error(git_proc.stderr.decode()) diff --git a/pkgs/clan-cli/tests/helpers/validator.py b/pkgs/clan-cli/tests/helpers/validator.py index 18d12ae08..fefb2e413 100644 --- a/pkgs/clan-cli/tests/helpers/validator.py +++ b/pkgs/clan-cli/tests/helpers/validator.py @@ -9,7 +9,11 @@ class Error(Exception): def is_valid_age_key(secret_key: str) -> bool: # Run the age-keygen command with the -y flag to check the key format result = subprocess.run( - ["age-keygen", "-y"], input=secret_key, capture_output=True, text=True + ["age-keygen", "-y"], + input=secret_key, + capture_output=True, + text=True, + check=False, ) if result.returncode == 0: @@ -25,7 +29,10 @@ def is_valid_ssh_key(secret_key: str, ssh_pub: str) -> bool: temp.flush() # Run the ssh-keygen command with the -y flag to check the key format result = subprocess.run( - ["ssh-keygen", "-y", "-f", temp.name], capture_output=True, text=True + ["ssh-keygen", "-y", "-f", temp.name], + capture_output=True, + text=True, + check=False, ) if result.returncode == 0: diff --git a/pkgs/clan-cli/tests/sshd.py b/pkgs/clan-cli/tests/sshd.py index e14c0f89a..8abdee422 100644 --- a/pkgs/clan-cli/tests/sshd.py +++ b/pkgs/clan-cli/tests/sshd.py @@ -126,6 +126,7 @@ def sshd( str(port), "true", ], + check=False, ).returncode == 0 ): diff --git a/pkgs/clan-cli/tests/test_git.py b/pkgs/clan-cli/tests/test_git.py index 33266292f..1990cc0b0 100644 --- a/pkgs/clan-cli/tests/test_git.py +++ b/pkgs/clan-cli/tests/test_git.py @@ -46,8 +46,8 @@ def test_clan_flake_in_subdir(git_repo: Path, monkeypatch: pytest.MonkeyPatch) - # change to the clan_flake subdirectory monkeypatch.chdir(git_repo / "clan_flake") # commit files to git - subprocess.run(["git", "add", "."], cwd=git_repo) - subprocess.run(["git", "commit", "-m", "init"], cwd=git_repo) + subprocess.run(["git", "add", "."], cwd=git_repo, check=True) + subprocess.run(["git", "commit", "-m", "init"], cwd=git_repo, check=True) # add a new file under ./clan_flake (git_repo / "clan_flake" / "test.txt").touch() # commit the file diff --git a/pkgs/merge-after-ci/merge-after-ci.py b/pkgs/merge-after-ci/merge-after-ci.py index 1aa262c43..7b920a3b4 100755 --- a/pkgs/merge-after-ci/merge-after-ci.py +++ b/pkgs/merge-after-ci/merge-after-ci.py @@ -25,4 +25,4 @@ cmd = [ print("Running:", shlex.join(cmd)) -subprocess.run(cmd) +subprocess.run(cmd, check=True) diff --git a/pkgs/scripts/select-shell.py b/pkgs/scripts/select-shell.py index 4360d680b..33a8723d8 100644 --- a/pkgs/scripts/select-shell.py +++ b/pkgs/scripts/select-shell.py @@ -45,6 +45,7 @@ def list_devshells() -> list[str]: f"{project_root}#devShells.x86_64-linux", ], stdout=subprocess.PIPE, + check=True, ) names = json.loads(flake_show.stdout.decode()) return names diff --git a/pyproject.toml b/pyproject.toml index 6f0ae4a1d..f2a66548c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ lint.select = [ "TID", "TRY", "U", + "W", "YTT", ] lint.ignore = [