Skip to content

Commit 718e70a

Browse files
committed
Canonicalise deps to fixpoint
1 parent cf548f2 commit 718e70a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/hypothesis_jsonschema/_canonicalise.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ def canonicalish(schema: JSONType) -> Dict[str, Any]:
461461
# TODO: else merge schema-dependencies of required properties
462462
# into the base schema after adding required back in and being
463463
# careful to avoid an infinite loop...
464+
if not schema["dependencies"]:
465+
schema.pop("dependencies")
464466
schema["required"] = sorted(reqs)
465467
max_ = schema.get("maxProperties", float("inf"))
466468
assert isinstance(max_, (int, float))

tests/test_canonicalise.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def test_canonicalises_to_equivalent_fixpoint(schema_strategy, data):
5353
jsonschema.validators.validator_for(schema).check_schema(schema)
5454

5555

56+
def test_dependencies_canonicalises_to_fixpoint():
57+
"""Check that an object drawn from an arbitrary schema is valid."""
58+
cc = canonicalish(
59+
{"required": [""], "properties": {"": {}}, "dependencies": {"": [""]}}
60+
)
61+
assert cc == canonicalish(cc)
62+
63+
5664
@pytest.mark.parametrize(
5765
"schema",
5866
[

0 commit comments

Comments
 (0)