playpauseandstop / rororo

Implement aiohttp.web OpenAPI 3 server applications with schema first approach.
https://rororo.readthedocs.io
BSD 3-Clause "New" or "Revised" License
106 stars 9 forks source link

rororo should require jsonschema <= 4.17.3 #394

Closed playpauseandstop closed 3 months ago

playpauseandstop commented 1 year ago

As jsonschema==~4.18 will result in,

  File ".venv/lib/python3.11/site-packages/rororo/__init__.py", line 15, in <module>
    from rororo.openapi import (
  File ".venv/lib/python3.11/site-packages/rororo/openapi/__init__.py", line 11, in <module>
    from rororo.openapi.contexts import openapi_context
  File ".venv/lib/python3.11/site-packages/rororo/openapi/contexts.py", line 6, in <module>
    from rororo.openapi.data import OpenAPIContext
  File ".venv/lib/python3.11/site-packages/rororo/openapi/data.py", line 15, in <module>
    from openapi_core.validation.request.datatypes import RequestParameters
  ...
  File ".venv/lib/python3.11/site-packages/openapi_schema_validator/validators.py", line 11, in <module>
    meta_schema=_utils.load_schema("draft4"),
                ^^^^^^^^^^^^^^^^^^
AttributeError: module 'jsonschema._utils' has no attribute 'load_schema'

And jsonschema==~4.19 will result in,

  ...
  File ".venv/lib/python3.11/site-packages/openapi_schema_validator/validators.py", line 3, in <module>
    from jsonschema import _legacy_validators, _utils, _validators
ImportError: cannot import name '_legacy_validators' from 'jsonschema' (/Users/idavydenko/Projects/playpauseandstop/igordavydenko/.venv/lib/python3.11/site-packages/jsonschema/__init__.py)
Julian commented 1 year ago

Hi. I happen to be seeing this issue while doing a general GitHub search -- can I ask if there's anything I can do to make it even clearer that these are private and can change without warning? They follow Python conventions (beginning with an underscore) -- and they also have trivial replacements (specifically the VALIDATORS attribute on a Validator is the way to access functions which validate particular keywords, and there's no reason to call load_schema outside of the package itself, you should use importlib.resources).

It's the first time seeing this package (congrats on writing it) -- so just my 0.02, but I wouldn't be trying to pin jsonschema from above if it were me, I'd simply ensure you were using public APIs instead of private ones. Happy to answer questions if needed.

playpauseandstop commented 3 months ago

@Julian

Sure! You’re completely right, but the problem here that my library requires an ancient version of other library, which at same time uses private capabilities of jsonschema. Cause of that & before I’ll be able to spend sometime for upgrading to moat recent version of that external library, I’ll create the upper boundary for the jsonschema here.

Hope it makes sense for you, but once again in ideal world I’d go as you suggested 🙏