Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Jun 17, 2024
1 parent d5a42a5 commit 8b900ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WDL/Value.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,21 +579,21 @@ def from_json(type: Type.Base, value: Any) -> Base:
raise Error.InputError(
f"initializer for struct {str(type)} omits required field(s)"
)
fields = {}
members = {}
extra = set()
for k, v in value.items():
assert isinstance(k, str)
if k not in type.members:
extra.add(k)
else:
try:
fields[k] = from_json(type.members[k], v)
members[k] = from_json(type.members[k], v)
except Error.InputError:
raise Error.InputError(
f"couldn't initialize struct {str(type)} {type.members[k]} {k} from {json.dumps(v)}"
) from None
# Struct.__init__ will populate null for any omitted optional members
return Struct(type, items, extra=extra)
return Struct(type, members, extra=extra)
if type.optional and value is None:
return Null()
raise Error.InputError(f"couldn't construct {str(type)} from {json.dumps(value)}")
Expand Down

0 comments on commit 8b900ac

Please sign in to comment.