diff options
Diffstat (limited to 'jsonschema/_format.py')
-rw-r--r-- | jsonschema/_format.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/jsonschema/_format.py b/jsonschema/_format.py index e9d91b6..ad8343b 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -6,6 +6,7 @@ import datetime import ipaddress import re import typing +import warnings from jsonschema.exceptions import FormatError @@ -85,6 +86,21 @@ class FormatChecker: def cls_checks( cls, format: str, raises: _RaisesType = (), ) -> typing.Callable[[_F], _F]: + warnings.warn( + ( + "FormatChecker.cls_checks is deprecated. Call " + "FormatChecker.checks on a specific FormatChecker instance " + "instead." + ), + DeprecationWarning, + stacklevel=2, + ) + return cls._cls_checks(format=format, raises=raises) + + @classmethod + def _cls_checks( + cls, format: str, raises: _RaisesType = (), + ) -> typing.Callable[[_F], _F]: def _checks(func: _F) -> _F: cls.checkers[format] = (func, raises) return func @@ -205,7 +221,7 @@ def _checks_drafts( # Oy. This is bad global state, but relied upon for now, until # deprecation. See #519 and test_format_checkers_come_with_defaults - FormatChecker.cls_checks( + FormatChecker._cls_checks( draft202012 or draft201909 or draft7 or draft6 or draft4 or draft3, raises, )(func) |