From 04457b1272d4b7189accead5a59d948c242649ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 20 Aug 2025 21:58:33 +0200 Subject: [PATCH] ARG001: fix --- .../clan-app/clan_app/deps/webview/webview.py | 2 +- pkgs/clan-cli/clan_cli/clan/show_test.py | 1 - pkgs/clan-cli/clan_cli/completions.py | 48 +++++++++---------- pkgs/clan-cli/clan_cli/facts/generate.py | 2 +- pkgs/clan-cli/clan_cli/flash/list_test.py | 4 +- pkgs/clan-cli/clan_cli/machines/list_test.py | 6 +-- pkgs/clan-cli/clan_cli/secrets/key.py | 2 +- .../clan_cli/tests/fixtures_flakes.py | 2 +- .../clan_cli/tests/test_clan_nix_attrset.py | 1 - .../clan_cli/tests/test_machines_cli.py | 3 +- pkgs/clan-cli/clan_lib/api/mdns_discovery.py | 2 +- pkgs/clan-cli/clan_lib/async_run/__init__.py | 2 +- .../clan_lib/fixtures/flakes/flakes.py | 8 ++-- .../clan_lib/import_utils/__init__.py | 2 +- pkgs/clan-cli/clan_lib/ssh/create_test.py | 2 +- pkgs/clan-cli/clan_lib/tests/test_create.py | 2 +- .../clan_vm_manager/history.py | 2 +- pkgs/clan-vm-manager/tests/test_cli.py | 2 +- pkgs/classgen/main.py | 7 +-- 19 files changed, 46 insertions(+), 54 deletions(-) diff --git a/pkgs/clan-app/clan_app/deps/webview/webview.py b/pkgs/clan-app/clan_app/deps/webview/webview.py index 8208f6f3b..f86f3dd5f 100644 --- a/pkgs/clan-app/clan_app/deps/webview/webview.py +++ b/pkgs/clan-app/clan_app/deps/webview/webview.py @@ -205,7 +205,7 @@ class Webview: ) 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()) try: result = callback(*args) diff --git a/pkgs/clan-cli/clan_cli/clan/show_test.py b/pkgs/clan-cli/clan_cli/clan/show_test.py index deab9667d..ae35a3801 100644 --- a/pkgs/clan-cli/clan_cli/clan/show_test.py +++ b/pkgs/clan-cli/clan_cli/clan/show_test.py @@ -23,7 +23,6 @@ def test_clan_show( def test_clan_show_no_flake( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, - capture_output: CaptureOutput, ) -> None: monkeypatch.chdir(tmp_path) diff --git a/pkgs/clan-cli/clan_cli/completions.py b/pkgs/clan-cli/clan_cli/completions.py index 2f0781874..a135ccf7c 100644 --- a/pkgs/clan-cli/clan_cli/completions.py +++ b/pkgs/clan-cli/clan_cli/completions.py @@ -38,9 +38,9 @@ def clan_dir(flake: str | None) -> str | None: def complete_machines( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for machine names configured in the clan.""" machines: list[str] = [] @@ -72,9 +72,9 @@ def complete_machines( def complete_services_for_machine( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for machine facts generation services.""" services: list[str] = [] @@ -117,9 +117,9 @@ def complete_services_for_machine( def complete_backup_providers_for_machine( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for machine backup providers.""" providers: list[str] = [] @@ -161,9 +161,9 @@ def complete_backup_providers_for_machine( def complete_state_services_for_machine( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for machine state providers.""" providers: list[str] = [] @@ -205,9 +205,9 @@ def complete_state_services_for_machine( def complete_secrets( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for clan secrets""" from clan_lib.flake.flake import Flake @@ -228,9 +228,9 @@ def complete_secrets( def complete_users( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for clan users""" from pathlib import Path @@ -251,9 +251,9 @@ def complete_users( def complete_groups( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for clan groups""" from pathlib import Path @@ -275,9 +275,9 @@ def complete_groups( def complete_templates_disko( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for disko templates""" from clan_lib.templates import list_templates @@ -299,9 +299,9 @@ def complete_templates_disko( def complete_templates_clan( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for clan templates""" from clan_lib.templates import list_templates @@ -323,9 +323,9 @@ def complete_templates_clan( def complete_vars_for_machine( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for variable names for a specific machine. 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( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for target_host for a specific machine""" target_hosts: list[str] = [] @@ -409,9 +409,9 @@ def complete_target_host( def complete_tags( - prefix: str, + _prefix: str, parsed_args: argparse.Namespace, - **kwargs: Any, + **_kwargs: Any, ) -> Iterable[str]: """Provides completion functionality for tags inside the inventory""" tags: list[str] = [] diff --git a/pkgs/clan-cli/clan_cli/facts/generate.py b/pkgs/clan-cli/clan_cli/facts/generate.py index bea29285a..359ec3257 100644 --- a/pkgs/clan-cli/clan_cli/facts/generate.py +++ b/pkgs/clan-cli/clan_cli/facts/generate.py @@ -151,7 +151,7 @@ def generate_service_facts( return True -def prompt_func(service: str, text: str) -> str: +def prompt_func(_service: str, text: str) -> str: print(f"{text}: ") return read_multiline_input() diff --git a/pkgs/clan-cli/clan_cli/flash/list_test.py b/pkgs/clan-cli/clan_cli/flash/list_test.py index 6a62e8c83..31f4e1b6a 100644 --- a/pkgs/clan-cli/clan_cli/flash/list_test.py +++ b/pkgs/clan-cli/clan_cli/flash/list_test.py @@ -8,7 +8,7 @@ from clan_cli.tests.stdout import CaptureOutput @pytest.mark.with_core def test_flash_list_languages( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 capture_output: CaptureOutput, ) -> None: with capture_output as output: @@ -21,7 +21,7 @@ def test_flash_list_languages( @pytest.mark.with_core def test_flash_list_keymaps( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 capture_output: CaptureOutput, ) -> None: with capture_output as output: diff --git a/pkgs/clan-cli/clan_cli/machines/list_test.py b/pkgs/clan-cli/clan_cli/machines/list_test.py index 9785fb268..f4f8dbec7 100644 --- a/pkgs/clan-cli/clan_cli/machines/list_test.py +++ b/pkgs/clan-cli/clan_cli/machines/list_test.py @@ -9,7 +9,7 @@ from clan_cli.tests.stdout import CaptureOutput def list_basic( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 test_flake_with_core: fixtures_flakes.FlakeForTest, capture_output: CaptureOutput, ) -> None: @@ -49,7 +49,7 @@ def list_basic( indirect=True, ) def list_with_tags_single_tag( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 test_flake_with_core: fixtures_flakes.FlakeForTest, capture_output: CaptureOutput, ) -> None: @@ -100,7 +100,7 @@ def list_with_tags_single_tag( indirect=True, ) def list_with_tags_multiple_tags_intersection( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 test_flake_with_core: fixtures_flakes.FlakeForTest, capture_output: CaptureOutput, ) -> None: diff --git a/pkgs/clan-cli/clan_cli/secrets/key.py b/pkgs/clan-cli/clan_cli/secrets/key.py index a9491c5cb..9aa617410 100644 --- a/pkgs/clan-cli/clan_cli/secrets/key.py +++ b/pkgs/clan-cli/clan_cli/secrets/key.py @@ -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() if not keys: msg = "No public key found" diff --git a/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py b/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py index 6198ac25d..48f224159 100644 --- a/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py +++ b/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py @@ -475,7 +475,7 @@ def writable_clan_core( @pytest.fixture def vm_test_flake( - clan_core: Path, + clan_core: Path, # noqa: ARG001 tmp_path: Path, ) -> Path: """Creates a test flake that imports the VM test nixOS modules from clan-core.""" diff --git a/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py b/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py index c7cab612c..10a8089b8 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py +++ b/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py @@ -10,7 +10,6 @@ from clan_lib.templates.filesystem import copy_from_nixstore @pytest.mark.with_core def test_clan_core_templates( test_flake_with_core: FlakeForTest, - monkeypatch: pytest.MonkeyPatch, temporary_home: Path, ) -> None: clan_dir = Flake(str(test_flake_with_core.path)) diff --git a/pkgs/clan-cli/clan_cli/tests/test_machines_cli.py b/pkgs/clan-cli/clan_cli/tests/test_machines_cli.py index 13031ef55..893f146f5 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_machines_cli.py +++ b/pkgs/clan-cli/clan_cli/tests/test_machines_cli.py @@ -67,8 +67,7 @@ def test_machine_subcommands( @pytest.mark.with_core def test_machines_update_with_tags( - test_flake_with_core: fixtures_flakes.FlakeForTest, - capture_output: CaptureOutput, + test_flake_with_core: fixtures_flakes.FlakeForTest, # noqa: ARG001 ) -> None: import argparse diff --git a/pkgs/clan-cli/clan_lib/api/mdns_discovery.py b/pkgs/clan-cli/clan_lib/api/mdns_discovery.py index 7703093c7..803e62a14 100644 --- a/pkgs/clan-cli/clan_lib/api/mdns_discovery.py +++ b/pkgs/clan-cli/clan_lib/api/mdns_discovery.py @@ -112,7 +112,7 @@ def list_system_services_mdns() -> DNSInfo: return data -def mdns_command(args: argparse.Namespace) -> None: +def mdns_command(_args: argparse.Namespace) -> None: dns_info = list_system_services_mdns() for name, info in dns_info.services.items(): print(f"Hostname: {name} - ip: {info.ip}") diff --git a/pkgs/clan-cli/clan_lib/async_run/__init__.py b/pkgs/clan-cli/clan_lib/async_run/__init__.py index 3642abc6c..3d920b02d 100644 --- a/pkgs/clan-cli/clan_lib/async_run/__init__.py +++ b/pkgs/clan-cli/clan_lib/async_run/__init__.py @@ -329,7 +329,7 @@ if __name__ == "__main__": def concatenate(a: str, b: str) -> str: time.sleep(1) - msg = "Hello World" + msg = a + b raise ClanError(msg) with runtime: diff --git a/pkgs/clan-cli/clan_lib/fixtures/flakes/flakes.py b/pkgs/clan-cli/clan_lib/fixtures/flakes/flakes.py index 94c178c5d..e4331665e 100644 --- a/pkgs/clan-cli/clan_lib/fixtures/flakes/flakes.py +++ b/pkgs/clan-cli/clan_lib/fixtures/flakes/flakes.py @@ -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: @contextmanager def fake_clan_template( - flake: Flake, - template_ident: str, + _flake: Flake, + template_ident: str, # noqa: ARG001 dst_dir: Path, - post_process: Callable[[Path], None] | None = None, + post_process: Callable[[Path], None] | None = None, # noqa: ARG001 ) -> Iterator[Path]: # Just yield static destination directory without any processing 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() def clan_flake( tmp_path: Path, - patch_clan_template: Any, + patch_clan_template: Any, # noqa: ARG001 ) -> Callable[[Clan | None, str | None], Flake]: def factory(clan: Clan | None = None, raw: str | None = None) -> Flake: # TODO: Make more options configurable diff --git a/pkgs/clan-cli/clan_lib/import_utils/__init__.py b/pkgs/clan-cli/clan_lib/import_utils/__init__.py index 149717f27..799e8830b 100644 --- a/pkgs/clan-cli/clan_lib/import_utils/__init__.py +++ b/pkgs/clan-cli/clan_lib/import_utils/__init__.py @@ -35,7 +35,7 @@ class ClassSource: def import_with_source[T]( module_name: str, class_name: str, - base_class: type[T], + _base_class: type[T], *args: Any, **kwargs: Any, ) -> T: diff --git a/pkgs/clan-cli/clan_lib/ssh/create_test.py b/pkgs/clan-cli/clan_lib/ssh/create_test.py index 3d76a31f2..d4b93d085 100644 --- a/pkgs/clan-cli/clan_lib/ssh/create_test.py +++ b/pkgs/clan-cli/clan_lib/ssh/create_test.py @@ -3,7 +3,7 @@ from pathlib import Path 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() assert keypair.private.exists() diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index 228fe921c..227ef4fe0 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -107,7 +107,7 @@ def fix_flake_inputs(clan_dir: Path, clan_core_dir: Path) -> None: @pytest.mark.with_core @pytest.mark.skipif(sys.platform == "darwin", reason="sshd fails to start on darwin") def test_clan_create_api( - temporary_home: Path, + temporary_home: Path, # noqa: ARG001 test_lib_root: Path, clan_core: Path, hosts: list[Remote], diff --git a/pkgs/clan-vm-manager/clan_vm_manager/history.py b/pkgs/clan-vm-manager/clan_vm_manager/history.py index 0284cccb2..7bfe70b25 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/history.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/history.py @@ -116,7 +116,7 @@ def add_history_command(args: argparse.Namespace) -> None: 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]] = {} for history_entry in list_history(): url = str(history_entry.flake.flake_url) diff --git a/pkgs/clan-vm-manager/tests/test_cli.py b/pkgs/clan-vm-manager/tests/test_cli.py index 654fa82a2..bcf2fab2e 100644 --- a/pkgs/clan-vm-manager/tests/test_cli.py +++ b/pkgs/clan-vm-manager/tests/test_cli.py @@ -2,7 +2,7 @@ import pytest from cli import Cli -def test_help(capfd: pytest.CaptureFixture) -> None: +def test_help() -> None: cli = Cli() with pytest.raises(SystemExit): cli.run(["clan-vm-manager", "--help"]) diff --git a/pkgs/classgen/main.py b/pkgs/classgen/main.py index 828299f43..db6cb96e6 100644 --- a/pkgs/classgen/main.py +++ b/pkgs/classgen/main.py @@ -214,7 +214,6 @@ def field_def_from_default_value( def get_field_def( field_name: str, - field_meta: str | None, field_types: list[str], default: 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}" raise Error(msg) - field_meta = None - if field_name != prop: - field_meta = f"""{{"alias": "{prop}"}}""" - - finalize_field = partial(get_field_def, field_name, field_meta) + finalize_field = partial(get_field_def, field_name) # Sort and remove potential duplicates field_types_sorted = sort_types(set(field_types))