From 63697ac4b1d43603352c069b5015b668b1157dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 26 Aug 2025 12:59:49 +0200 Subject: [PATCH] various fixes --- pkgs/clan-cli/clan_cli/templates/list.py | 3 ++- pkgs/clan-cli/clan_lib/api/serde.py | 6 +++--- pkgs/clan-cli/clan_lib/clan/get.py | 5 ++--- pkgs/clan-cli/clan_lib/machines/update.py | 6 ++++-- pkgs/clan-cli/clan_lib/tags/list.py | 4 +--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/templates/list.py b/pkgs/clan-cli/clan_cli/templates/list.py index 6338a15bd..56a25d3bc 100644 --- a/pkgs/clan-cli/clan_cli/templates/list.py +++ b/pkgs/clan-cli/clan_cli/templates/list.py @@ -1,12 +1,13 @@ from __future__ import annotations -import argparse import logging from typing import TYPE_CHECKING from clan_lib.templates import list_templates if TYPE_CHECKING: + import argparse + from clan_lib.nix_models.clan import TemplateClanType log = logging.getLogger(__name__) diff --git a/pkgs/clan-cli/clan_lib/api/serde.py b/pkgs/clan-cli/clan_lib/api/serde.py index 85e1690fa..ffae996f0 100644 --- a/pkgs/clan-cli/clan_lib/api/serde.py +++ b/pkgs/clan-cli/clan_lib/api/serde.py @@ -277,9 +277,9 @@ def construct_value( inner_types = unwrap_union_type(t) # Construct the field value errors = [] - for t in inner_types: + for inner_type in inner_types: try: - return construct_value(t, field_value, loc) + return construct_value(inner_type, field_value, loc) except ClanError as exc: errors.append(exc) continue @@ -392,7 +392,7 @@ def construct_dataclass[T: Any]( field_values[field.name] = None else: field_values[field.name] = construct_value( - cast(type, field.type), field_value + cast("type", field.type), field_value ) # Check that all required field are present. diff --git a/pkgs/clan-cli/clan_lib/clan/get.py b/pkgs/clan-cli/clan_lib/clan/get.py index 5a929cfe5..ea304653e 100644 --- a/pkgs/clan-cli/clan_lib/clan/get.py +++ b/pkgs/clan-cli/clan_lib/clan/get.py @@ -38,8 +38,7 @@ def get_clan_details(flake: Flake) -> InventoryMeta: @API.register def get_clan_details_schema(flake: Flake) -> dict[str, FieldSchema]: - """ - Get attributes for each field of the clan. + """Get attributes for each field of the clan. This function checks which fields of the 'clan' resource are readonly and provides a reason if so. @@ -48,8 +47,8 @@ def get_clan_details_schema(flake: Flake) -> dict[str, FieldSchema]: Returns: dict[str, FieldSchema]: A map from field-names to { 'readonly' (bool) and 'reason' (str or None ) } - """ + """ inventory_store = InventoryStore(flake) write_info = inventory_store.get_writeability() diff --git a/pkgs/clan-cli/clan_lib/machines/update.py b/pkgs/clan-cli/clan_lib/machines/update.py index d0c84f91b..781c53b80 100644 --- a/pkgs/clan-cli/clan_lib/machines/update.py +++ b/pkgs/clan-cli/clan_lib/machines/update.py @@ -140,14 +140,16 @@ def run_machine_update( """ with ExitStack() as stack: _target_host: Host = cast( - Host, stack.enter_context(target_host.host_connection()) + "Host", stack.enter_context(target_host.host_connection()) ) _build_host: Host # If no build host is specified, use the target host as the build host. if build_host is None: _build_host = _target_host else: - _build_host = cast(Host, stack.enter_context(build_host.host_connection())) + _build_host = cast( + "Host", stack.enter_context(build_host.host_connection()) + ) # Some operations require root privileges on the target host. target_host_root = stack.enter_context(_target_host.become_root()) diff --git a/pkgs/clan-cli/clan_lib/tags/list.py b/pkgs/clan-cli/clan_lib/tags/list.py index 650ba2fc6..41caf6698 100644 --- a/pkgs/clan-cli/clan_lib/tags/list.py +++ b/pkgs/clan-cli/clan_lib/tags/list.py @@ -14,15 +14,13 @@ class TagList: @API.register def list_tags(flake: Flake) -> TagList: - """ - List all tags of a clan. + """List all tags of a clan. Returns: - 'options' - Existing Tags that can be added to machines - 'special' - Prefined Tags that are special and cannot be added to machines, they can be used in roles and refer to a fixed set of machines. """ - inventory_store = InventoryStore(flake=flake) inventory = inventory_store.read()