Answer principles round 2: 0 🔴, 3 🟡; cite item 171 in the figures decision, check a handed route's levels as a value, carry the item and levels in ArchivedWorker

This commit is contained in:
2026-10-16 12:56:20 +02:00
parent 50fdd9e66d
commit 24549589ec
7 changed files with 31 additions and 20 deletions
+3 -6
View File
@@ -58,13 +58,10 @@ def decoded_as(value: object, kind: typing.Any) -> typing.Any:
if not isinstance(value, dict) or not required <= value.keys() <= shape.keys():
return REJECTED
fields = {name: decoded_as(field, shape[name]) for name, field in value.items()}
if any(field in (REJECTED, RETIRED) for field in fields.values()):
return REJECTED
try:
return kind(**fields)
except ValueError:
# A dataclass that checks its fields, as Route does, refuses a handed state that breaks them.
# A dataclass that checks its fields, as Route does, names the check fits.
if any(field in (REJECTED, RETIRED) for field in fields.values()) or not getattr(kind, "fits", lambda _: True)(fields):
return REJECTED
return kind(**fields)
return value if type(value) is kind else REJECTED