Skip to content

Patch type checking issues #572

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

Merged
merged 1 commit into from
Jun 22, 2025
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
7 changes: 6 additions & 1 deletion src/check_jsonschema/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/check_jsonschema/schema_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading