Skip to content
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

Replace deprecated jsonschema.RefResolver with referencing.Registry #2023

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

radoering
Copy link

Fixes #1786 (which was closed prematurely as pointed out in #1786 (comment))

Fixes the following deprecation warnings:

connexion/json_schema.py:18
  /home/randy/connexion/connexion/json_schema.py:18: DeprecationWarning: jsonschema.RefResolver is deprecated as of v4.18.0, in favor of the https://github.com/python-jsonschema/referencing library, which provides more compliant referencing behavior as well as more flexible APIs for customization. A future release will remove RefResolver. Please file a feature request (on referencing) if you are missing an API for the kind of customization you need.
    from jsonschema import Draft4Validator, RefResolver

connexion/json_schema.py:19
  /home/randy/connexion/connexion/json_schema.py:19: DeprecationWarning: jsonschema.exceptions.RefResolutionError is deprecated as of version 4.18.0. If you wish to catch potential reference resolution errors, directly catch referencing.exceptions.Unresolvable.
    from jsonschema.exceptions import RefResolutionError, ValidationError  # noqa

See also https://python-jsonschema.readthedocs.io/en/latest/referencing/#migrating-from-refresolver

@chrisinmtown
Copy link
Contributor

chrisinmtown commented Dec 31, 2024

Thanks for this, I'm a little tired of seeing those warnings every time I run tox. I hope someone can explain why the code test pipeline/workflow didn't run automatically on this PR, only the read-the-docs check?

@@ -13,9 +14,11 @@

import requests
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the imports are grouped (1) python standard, (2) third party and (3) connexion. FWIW maybe it's worth sorting within categories (1) and (2) here?

Copy link
Author

Choose a reason for hiding this comment

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

There is a sorting within categories: At first normal imports sorted alphabetically, then from imports sorted alphabetically.

If I change the order isort will complain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining, I didn't spot that pattern, never mind!



def retrieve(uri: str) -> Resource:
parsed = urllib.parse.urlsplit(uri)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please consider adding pydoc for this new function?

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@chrisinmtown
Copy link
Contributor

chrisinmtown commented Dec 31, 2024

The referencing library is in status Alpha and their issues board includes a ticket about very slow performance:

python-jsonschema/referencing#178

Did you notice any slowdown here?

@radoering radoering force-pushed the fix-jsonschema-refresolver-deprecation branch from ee04d60 to 5ba75c9 Compare December 31, 2024 15:55
@radoering
Copy link
Author

Did you notice any slowdown here?

I did not notice any slowdown in the tests. I did not try with larger schemas.

@radoering
Copy link
Author

I hope someone can explain why the code test pipeline/workflow didn't run automatically on this PR, only the read-the-docs check?

The workflow requires approval from a maintainer according to https://github.com/spec-first/connexion/actions

@radoering radoering force-pushed the fix-jsonschema-refresolver-deprecation branch from 5ba75c9 to 2d70dde Compare January 12, 2025 06:17
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.

Various jsonschema DeprecationWarnings
2 participants