Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Unreleased
- Added support for Python 3.15 .
- Removed support for Python 3.10 .
- The build backend has been updated from setuptools to flit.
- When running with a builtin schema, ``check-jsonschema`` will now skip
the metaschema check as an optimization.

0.38.2
------
Expand Down
8 changes: 7 additions & 1 deletion src/check_jsonschema/schema_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def get_validator(
class SchemaLoader(SchemaLoaderBase):
validator_class: type[jsonschema.protocols.Validator] | None = None
disable_cache: bool = True
validate_schema: t.ClassVar[bool] = True

def __init__(
self,
Expand Down Expand Up @@ -169,7 +170,8 @@ def _get_validator(
# get the correct validator class and check the schema under its metaschema
validator_cls = jsonschema.validators.validator_for(schema)

_check_schema(validator_cls, schema, regex_impl=regex_impl)
if self.validate_schema:
_check_schema(validator_cls, schema, regex_impl=regex_impl)
else:
# for a user-provided validator class, don't check_schema
# on the grounds that it might *not* be valid but the user wants to use
Expand Down Expand Up @@ -241,6 +243,10 @@ def _dialect_of_schema(schema: dict[str, t.Any] | bool) -> str | None:


class BuiltinSchemaLoader(SchemaLoader):
# disable schema validation for builtin schemas
# they are already checked under the metaschema checker when they are updated/added
validate_schema: t.ClassVar[bool] = False

def __init__(self, schema_name: str, *, base_uri: str | None = None) -> None:
self.schema_name = schema_name
self.base_uri = base_uri
Expand Down
Loading