Clan-app: example disk view

This commit is contained in:
Johannes Kirschbauer
2024-07-29 11:48:39 +02:00
parent 5223506e29
commit d11e725a80
6 changed files with 61 additions and 3 deletions

View File

@@ -90,7 +90,9 @@ def from_dict(t: type[T], data: Any) -> T:
"""
adapter = TypeAdapter(t)
try:
return adapter.validate_python(data)
return adapter.validate_python(
data,
)
except ValidationError as e:
fst_error: ErrorDetails = e.errors()[0]
if not fst_error:

View File

@@ -74,7 +74,9 @@ def type_to_dict(t: Any, scope: str = "", type_map: dict[TypeVar, type] = {}) ->
if dataclasses.is_dataclass(t):
fields = dataclasses.fields(t)
properties = {
f.name: type_to_dict(f.type, f"{scope} {t.__name__}.{f.name}", type_map)
f.metadata.get("alias", f.name): type_to_dict(
f.type, f"{scope} {t.__name__}.{f.name}", type_map
)
for f in fields
if not f.name.startswith("_")
}