jsonschema_extras package

Utilities for working with the JSON Schema Python library jsonschema.

Features:

jsonschema_extras.BUNDLED_SCHEMAS_URI_BASE: Final[str] = 'file:/jsonschema_extras/schemas'

Base URI for schemas bundled with this library.

jsonschema_extras.bundled_schemas_files()[source]

Returns a Traversable object containing resources for bundled schemas.

Built upon importlib.resources.files().

Return type:

Traversable

jsonschema_extras.bundled_schemas_retriever(*, open_buffering=-1, cache=None)[source]

Context manager producing a retrieval callable for this library’s bundled schemas.

Warning

The produced retriever is only valid within duration of an explicit lifecycle, hence the context manager.

Parameters:
  • cache (GenericAlias[Any] | Literal['default'] | None) – Caching decorator for Retrieve, or 'default' to use the default caching implementation (see description of jsonschema_extras.registries.retrieval for details). Defaults to None, meaning no caching.

  • open_buffering (int) – Optional integer used to set the buffering policy. See the Python built-in function open().

Yields:

A retrieval callable for this library’s bundled schemas. The retriever is only valid until the context is exited.

Raises:

ValueError – On invalid uri_base.

Return type:

Iterator[Retrieve]

Note

The implementation uses importlib.resources which conceptually cannot provide a persistent path to a directory which could be accessed by common code at any time. The lifecycle has to be explicit due to using package resources.

Subpackages

Submodules