Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable canonicalisation #84

Open
Zac-HD opened this issue Jun 3, 2021 · 2 comments
Open

Unstable canonicalisation #84

Zac-HD opened this issue Jun 3, 2021 · 2 comments

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Jun 3, 2021

____________ test_canonicalises_to_equivalent_fixpoint[any-schema] _____________
[gw0] linux -- Python 3.7.10 /home/runner/work/hypothesis-jsonschema/hypothesis-jsonschema/.tox/test/bin/python
tests/test_canonicalise.py:27: in test_canonicalises_to_equivalent_fixpoint
    @given(data=st.data())
tests/test_canonicalise.py:33: in test_canonicalises_to_equivalent_fixpoint
    assert cc == canonicalish(cc)
E   AssertionError: assert {'not': {'min...g', 'object']} == {'type': ['nu...g', 'object']}
E     Omitting 1 identical items, use -vv to show
E     Left contains 1 more item:
E     {'not': {'minItems': 1, 'type': 'array'}}
E     Use -v to get the full diff
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_canonicalises_to_equivalent_fixpoint(
    data=data(...), schema_strategy=_json_schemata(),
)
Draw 1 (schema): {'not': {'anyOf': [{'type': 'array', 'items': {}, 'contains': {}}, {'type': 'array', 'items': True}]}}
@Stranger6667
Copy link
Contributor

There is a similar canonicalisation issue with not involved:

>>> schema = {"type": "integer", "not": {"required": ["foo"]}}
>>> canonicalish(schema)
{'type': 'integer', 'not': {'type': 'integer'}}
>>> canonicalish(canonicalish(schema))
{'not': {}}

Not sure if it is exactly the same issue, though, but may be related

@Zac-HD
Copy link
Member Author

Zac-HD commented Jun 3, 2021

Yeah, that's a simpler but equivalent problem.

Importantly the canonicalisation is correct if incomplete in both cases, so given the difficulty of fixing it I'm not treating the possible gain in efficiency as a particularly urgent issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants