ARG002/ARG005: fix

This commit is contained in:
Jörg Thalheim
2025-08-20 21:05:11 +02:00
parent 5233eb7fdb
commit 4986fe30c3
31 changed files with 67 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ class AppendOptionAction(argparse.Action):
values: str | Sequence[str] | None,
option_string: str | None = None,
) -> None:
del parser, option_string # Unused but required by argparse API
lst = getattr(namespace, self.dest)
lst.append("--option")
if not values or not hasattr(values, "__getitem__"):

View File

@@ -12,6 +12,7 @@ class FactStore(FactStoreBase):
self.works_remotely = False
def set(self, service: str, name: str, value: bytes) -> Path | None:
del service # Unused but kept for API compatibility
if self.machine.flake.is_local:
fact_path = (
self.machine.flake.path
@@ -28,6 +29,7 @@ class FactStore(FactStoreBase):
raise ClanError(msg)
def exists(self, service: str, name: str) -> bool:
del service # Unused but kept for API compatibility
fact_path = (
self.machine.flake_dir / "machines" / self.machine.name / "facts" / name
)
@@ -35,6 +37,7 @@ class FactStore(FactStoreBase):
# get a single fact
def get(self, service: str, name: str) -> bytes:
del service # Unused but kept for API compatibility
fact_path = (
self.machine.flake_dir / "machines" / self.machine.name / "facts" / name
)

View File

@@ -34,6 +34,7 @@ class SecretStoreBase(ABC):
pass
def needs_upload(self, host: Host) -> bool:
del host # Unused but kept for API compatibility
return True
@abstractmethod

View File

@@ -22,6 +22,7 @@ class SecretStore(SecretStoreBase):
value: bytes,
groups: list[str],
) -> Path | None:
del service, groups # Unused but kept for API compatibility
subprocess.run(
nix_shell(
["pass"],
@@ -33,6 +34,7 @@ class SecretStore(SecretStoreBase):
return None # we manage the files outside of the git repo
def get(self, service: str, name: str) -> bytes:
del service # Unused but kept for API compatibility
return subprocess.run(
nix_shell(
["pass"],
@@ -43,6 +45,7 @@ class SecretStore(SecretStoreBase):
).stdout
def exists(self, service: str, name: str) -> bool:
del service # Unused but kept for API compatibility
password_store = os.environ.get(
"PASSWORD_STORE_DIR",
f"{os.environ['HOME']}/.password-store",

View File

@@ -43,6 +43,7 @@ class SecretStore(SecretStoreBase):
value: bytes,
groups: list[str],
) -> Path | None:
del service # Unused but kept for API compatibility
path = (
sops_secrets_folder(self.machine.flake_dir) / f"{self.machine.name}-{name}"
)
@@ -57,12 +58,14 @@ class SecretStore(SecretStoreBase):
return path
def get(self, service: str, name: str) -> bytes:
del service # Unused but kept for API compatibility
return decrypt_secret(
sops_secrets_folder(self.machine.flake_dir) / f"{self.machine.name}-{name}",
age_plugins=load_age_plugins(self.machine.flake),
).encode("utf-8")
def exists(self, service: str, name: str) -> bool:
del service # Unused but kept for API compatibility
return has_secret(
sops_secrets_folder(self.machine.flake_dir) / f"{self.machine.name}-{name}",
)

View File

@@ -21,6 +21,7 @@ class SecretStore(SecretStoreBase):
value: bytes,
groups: list[str],
) -> Path | None:
del groups # Unused but kept for API compatibility
secret_file = self.dir / service / name
secret_file.parent.mkdir(parents=True, exist_ok=True)
secret_file.write_bytes(value)

View File

@@ -39,6 +39,7 @@ class AppendDiskAction(argparse.Action):
values: str | Sequence[str] | None, # Updated type hint
option_string: str | None = None,
) -> None:
del parser, option_string # Unused but required by argparse API
# Ensure 'values' is a sequence of two elements
if not (
isinstance(values, Sequence)

View File

@@ -27,6 +27,7 @@ class AppendSetAction(argparse.Action):
values: str | Sequence[str] | None,
option_string: str | None = None,
) -> None:
del parser, option_string # Unused but required by argparse API
lst = getattr(namespace, self.dest)
if not values or not hasattr(values, "__getitem__"):
msg = "values must be indexable"

View File

@@ -94,6 +94,7 @@ class StoreBase(ABC):
str | None: An error message describing issues found, or None if everything is healthy
"""
del machine, generators, file_name # Unused but kept for API compatibility
return None
def fix(
@@ -116,7 +117,7 @@ class StoreBase(ABC):
None
"""
return
del machine, generators, file_name # Unused but kept for API compatibility
def backend_collision_error(self, folder: Path) -> None:
msg = (

View File

@@ -41,6 +41,7 @@ class SecretStore(StoreBase):
return secret_file.read_bytes()
def populate_dir(self, machine: str, output_dir: Path, phases: list[str]) -> None:
del machine, phases # Unused but kept for API compatibility
if output_dir.exists():
shutil.rmtree(output_dir)
shutil.copytree(self.dir, output_dir)
@@ -53,6 +54,7 @@ class SecretStore(StoreBase):
return []
def delete_store(self, machine: str) -> list[Path]:
del machine # Unused but kept for API compatibility
if self.dir.exists():
shutil.rmtree(self.dir)
return []

View File

@@ -66,6 +66,7 @@ class SecretStore(StoreBase):
return [vars_dir]
def populate_dir(self, machine: str, output_dir: Path, phases: list[str]) -> None:
del phases # Unused but kept for API compatibility
vars_dir = self.get_dir(machine)
if output_dir.exists():
shutil.rmtree(output_dir)

View File

@@ -575,6 +575,7 @@ class LogManager:
The LogFile if found, None otherwise.
"""
del group_path # Unused but kept for API compatibility
log_files: list[LogFile] = []
# Recursively search for log files

View File

@@ -811,6 +811,7 @@ class TestLogFileSorting:
configured_log_manager: LogManager,
) -> None:
"""Test that list_log_days returns days sorted newest first."""
del configured_log_manager # Unused but kept for API compatibility
# Create log files on different days by manipulating the date
import tempfile

View File

@@ -128,7 +128,7 @@ def get_machine_fields_schema(machine: Machine) -> dict[str, FieldSchema]:
"""
inventory_store = InventoryStore(machine.flake)
write_info = inventory_store.get_writeability_of(f"machines.{machine.name}")
write_info = inventory_store.get_writeability()
field_names = retrieve_typed_field_names(InventoryMachine)

View File

@@ -215,11 +215,10 @@ class InventoryStore:
return WriteInfo(writeables, data_eval, data_disk)
def get_writeability_of(self, path: str) -> Any:
"""Get the writeability of a path in the inventory
def get_writeability(self) -> Any:
"""Get the writeability of the inventory
:param path: The path to check
:return: A dictionary with the writeability of the path
:return: A dictionary with the writeability of all paths
"""
write_info = self._write_info()
return write_info.writeables

View File

@@ -28,6 +28,7 @@ class MockFlake:
selector: str,
nix_options: list[str] | None = None,
) -> Any:
del nix_options # Unused but kept for API compatibility
nixpkgs = os.environ.get("NIXPKGS")
select = os.environ.get("NIX_SELECT")
clan_core_path = os.environ.get("CLAN_CORE_PATH")

View File

@@ -44,6 +44,7 @@ class LocalHost:
control_master: bool = True,
) -> CmdOut:
"""Run a command locally."""
del tty, verbose_ssh, control_master # Unused but kept for API compatibility
if opts is None:
opts = RunOpts()
@@ -99,6 +100,7 @@ class LocalHost:
control_master: bool = True,
) -> dict[str, str]:
"""LocalHost doesn't need SSH environment variables."""
del control_master # Unused but kept for API compatibility
if env is None:
env = {}
# Don't set NIX_SSHOPTS for localhost