mirror of
https://github.com/clearml/clearml
synced 2025-02-07 05:18:50 +00:00
Fix several jsonschema DeprecationWarning (#1128)
* address DeprecationWarnings from jsonschema * use `referencing` for Python >= 3.8 * undo unrelated change by auto linter
This commit is contained in:
parent
489dee0e92
commit
e89b2a03a7
@ -1,7 +1,14 @@
|
||||
import abc
|
||||
|
||||
import jsonschema
|
||||
import six
|
||||
from jsonschema.exceptions import FormatError, SchemaError, ValidationError
|
||||
|
||||
try:
|
||||
# Since `referencing`` only supports Python >= 3.8, this try-except blocks maintain support
|
||||
# for earlier python versions.
|
||||
from referencing.exceptions import Unresolvable
|
||||
except ImportError:
|
||||
from jsonschema.exceptions import RefResolutionError as Unresolvable
|
||||
|
||||
from .apimodel import ApiModel
|
||||
from .datamodel import DataModel
|
||||
@ -39,8 +46,7 @@ class BatchRequest(Request):
|
||||
|
||||
_batched_request_cls = abc.abstractproperty()
|
||||
|
||||
_schema_errors = (jsonschema.SchemaError, jsonschema.ValidationError, jsonschema.FormatError,
|
||||
jsonschema.RefResolutionError)
|
||||
_schema_errors = (SchemaError, ValidationError, FormatError, Unresolvable)
|
||||
|
||||
def __init__(self, requests, validate_requests=False, allow_raw_requests=True, **kwargs):
|
||||
super(BatchRequest, self).__init__(**kwargs)
|
||||
@ -70,8 +76,7 @@ class BatchRequest(Request):
|
||||
for i, req in enumerate(self.requests):
|
||||
try:
|
||||
req.validate()
|
||||
except (jsonschema.SchemaError, jsonschema.ValidationError,
|
||||
jsonschema.FormatError, jsonschema.RefResolutionError) as e:
|
||||
except (SchemaError, ValidationError, FormatError, Unresolvable) as e:
|
||||
raise Exception('Validation error in batch item #%d: %s' % (i, str(e)))
|
||||
|
||||
def get_json(self):
|
||||
|
@ -14,6 +14,7 @@ python-dateutil>=2.6.1
|
||||
pyjwt>=2.4.0,<2.9.0 ; python_version > '3.5'
|
||||
pyjwt>=1.6.4,<2.0.0 ; python_version <= '3.5'
|
||||
PyYAML>=3.12
|
||||
referencing<0.40 ; python_version >= '3.8'
|
||||
requests>=2.20.0
|
||||
six>=1.13.0
|
||||
typing>=3.6.4 ; python_version < '3.5'
|
||||
|
Loading…
Reference in New Issue
Block a user