schemas: filter 'extraModules' from python classes and derived schemas
This commit is contained in:
@@ -243,7 +243,11 @@ API.register(get_system_file)
|
||||
if "oneOf" not in return_type:
|
||||
msg = (
|
||||
f"Return type of function '{name}' is not a union type. Expected a union of Success and Error types."
|
||||
# @DavHau: no idea wy exactly this leads to the "oneOf" ot being present, but this should help
|
||||
# If the SuccessData type is unsupported it was dropped by Union narrowing.
|
||||
# This is probably an antifeature
|
||||
# Introduced because run_generator wanted to use:
|
||||
# Callable[[Generator], dict[str, str]]
|
||||
# In its function signature.
|
||||
"Hint: When using dataclasses as return types, ensure they don't contain public fields with non-serializable types"
|
||||
)
|
||||
raise JSchemaTypeError(msg)
|
||||
|
||||
@@ -28,13 +28,11 @@ class InventoryInstanceRoleMachine(TypedDict):
|
||||
|
||||
|
||||
|
||||
InventoryInstanceRoleExtramodulesType = list[dict[str, Any] | list[Any] | bool | float | int | str | None]
|
||||
InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine]
|
||||
InventoryInstanceRoleSettingsType = Unknown
|
||||
InventoryInstanceRoleTagsType = dict[str, Any] | list[str]
|
||||
|
||||
class InventoryInstanceRole(TypedDict):
|
||||
extraModules: NotRequired[InventoryInstanceRoleExtramodulesType]
|
||||
machines: NotRequired[InventoryInstanceRoleMachinesType]
|
||||
settings: NotRequired[InventoryInstanceRoleSettingsType]
|
||||
tags: NotRequired[InventoryInstanceRoleTagsType]
|
||||
|
||||
@@ -241,6 +241,11 @@ def generate_dataclass(
|
||||
# If we are at the top level, and the attribute name is not explicitly included we only do shallow
|
||||
field_name = prop.replace("-", "_")
|
||||
|
||||
# Skip "extraModules"
|
||||
# TODO: Introduce seperate model that is tied to the serialization format
|
||||
if "extraModules" in field_name:
|
||||
continue
|
||||
|
||||
# if len(attr_path) == 0 and prop in shallow_attrs:
|
||||
# field_def = field_name, "dict[str, Any]"
|
||||
# fields_with_default.append(field_def)
|
||||
|
||||
Reference in New Issue
Block a user