Skip to content

Replace hand-written format checkers with jsonschema[format-nongpl] #121

Description

@LukasOro

src/oold/validation/formats.py is 233 lines implementing 18 format assertions by hand. jsonschema[format-nongpl] supplies 19, covering all 18, with identical behaviour on the cases that matter here.

Measured

Same seven inputs through both, across iri, iri-reference, uri, uri-reference - identical in every cell, including the compact-IRI case that motivated the hand-written versions:

ex:alice                       iri=True   iri-reference=True   uri=True   uri-reference=True
schema:Person                  iri=True   iri-reference=True   uri=True   uri-reference=True
urn:uuid:1234...               iri=True   iri-reference=True   uri=True   uri-reference=True
alice                          iri=False  iri-reference=True   uri=False  uri-reference=True
../Thing.schema.json           iri=False  iri-reference=True   uri=False  uri-reference=True
http://exa mple.org            iri=False  iri-reference=False  uri=False  uri-reference=False

The non-ASCII behaviour asserted by test_iri_allows_non_ascii_but_uri_does_not also matches: iri-reference=True, uri=False.

Coverage: all 18 of this package's formats appear in format-nongpl's 19.

Licence constraint

Use jsonschema[format-nongpl], not jsonschema[format]. The latter pulls in rfc3987, which is GNU GPLv3+; this package is Apache-2.0. rfc3987 is correct on every case tested, but its licence rules it out.

Cost

format-nongpl installs 20 transitive packages. That is the main argument for keeping the hand-written module.

Work

  • Swap OOLD_FORMAT_CHECKER onto the library checkers, keeping the module as the seam so callers do not change
  • Gate on tests/test_validation/test_formats.py in full, not the sample above, plus OOLD_SCHEMA_DIR=../oold-schema uv run pytest -m parity
  • If any format diverges, keep that one hand-written and document which and why

Raised from review of #114 (#114 (comment)).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions