diff --git a/src/check_jsonschema/formats/__init__.py b/src/check_jsonschema/formats/__init__.py index 2308c4313..55989c6a7 100644 --- a/src/check_jsonschema/formats/__init__.py +++ b/src/check_jsonschema/formats/__init__.py @@ -50,11 +50,16 @@ def __init__( def get_base_format_checker(schema_dialect: str | None) -> jsonschema.FormatChecker: + # mypy does not consider a class whose instances match a protocol to match + # `type[$PROTOCOL]` so this is considered a mismatch + default_validator_cls: type[jsonschema.Validator] = ( + jsonschema.Draft202012Validator # type:ignore[assignment] + ) # resolve the dialect, if given, to a validator class # default to the latest draft validator_class = jsonschema.validators.validator_for( {} if schema_dialect is None else {"$schema": schema_dialect}, - default=jsonschema.Draft202012Validator, + default=default_validator_cls, ) return validator_class.FORMAT_CHECKER diff --git a/src/check_jsonschema/schema_loader/main.py b/src/check_jsonschema/schema_loader/main.py index e056389a9..a55756d21 100644 --- a/src/check_jsonschema/schema_loader/main.py +++ b/src/check_jsonschema/schema_loader/main.py @@ -187,7 +187,11 @@ def _get_validator( validator_cls = _extend_with_pattern_implementation(validator_cls, regex_impl) # now that we know it's safe to try to create the validator instance, do it - validator = validator_cls( + # + # TODO: remove type ignore + # mypy flags this because of an incorrect signature in typeshed + # see: https://github.com/python/typeshed/pull/14327 + validator = validator_cls( # type: ignore[call-arg] schema, registry=reference_registry, format_checker=format_checker,