summaryrefslogtreecommitdiff
path: root/jsonschema/__init__.py
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2023-02-23 15:35:44 +0200
committerJulian Berman <Julian@GrayVines.com>2023-02-23 16:12:31 +0200
commit19bdf6191a8e209584b18e7a3d4ec55cad9037e6 (patch)
treeb406a160255aaa084018ccde678a97b08b525edd /jsonschema/__init__.py
parent3801d9aea0e044ff8b190bff750594aa18dee67e (diff)
downloadjsonschema-19bdf6191a8e209584b18e7a3d4ec55cad9037e6.tar.gz
Three more exception-related deprecations.
* RefResolutionError is deprecated entirely. Use referencing.Registry-based APIs, and catch referencing.exceptions.Unresolvable if you really want to ignore referencing related issues. * FormatError should now be imported from jsonschema.exceptions only, not from the package root. * ErrorTree should now be imported from jsonschema.exceptions only, not from the package root.
Diffstat (limited to 'jsonschema/__init__.py')
-rw-r--r--jsonschema/__init__.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/jsonschema/__init__.py b/jsonschema/__init__.py
index 8f6b0a4..ad7affc 100644
--- a/jsonschema/__init__.py
+++ b/jsonschema/__init__.py
@@ -12,13 +12,7 @@ import warnings
from jsonschema._format import FormatChecker
from jsonschema._types import TypeChecker
-from jsonschema.exceptions import (
- ErrorTree,
- FormatError,
- RefResolutionError,
- SchemaError,
- ValidationError,
-)
+from jsonschema.exceptions import SchemaError, ValidationError
from jsonschema.protocols import Validator
from jsonschema.validators import (
Draft3Validator,
@@ -55,6 +49,34 @@ def __getattr__(name):
stacklevel=2,
)
return _RefResolver
+ elif name == "ErrorTree":
+ warnings.warn(
+ "Importing ErrorTree directly from the jsonschema package "
+ "is deprecated and will become an ImportError. Import it from "
+ "jsonschema.exceptions instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ from jsonschema.exceptions import ErrorTree
+ return ErrorTree
+ elif name == "FormatError":
+ warnings.warn(
+ "Importing FormatError directly from the jsonschema package "
+ "is deprecated and will become an ImportError. Import it from "
+ "jsonschema.exceptions instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ from jsonschema.exceptions import FormatError
+ return FormatError
+ elif name == "RefResolutionError":
+ from jsonschema.exceptions import _RefResolutionError
+ warnings.warn(
+ _RefResolutionError._DEPRECATION_MESSAGE,
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return _RefResolutionError
format_checkers = {
"draft3_format_checker": Draft3Validator,