nix_modules: fix and update None types

This commit is contained in:
Johannes Kirschbauer
2025-08-31 12:49:58 +02:00
parent 453f2649d3
commit 5137d19b0f
2 changed files with 6 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ class Unknown:
InventoryInstanceModuleNameType = str
InventoryInstanceModuleInputType = str
InventoryInstanceModuleInputType = str | None
class InventoryInstanceModule(TypedDict):
name: str
@@ -163,7 +163,7 @@ class Template(TypedDict):
ClanDirectoryType = dict[str, Any] | list[Any] | bool | float | int | str
ClanDirectoryType = dict[str, Any] | list[Any] | bool | float | int | str | None
ClanInventoryType = Inventory
ClanMachinesType = dict[str, Unknown]
ClanMetaType = Unknown

View File

@@ -218,13 +218,12 @@ def get_field_def(
default_factory: str | None = None,
type_appendix: str = "",
) -> tuple[str, str]:
if "None" in field_types or default or default_factory:
if "None" in field_types:
field_types.remove("None")
serialised_types = " | ".join(sort_types(field_types)) + type_appendix
_field_types = set(field_types)
if "None" in _field_types or default or default_factory:
serialised_types = " | ".join(sort_types(_field_types)) + type_appendix
serialised_types = f"{serialised_types}"
else:
serialised_types = " | ".join(sort_types(field_types)) + type_appendix
serialised_types = " | ".join(sort_types(_field_types)) + type_appendix
return (field_name, serialised_types)