ruff: enable warning lints

This commit is contained in:
Jörg Thalheim
2024-10-23 10:20:43 +02:00
committed by Mic92
parent 4c4d4d07f0
commit 4230ae6750
15 changed files with 30 additions and 15 deletions

View File

@@ -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)

View File

@@ -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__":

View File

@@ -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

View File

@@ -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()
)

View File

@@ -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:

View File

@@ -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()
)

View File

@@ -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())

View File

@@ -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:

View File

@@ -126,6 +126,7 @@ def sshd(
str(port),
"true",
],
check=False,
).returncode
== 0
):

View File

@@ -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

View File

@@ -25,4 +25,4 @@ cmd = [
print("Running:", shlex.join(cmd))
subprocess.run(cmd)
subprocess.run(cmd, check=True)

View File

@@ -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

View File

@@ -41,6 +41,7 @@ lint.select = [
"TID",
"TRY",
"U",
"W",
"YTT",
]
lint.ignore = [