Skip to content

Update jsonschema.protocols.Validator.__init__ #14327

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 2 commits into from
Jul 7, 2025

Conversation

sirosen
Copy link
Contributor

@sirosen sirosen commented Jun 22, 2025

The signature of this protocol has changed in recent versions of jsonschema. Update to match.


Aside: There was a period (~1 year ago?) when I was actively working on jsonschema types with a plan to backport things from typeshed to jsonschema.
I got a bit bogged down and the work is unfinished, but I would ultimately like to help make that happen. In the meantime, I still want to keep these in sync. :)

sirosen and others added 2 commits June 22, 2025 17:47
The signature of this protocol has changed in recent versions of
`jsonschema`. Update to match.
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

check-jsonschema (https://github.com/python-jsonschema/check-jsonschema)
- src/check_jsonschema/schema_loader/main.py:190: error: Unexpected keyword argument "registry" for "Validator"  [call-arg]
+ src/check_jsonschema/schema_loader/main.py:219: error: Missing positional argument "registry" in call to "Validator"  [call-arg]
+ src/check_jsonschema/schema_loader/main.py:277: error: Missing positional argument "registry" in call to "Validator"  [call-arg]

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/definitions.py: note: In function "make_validator":
+ src/schemathesis/specs/openapi/definitions.py:1918: error: Missing positional argument "registry" in call to "Validator"  [call-arg]
+ src/schemathesis/specs/openapi/negative/__init__.py: note: In function "get_validator":
+ src/schemathesis/specs/openapi/negative/__init__.py:43: error: Missing positional argument "registry" in call to "Validator"  [call-arg]
+ src/schemathesis/specs/openapi/negative/__init__.py: note: At top level:

@sirosen
Copy link
Contributor Author

sirosen commented Jun 22, 2025

☝️ Quick note on the above mypy_primer results:
The signature of the protocol does not allow for deprecated args (notably, resolver), even though these currently are allowed at runtime. And the arg is declared as keyword-or-positional but I'm not sure if the order of arguments matches what would happen at runtime with positional args.

This is just what we get with a verbatim copy of the __init__ signature of this protocol from the source repo. I think that it's best to mirror values as closely as possible.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit 09cffef into python:main Jul 7, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants