Skip to content

Commit

Permalink
Simplify example comments to avoid repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
larsmaxfield committed Jan 7, 2025
1 parent 0891adf commit 6db3369
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/load_dereference_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ def main():
protocols.Validator.check_schema(schema)
validate(instance, schema)

# De-reference schema before using it to fill defaults
# jsonref.replace_refs replaces "$refs" in a schema with the referenced
# schemas themselves. Assigning its return immediately evaluates it and
# returns a deep copy.
# De-reference schema "$refs"
# Assign jsonref.replace_refs return to immediately evaluate and get copy.
schema = replace_refs(schema)

# Fill instance with schema defaults
# fill_default mutates the instance, so we don't assign its return
# fill_default mutates the instance, so we don't assign its return.
print(f"Original instance:\n{instance}\n")
fill_default(instance, schema)
validate(instance, schema)
Expand Down

0 comments on commit 6db3369

Please sign in to comment.