Skip to content

Commit

Permalink
Add referencing.jsonschema.EMPTY_REGISTRY.
Browse files Browse the repository at this point in the history
It's just Registry() but with a SchemaRegistry annotation.
  • Loading branch information
Julian committed Nov 14, 2023
1 parent 783129b commit fdc8ab0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

v0.31.0
-------

* Add ``referencing.jsonschema.EMPTY_REGISTRY`` (which simply has a convenient type annotation, but otherwise is just ``Registry()``).

v0.30.2
-------

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ ignore = [
"D407",
# Plz spaces after section headers
"D412",
# Not sure what heuristic this uses, but it seems easy for it to be wrong.
"SIM300",
# We support 3.8 + 3.9
"UP007",
]
Expand Down
3 changes: 3 additions & 0 deletions referencing/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#: A JSON Schema Registry
SchemaRegistry = Registry[Schema]

#: The empty JSON Schema Registry
EMPTY_REGISTRY: SchemaRegistry = Registry()


@frozen
class UnknownDialect(Exception):
Expand Down
4 changes: 4 additions & 0 deletions referencing/tests/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,7 @@ def test_multiple_lookup_recursive_ref_with_nonrecursive_ref():
resolver = second.resolver.lookup("bar").resolver
fourth = referencing.jsonschema.lookup_recursive_ref(resolver=resolver)
assert fourth.contents == two.contents


def test_empty_registry():
assert referencing.jsonschema.EMPTY_REGISTRY == Registry()

0 comments on commit fdc8ab0

Please sign in to comment.