Open slayoo opened 2 years ago
Note that jsonschema 4.x was released yesterday, and has already had some bugfix releases.
In the near term, you could:
<4
in your repo's CIWould a PR that does this in a minor release of nbformat fix this DeprecationWarning?:
DeprecationWarning: Passing a schema to
Validator.iter_errors
is deprecated and will be removed in a future release. Callvalidator.evolve(schema=new_schema).iter_errors(...)
instead
Does the fix need to be backwards-compatible or can this one call be updated along with the version constraint?
Hi @westurner it could be backwards, by using a try/except if there is an attributerror (assuming the evolve call is not on older versions)
try:
iterator = validator.evolve(schema=new_schema).iter_errors(...)
except AttributeError:
iterator = Validator.iter_errors(...)
We should likely never be creating a new instances of validators, even if the warning suggests it, as this is very expensive (see https://www.peterbe.com/plog/jsonschema-validate-10x-faster-in-python).
Likely we need to
If there's no risk of memory leak from keeping the configured validator in scope, IMHO that sounds like a justified PERF optimization that justifies a couple more lines of changes.
FWIW if anyone else is seeing this as a warning in pytest (e.g. via testbook), adding this to pytest's config will ignore the warning:
[pytest]
filterwarnings =
ignore:Passing a schema to Validator\.iter_errors is deprecated and will be removed in a future release\.:DeprecationWarning:jsonschema\.validators
Since 4.0.0 release of jsonschema (https://github.com/Julian/jsonschema/releases/tag/v4.0.0), the following error started popping out in our CI logs:
HTH, Would be great release a fix, Thanks, Sylwester