ARG001: fix

This commit is contained in:
Jörg Thalheim
2025-08-20 21:58:33 +02:00
parent 4986fe30c3
commit 04457b1272
19 changed files with 46 additions and 54 deletions

View File

@@ -205,7 +205,7 @@ class Webview:
) )
def bind(self, name: str, callback: Callable[..., Any]) -> None: def bind(self, name: str, callback: Callable[..., Any]) -> None:
def wrapper(seq: bytes, req: bytes, arg: int) -> None: def wrapper(seq: bytes, req: bytes, _arg: int) -> None:
args = json.loads(req.decode()) args = json.loads(req.decode())
try: try:
result = callback(*args) result = callback(*args)

View File

@@ -23,7 +23,6 @@ def test_clan_show(
def test_clan_show_no_flake( def test_clan_show_no_flake(
tmp_path: Path, tmp_path: Path,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
capture_output: CaptureOutput,
) -> None: ) -> None:
monkeypatch.chdir(tmp_path) monkeypatch.chdir(tmp_path)

View File

@@ -38,9 +38,9 @@ def clan_dir(flake: str | None) -> str | None:
def complete_machines( def complete_machines(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for machine names configured in the clan.""" """Provides completion functionality for machine names configured in the clan."""
machines: list[str] = [] machines: list[str] = []
@@ -72,9 +72,9 @@ def complete_machines(
def complete_services_for_machine( def complete_services_for_machine(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for machine facts generation services.""" """Provides completion functionality for machine facts generation services."""
services: list[str] = [] services: list[str] = []
@@ -117,9 +117,9 @@ def complete_services_for_machine(
def complete_backup_providers_for_machine( def complete_backup_providers_for_machine(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for machine backup providers.""" """Provides completion functionality for machine backup providers."""
providers: list[str] = [] providers: list[str] = []
@@ -161,9 +161,9 @@ def complete_backup_providers_for_machine(
def complete_state_services_for_machine( def complete_state_services_for_machine(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for machine state providers.""" """Provides completion functionality for machine state providers."""
providers: list[str] = [] providers: list[str] = []
@@ -205,9 +205,9 @@ def complete_state_services_for_machine(
def complete_secrets( def complete_secrets(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for clan secrets""" """Provides completion functionality for clan secrets"""
from clan_lib.flake.flake import Flake from clan_lib.flake.flake import Flake
@@ -228,9 +228,9 @@ def complete_secrets(
def complete_users( def complete_users(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for clan users""" """Provides completion functionality for clan users"""
from pathlib import Path from pathlib import Path
@@ -251,9 +251,9 @@ def complete_users(
def complete_groups( def complete_groups(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for clan groups""" """Provides completion functionality for clan groups"""
from pathlib import Path from pathlib import Path
@@ -275,9 +275,9 @@ def complete_groups(
def complete_templates_disko( def complete_templates_disko(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for disko templates""" """Provides completion functionality for disko templates"""
from clan_lib.templates import list_templates from clan_lib.templates import list_templates
@@ -299,9 +299,9 @@ def complete_templates_disko(
def complete_templates_clan( def complete_templates_clan(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for clan templates""" """Provides completion functionality for clan templates"""
from clan_lib.templates import list_templates from clan_lib.templates import list_templates
@@ -323,9 +323,9 @@ def complete_templates_clan(
def complete_vars_for_machine( def complete_vars_for_machine(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for variable names for a specific machine. """Provides completion functionality for variable names for a specific machine.
Only completes vars that already exist in the vars directory on disk. Only completes vars that already exist in the vars directory on disk.
@@ -367,9 +367,9 @@ def complete_vars_for_machine(
def complete_target_host( def complete_target_host(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for target_host for a specific machine""" """Provides completion functionality for target_host for a specific machine"""
target_hosts: list[str] = [] target_hosts: list[str] = []
@@ -409,9 +409,9 @@ def complete_target_host(
def complete_tags( def complete_tags(
prefix: str, _prefix: str,
parsed_args: argparse.Namespace, parsed_args: argparse.Namespace,
**kwargs: Any, **_kwargs: Any,
) -> Iterable[str]: ) -> Iterable[str]:
"""Provides completion functionality for tags inside the inventory""" """Provides completion functionality for tags inside the inventory"""
tags: list[str] = [] tags: list[str] = []

View File

@@ -151,7 +151,7 @@ def generate_service_facts(
return True return True
def prompt_func(service: str, text: str) -> str: def prompt_func(_service: str, text: str) -> str:
print(f"{text}: ") print(f"{text}: ")
return read_multiline_input() return read_multiline_input()

View File

@@ -8,7 +8,7 @@ from clan_cli.tests.stdout import CaptureOutput
@pytest.mark.with_core @pytest.mark.with_core
def test_flash_list_languages( def test_flash_list_languages(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
capture_output: CaptureOutput, capture_output: CaptureOutput,
) -> None: ) -> None:
with capture_output as output: with capture_output as output:
@@ -21,7 +21,7 @@ def test_flash_list_languages(
@pytest.mark.with_core @pytest.mark.with_core
def test_flash_list_keymaps( def test_flash_list_keymaps(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
capture_output: CaptureOutput, capture_output: CaptureOutput,
) -> None: ) -> None:
with capture_output as output: with capture_output as output:

View File

@@ -9,7 +9,7 @@ from clan_cli.tests.stdout import CaptureOutput
def list_basic( def list_basic(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
test_flake_with_core: fixtures_flakes.FlakeForTest, test_flake_with_core: fixtures_flakes.FlakeForTest,
capture_output: CaptureOutput, capture_output: CaptureOutput,
) -> None: ) -> None:
@@ -49,7 +49,7 @@ def list_basic(
indirect=True, indirect=True,
) )
def list_with_tags_single_tag( def list_with_tags_single_tag(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
test_flake_with_core: fixtures_flakes.FlakeForTest, test_flake_with_core: fixtures_flakes.FlakeForTest,
capture_output: CaptureOutput, capture_output: CaptureOutput,
) -> None: ) -> None:
@@ -100,7 +100,7 @@ def list_with_tags_single_tag(
indirect=True, indirect=True,
) )
def list_with_tags_multiple_tags_intersection( def list_with_tags_multiple_tags_intersection(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
test_flake_with_core: fixtures_flakes.FlakeForTest, test_flake_with_core: fixtures_flakes.FlakeForTest,
capture_output: CaptureOutput, capture_output: CaptureOutput,
) -> None: ) -> None:

View File

@@ -59,7 +59,7 @@ def generate_command(args: argparse.Namespace) -> None:
) )
def show_command(args: argparse.Namespace) -> None: def show_command(_args: argparse.Namespace) -> None:
keys = sops.maybe_get_admin_public_keys() keys = sops.maybe_get_admin_public_keys()
if not keys: if not keys:
msg = "No public key found" msg = "No public key found"

View File

@@ -475,7 +475,7 @@ def writable_clan_core(
@pytest.fixture @pytest.fixture
def vm_test_flake( def vm_test_flake(
clan_core: Path, clan_core: Path, # noqa: ARG001
tmp_path: Path, tmp_path: Path,
) -> Path: ) -> Path:
"""Creates a test flake that imports the VM test nixOS modules from clan-core.""" """Creates a test flake that imports the VM test nixOS modules from clan-core."""

View File

@@ -10,7 +10,6 @@ from clan_lib.templates.filesystem import copy_from_nixstore
@pytest.mark.with_core @pytest.mark.with_core
def test_clan_core_templates( def test_clan_core_templates(
test_flake_with_core: FlakeForTest, test_flake_with_core: FlakeForTest,
monkeypatch: pytest.MonkeyPatch,
temporary_home: Path, temporary_home: Path,
) -> None: ) -> None:
clan_dir = Flake(str(test_flake_with_core.path)) clan_dir = Flake(str(test_flake_with_core.path))

View File

@@ -67,8 +67,7 @@ def test_machine_subcommands(
@pytest.mark.with_core @pytest.mark.with_core
def test_machines_update_with_tags( def test_machines_update_with_tags(
test_flake_with_core: fixtures_flakes.FlakeForTest, test_flake_with_core: fixtures_flakes.FlakeForTest, # noqa: ARG001
capture_output: CaptureOutput,
) -> None: ) -> None:
import argparse import argparse

View File

@@ -112,7 +112,7 @@ def list_system_services_mdns() -> DNSInfo:
return data return data
def mdns_command(args: argparse.Namespace) -> None: def mdns_command(_args: argparse.Namespace) -> None:
dns_info = list_system_services_mdns() dns_info = list_system_services_mdns()
for name, info in dns_info.services.items(): for name, info in dns_info.services.items():
print(f"Hostname: {name} - ip: {info.ip}") print(f"Hostname: {name} - ip: {info.ip}")

View File

@@ -329,7 +329,7 @@ if __name__ == "__main__":
def concatenate(a: str, b: str) -> str: def concatenate(a: str, b: str) -> str:
time.sleep(1) time.sleep(1)
msg = "Hello World" msg = a + b
raise ClanError(msg) raise ClanError(msg)
with runtime: with runtime:

View File

@@ -39,10 +39,10 @@ def offline_template(tmp_path_factory: Any, offline_session_flake_hook: Any) ->
def patch_clan_template(monkeypatch: Any, offline_template: Path) -> None: def patch_clan_template(monkeypatch: Any, offline_template: Path) -> None:
@contextmanager @contextmanager
def fake_clan_template( def fake_clan_template(
flake: Flake, _flake: Flake,
template_ident: str, template_ident: str, # noqa: ARG001
dst_dir: Path, dst_dir: Path,
post_process: Callable[[Path], None] | None = None, post_process: Callable[[Path], None] | None = None, # noqa: ARG001
) -> Iterator[Path]: ) -> Iterator[Path]:
# Just yield static destination directory without any processing # Just yield static destination directory without any processing
shutil.copytree(offline_template, dst_dir, dirs_exist_ok=True, symlinks=True) shutil.copytree(offline_template, dst_dir, dirs_exist_ok=True, symlinks=True)
@@ -54,7 +54,7 @@ def patch_clan_template(monkeypatch: Any, offline_template: Path) -> None:
@pytest.fixture() @pytest.fixture()
def clan_flake( def clan_flake(
tmp_path: Path, tmp_path: Path,
patch_clan_template: Any, patch_clan_template: Any, # noqa: ARG001
) -> Callable[[Clan | None, str | None], Flake]: ) -> Callable[[Clan | None, str | None], Flake]:
def factory(clan: Clan | None = None, raw: str | None = None) -> Flake: def factory(clan: Clan | None = None, raw: str | None = None) -> Flake:
# TODO: Make more options configurable # TODO: Make more options configurable

View File

@@ -35,7 +35,7 @@ class ClassSource:
def import_with_source[T]( def import_with_source[T](
module_name: str, module_name: str,
class_name: str, class_name: str,
base_class: type[T], _base_class: type[T],
*args: Any, *args: Any,
**kwargs: Any, **kwargs: Any,
) -> T: ) -> T:

View File

@@ -3,7 +3,7 @@ from pathlib import Path
from clan_lib.ssh.create import create_secret_key_nixos_anywhere from clan_lib.ssh.create import create_secret_key_nixos_anywhere
def test_clan_generate_sshkeys(temporary_home: Path) -> None: def test_clan_generate_sshkeys(temporary_home: Path) -> None: # noqa: ARG001
keypair = create_secret_key_nixos_anywhere() keypair = create_secret_key_nixos_anywhere()
assert keypair.private.exists() assert keypair.private.exists()

View File

@@ -107,7 +107,7 @@ def fix_flake_inputs(clan_dir: Path, clan_core_dir: Path) -> None:
@pytest.mark.with_core @pytest.mark.with_core
@pytest.mark.skipif(sys.platform == "darwin", reason="sshd fails to start on darwin") @pytest.mark.skipif(sys.platform == "darwin", reason="sshd fails to start on darwin")
def test_clan_create_api( def test_clan_create_api(
temporary_home: Path, temporary_home: Path, # noqa: ARG001
test_lib_root: Path, test_lib_root: Path,
clan_core: Path, clan_core: Path,
hosts: list[Remote], hosts: list[Remote],

View File

@@ -116,7 +116,7 @@ def add_history_command(args: argparse.Namespace) -> None:
add_history(args.uri) add_history(args.uri)
def list_history_command(args: argparse.Namespace) -> None: def list_history_command(_args: argparse.Namespace) -> None:
res: dict[str, list[HistoryEntry]] = {} res: dict[str, list[HistoryEntry]] = {}
for history_entry in list_history(): for history_entry in list_history():
url = str(history_entry.flake.flake_url) url = str(history_entry.flake.flake_url)

View File

@@ -2,7 +2,7 @@ import pytest
from cli import Cli from cli import Cli
def test_help(capfd: pytest.CaptureFixture) -> None: def test_help() -> None:
cli = Cli() cli = Cli()
with pytest.raises(SystemExit): with pytest.raises(SystemExit):
cli.run(["clan-vm-manager", "--help"]) cli.run(["clan-vm-manager", "--help"])

View File

@@ -214,7 +214,6 @@ def field_def_from_default_value(
def get_field_def( def get_field_def(
field_name: str, field_name: str,
field_meta: str | None,
field_types: list[str], field_types: list[str],
default: str | None = None, default: str | None = None,
default_factory: str | None = None, default_factory: str | None = None,
@@ -332,11 +331,7 @@ def generate_dataclass(
msg = f"Python type not found for {prop} {prop_info}" msg = f"Python type not found for {prop} {prop_info}"
raise Error(msg) raise Error(msg)
field_meta = None finalize_field = partial(get_field_def, field_name)
if field_name != prop:
field_meta = f"""{{"alias": "{prop}"}}"""
finalize_field = partial(get_field_def, field_name, field_meta)
# Sort and remove potential duplicates # Sort and remove potential duplicates
field_types_sorted = sort_types(set(field_types)) field_types_sorted = sort_types(set(field_types))