From 9d29cc63ad6ecdc6cc06a4817c03a9f7779d37ee Mon Sep 17 00:00:00 2001 From: Clan Merge Bot Date: Mon, 13 Jan 2025 00:00:49 +0000 Subject: [PATCH 1/3] update flake lock - nixpkgs - 2025-01-13T00:00+00:00 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/4989a246d7a390a859852baddb1013f825435cee?narHash=sha256-kMBQ5PRiFLagltK0sH%2B08aiNt3zGERC2297iB6vrvlU%3D' (2024-12-17) → 'github:NixOS/nixpkgs/2f9e2f85cb14a46410a1399aa9ea7ecf433e422e?narHash=sha256-FWlPMUzp0lkQBdhKlPqtQdqmp%2B/C%2B1MBiEytaYfrCTY%3D' (2025-01-12) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 597c9428c..ddc70e370 100644 --- a/flake.lock +++ b/flake.lock @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734435836, - "narHash": "sha256-kMBQ5PRiFLagltK0sH+08aiNt3zGERC2297iB6vrvlU=", + "lastModified": 1736657626, + "narHash": "sha256-FWlPMUzp0lkQBdhKlPqtQdqmp+/C+1MBiEytaYfrCTY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4989a246d7a390a859852baddb1013f825435cee", + "rev": "2f9e2f85cb14a46410a1399aa9ea7ecf433e422e", "type": "github" }, "original": { From e2aa66d86fc5a691557446275e20060854bf600a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 14 Jan 2025 15:30:29 +0100 Subject: [PATCH 2/3] reformat after update --- checks/lib/container-driver/test_driver/__init__.py | 6 +++--- docs/nix/render_options/__init__.py | 4 ++-- nixosModules/clanCore/zerotier/generate.py | 12 ++++++------ pkgs/clan-app/tests/helpers/cli.py | 2 +- pkgs/clan-cli/clan_cli/api/util.py | 6 +++--- pkgs/clan-cli/clan_cli/clan/show.py | 6 +++--- pkgs/clan-cli/clan_cli/custom_logger.py | 4 +++- pkgs/clan-cli/clan_cli/errors.py | 4 ++-- pkgs/clan-cli/clan_cli/secrets/sops.py | 2 +- .../clan_cli/vars/secret_modules/password_store.py | 2 +- pkgs/clan-cli/clan_cli/vars/secret_modules/sops.py | 2 +- pkgs/clan-cli/clan_cli/vms/qemu.py | 4 ++-- pkgs/clan-cli/clan_cli/vms/waypipe.py | 2 +- pkgs/clan-cli/docs.py | 2 +- pkgs/clan-cli/tests/sshd.py | 6 +++--- pkgs/clan-vm-manager/tests/helpers/cli.py | 2 +- pkgs/zerotier-members/zerotier-members.py | 6 +++--- 17 files changed, 37 insertions(+), 35 deletions(-) diff --git a/checks/lib/container-driver/test_driver/__init__.py b/checks/lib/container-driver/test_driver/__init__.py index e5beebc4b..4a7bd5362 100644 --- a/checks/lib/container-driver/test_driver/__init__.py +++ b/checks/lib/container-driver/test_driver/__init__.py @@ -102,9 +102,9 @@ class Machine: .read_text() .split() ) - assert ( - len(childs) == 1 - ), f"Expected exactly one child process for systemd-nspawn, got {childs}" + assert len(childs) == 1, ( + f"Expected exactly one child process for systemd-nspawn, got {childs}" + ) try: return int(childs[0]) except ValueError as e: diff --git a/docs/nix/render_options/__init__.py b/docs/nix/render_options/__init__.py index 37fa1c5e1..0de75ebb7 100644 --- a/docs/nix/render_options/__init__.py +++ b/docs/nix/render_options/__init__.py @@ -103,7 +103,7 @@ def render_option( read_only = option.get("readOnly") res = f""" -{"#" * level} {sanitize(name) if short_head is None else sanitize(short_head)} {"{: #"+sanitize_anchor(name)+"}" if level > 1 else ""} +{"#" * level} {sanitize(name) if short_head is None else sanitize(short_head)} {"{: #" + sanitize_anchor(name) + "}" if level > 1 else ""} """ @@ -125,7 +125,7 @@ def render_option( **Default**: ```nix -{option.get("default",{}).get("text") if option.get("default") else "No default set."} +{option.get("default", {}).get("text") if option.get("default") else "No default set."} ``` """ example = option.get("example", {}).get("text") diff --git a/nixosModules/clanCore/zerotier/generate.py b/nixosModules/clanCore/zerotier/generate.py index d7678d587..8f6125017 100644 --- a/nixosModules/clanCore/zerotier/generate.py +++ b/nixosModules/clanCore/zerotier/generate.py @@ -55,9 +55,9 @@ class Identity: def node_id(self) -> str: nid = self.public.split(":")[0] - assert ( - len(nid) == 10 - ), f"node_id must be 10 characters long, got {len(nid)}: {nid}" + assert len(nid) == 10, ( + f"node_id must be 10 characters long, got {len(nid)}: {nid}" + ) return nid @@ -172,9 +172,9 @@ def create_identity() -> Identity: def compute_zerotier_ip(network_id: str, identity: Identity) -> ipaddress.IPv6Address: - assert ( - len(network_id) == 16 - ), "network_id must be 16 characters long, got {network_id}" + assert len(network_id) == 16, ( + "network_id must be 16 characters long, got {network_id}" + ) nwid = int(network_id, 16) node_id = int(identity.node_id(), 16) addr_parts = bytearray( diff --git a/pkgs/clan-app/tests/helpers/cli.py b/pkgs/clan-app/tests/helpers/cli.py index de600ac7c..3bd1f5f62 100644 --- a/pkgs/clan-app/tests/helpers/cli.py +++ b/pkgs/clan-app/tests/helpers/cli.py @@ -14,7 +14,7 @@ def print_trace(msg: str) -> None: if "run_no_stdout" in callers[0]: callers = get_callers(3, 3 + trace_depth) - callers_str = "\n".join(f"{i+1}: {caller}" for i, caller in enumerate(callers)) + callers_str = "\n".join(f"{i + 1}: {caller}" for i, caller in enumerate(callers)) log.debug(f"{msg} \nCallers: \n{callers_str}") diff --git a/pkgs/clan-cli/clan_cli/api/util.py b/pkgs/clan-cli/clan_cli/api/util.py index 073a945d2..72f16f543 100644 --- a/pkgs/clan-cli/clan_cli/api/util.py +++ b/pkgs/clan-cli/clan_cli/api/util.py @@ -115,9 +115,9 @@ def type_to_dict( for f in fields: if f.name.startswith("_"): continue - assert not isinstance( - f.type, str - ), f"Expected field type to be a type, got {f.type}, Have you imported `from __future__ import annotations`?" + assert not isinstance(f.type, str), ( + f"Expected field type to be a type, got {f.type}, Have you imported `from __future__ import annotations`?" + ) properties[f.metadata.get("alias", f.name)] = type_to_dict( f.type, f"{scope} {t.__name__}.{f.name}", # type: ignore diff --git a/pkgs/clan-cli/clan_cli/clan/show.py b/pkgs/clan-cli/clan_cli/clan/show.py index b63b4f7f8..d99c180f2 100644 --- a/pkgs/clan-cli/clan_cli/clan/show.py +++ b/pkgs/clan-cli/clan_cli/clan/show.py @@ -75,9 +75,9 @@ def show_command(args: argparse.Namespace) -> None: flake_path = args.flake.path meta = show_clan_meta(flake_path) - print(f"Name: {meta.get("name")}") - print(f"Description: {meta.get("description", '-')}") - print(f"Icon: {meta.get("icon", '-')}") + print(f"Name: {meta.get('name')}") + print(f"Description: {meta.get('description', '-')}") + print(f"Icon: {meta.get('icon', '-')}") def register_parser(parser: argparse.ArgumentParser) -> None: diff --git a/pkgs/clan-cli/clan_cli/custom_logger.py b/pkgs/clan-cli/clan_cli/custom_logger.py index a7a3d2891..beebdcef0 100644 --- a/pkgs/clan-cli/clan_cli/custom_logger.py +++ b/pkgs/clan-cli/clan_cli/custom_logger.py @@ -146,7 +146,9 @@ def print_trace(msg: str, logger: logging.Logger, prefix: str | None) -> None: if len(callers) == 1: callers_str = f"Caller: {callers[0]}\n" else: - callers_str = "\n".join(f"{i+1}: {caller}" for i, caller in enumerate(callers)) + callers_str = "\n".join( + f"{i + 1}: {caller}" for i, caller in enumerate(callers) + ) callers_str = f"Callers:\n{callers_str}" logger.debug(f"{msg} \n{callers_str}", extra={"command_prefix": prefix}) diff --git a/pkgs/clan-cli/clan_cli/errors.py b/pkgs/clan-cli/clan_cli/errors.py index 9b48a6569..31b3a489e 100644 --- a/pkgs/clan-cli/clan_cli/errors.py +++ b/pkgs/clan-cli/clan_cli/errors.py @@ -116,7 +116,7 @@ class CmdOut: {optional_text("Command", self.command)} {optional_text("Stdout", self.stdout)} {optional_text("Stderr", self.stderr)} -{'Return Code:':<{label_width}} {self.returncode} +{"Return Code:":<{label_width}} {self.returncode} """ ] if self.msg: @@ -135,7 +135,7 @@ class CmdOut: f""" {optional_text("Environment", diffed_dict_str)} {text_heading(heading="Metadata")} -{'Work Dir:':<{label_width}} '{self.cwd}' +{"Work Dir:":<{label_width}} '{self.cwd}' """ ] return "\n".join(error_msg) diff --git a/pkgs/clan-cli/clan_cli/secrets/sops.py b/pkgs/clan-cli/clan_cli/secrets/sops.py index 6d8d3ecff..9c37aad12 100644 --- a/pkgs/clan-cli/clan_cli/secrets/sops.py +++ b/pkgs/clan-cli/clan_cli/secrets/sops.py @@ -492,7 +492,7 @@ def read_key(path: Path) -> tuple[str, KeyType]: raise ClanError(msg) from e key_type = KeyType.validate(key.get("type")) if key_type is None: - msg = f"Invalid key type in {path.name}: \"{key_type}\" (expected one of {', '.join(KeyType.__members__.keys())})." + msg = f'Invalid key type in {path.name}: "{key_type}" (expected one of {", ".join(KeyType.__members__.keys())}).' raise ClanError(msg) publickey = key.get("publickey") if not publickey: 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 3c4d0096f..e2a401e3e 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 @@ -141,7 +141,7 @@ class SecretStore(StoreBase): # TODO get the path to the secrets from the machine [ "cat", - f"{self.machine.deployment["password-store"]["secretLocation"]}/.pass_info", + f"{self.machine.deployment['password-store']['secretLocation']}/.pass_info", ], RunOpts(log=Log.STDERR, check=False), ).stdout.strip() diff --git a/pkgs/clan-cli/clan_cli/vars/secret_modules/sops.py b/pkgs/clan-cli/clan_cli/vars/secret_modules/sops.py index a4f7c239e..dbf3128c9 100644 --- a/pkgs/clan-cli/clan_cli/vars/secret_modules/sops.py +++ b/pkgs/clan-cli/clan_cli/vars/secret_modules/sops.py @@ -238,7 +238,7 @@ class SecretStore(StoreBase): msg = ( f"One or more recipient keys were added to secret{' shared' if generator.share else ''} var '{var_id}', but it was never re-encrypted.\n" f"This could have been a malicious actor trying to add their keys, please investigate.\n" - f"Added keys: {', '.join(f"{r.key_type.name}:{r.pubkey}" for r in recipients_to_add)}\n" + f"Added keys: {', '.join(f'{r.key_type.name}:{r.pubkey}' for r in recipients_to_add)}\n" f"If this is intended, run 'clan vars fix' to re-encrypt the secret." ) return needs_update, msg diff --git a/pkgs/clan-cli/clan_cli/vms/qemu.py b/pkgs/clan-cli/clan_cli/vms/qemu.py index 0fd1108cc..d42b48ab9 100644 --- a/pkgs/clan-cli/clan_cli/vms/qemu.py +++ b/pkgs/clan-cli/clan_cli/vms/qemu.py @@ -99,8 +99,8 @@ def qemu_command( portmap = {} kernel_cmdline = [ (Path(nixos_config["toplevel"]) / "kernel-params").read_text(), - f'init={nixos_config["toplevel"]}/init', - f'regInfo={nixos_config["regInfo"]}/registration', + f"init={nixos_config['toplevel']}/init", + f"regInfo={nixos_config['regInfo']}/registration", "console=hvc0", ] if not vm.waypipe.enable: diff --git a/pkgs/clan-cli/clan_cli/vms/waypipe.py b/pkgs/clan-cli/clan_cli/vms/waypipe.py index 524b65f99..7a2ce2a14 100644 --- a/pkgs/clan-cli/clan_cli/vms/waypipe.py +++ b/pkgs/clan-cli/clan_cli/vms/waypipe.py @@ -16,7 +16,7 @@ def test_vsock_port(port: int) -> bool: msg = "vsock is only supported on Linux" raise NotImplementedError(msg) try: - with socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM) as s: + with socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM) as s: # type: ignore[attr-defined] s.connect((VMADDR_CID_HYPERVISOR, port)) except OSError: return False diff --git a/pkgs/clan-cli/docs.py b/pkgs/clan-cli/docs.py index 47389c4df..71c7288cf 100644 --- a/pkgs/clan-cli/docs.py +++ b/pkgs/clan-cli/docs.py @@ -327,7 +327,7 @@ def build_command_reference() -> None: filename = cmd.title.split(" ")[0] markdown = files.get(folder / f"{filename}.md", "") - markdown += f"{'#'*(cmd.level)} {cmd.title.capitalize()}\n\n" + markdown += f"{'#' * (cmd.level)} {cmd.title.capitalize()}\n\n" markdown += f"{cmd.description}\n\n" if cmd.description else "" diff --git a/pkgs/clan-cli/tests/sshd.py b/pkgs/clan-cli/tests/sshd.py index 7bb2798a7..571c900aa 100644 --- a/pkgs/clan-cli/tests/sshd.py +++ b/pkgs/clan-cli/tests/sshd.py @@ -76,9 +76,9 @@ exec {bash} -l "${{@}}" login_shell.chmod(0o755) lib_path = None - assert ( - platform == "linux" - ), f"we do not support the ld_preload trick on non-linux just now. Got {platform}" + assert platform == "linux", ( + f"we do not support the ld_preload trick on non-linux just now. Got {platform}" + ) # This enforces a login shell by overriding the login shell of `getpwnam(3)` lib_path = tmpdir / "libgetpwnam-preload.so" diff --git a/pkgs/clan-vm-manager/tests/helpers/cli.py b/pkgs/clan-vm-manager/tests/helpers/cli.py index 453923ebe..9f95e4abc 100644 --- a/pkgs/clan-vm-manager/tests/helpers/cli.py +++ b/pkgs/clan-vm-manager/tests/helpers/cli.py @@ -14,7 +14,7 @@ def print_trace(msg: str) -> None: if "run_no_stdout" in callers[0]: callers = get_callers(3, 3 + trace_depth) - callers_str = "\n".join(f"{i+1}: {caller}" for i, caller in enumerate(callers)) + callers_str = "\n".join(f"{i + 1}: {caller}" for i, caller in enumerate(callers)) log.debug(f"{msg} \nCallers: \n{callers_str}") diff --git a/pkgs/zerotier-members/zerotier-members.py b/pkgs/zerotier-members/zerotier-members.py index e3f51199d..d69642862 100755 --- a/pkgs/zerotier-members/zerotier-members.py +++ b/pkgs/zerotier-members/zerotier-members.py @@ -14,9 +14,9 @@ class ClanError(Exception): def compute_zerotier_ip(network_id: str, identity: str) -> ipaddress.IPv6Address: - assert ( - len(network_id) == 16 - ), "network_id must be 16 characters long, got {network_id}" + assert len(network_id) == 16, ( + "network_id must be 16 characters long, got {network_id}" + ) nwid = int(network_id, 16) node_id = int(identity, 16) addr_parts = bytearray( From fbdf0931b93900b6b62181729c83e2412a479501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 14 Jan 2025 15:32:13 +0100 Subject: [PATCH 3/3] ignore ruff A005 for now --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 23d87d00e..afc5d3ee1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,9 @@ lint.select = [ ] lint.ignore = [ "A003", + # A005 Module `inspect` shadows a Python standard-library module + # We might asctually wants to fix this. + "A005", "ANN401", "TRY400", "E402",