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:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user