diff --git a/HISTORY.rst b/HISTORY.rst index 3480ac25..8b876de0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,7 @@ History * Uncap the required Python version, to avoid problems detailed in https://iscinumpy.dev/post/bound-version-constraints/#pinning-the-python-version-is-special (`#275 `_) * Fix `Converter.register_structure_hook_factory` and `cattrs.gen.make_dict_unstructure_fn` type annotations. (`#281 `_) +* Expose all error classes in the `cattr.errors` namespace. Note that it is deprecated, just use `cattrs.errors`. (`#252 `_) 22.1.0 (2022-04-03) ------------------- diff --git a/src/cattr/errors.py b/src/cattr/errors.py index ef624ed6..af092e9c 100644 --- a/src/cattr/errors.py +++ b/src/cattr/errors.py @@ -1,3 +1,15 @@ -from cattrs.errors import StructureHandlerNotFoundError +from cattrs.errors import ( + BaseValidationError, + ClassValidationError, + ForbiddenExtraKeysError, + IterableValidationError, + StructureHandlerNotFoundError, +) -__all__ = ["StructureHandlerNotFoundError"] +__all__ = [ + "BaseValidationError", + "ClassValidationError", + "ForbiddenExtraKeysError", + "IterableValidationError", + "StructureHandlerNotFoundError", +] diff --git a/src/cattrs/__init__.py b/src/cattrs/__init__.py index c4bd080a..ae3a1c4d 100644 --- a/src/cattrs/__init__.py +++ b/src/cattrs/__init__.py @@ -1,25 +1,38 @@ from .converters import BaseConverter, Converter, GenConverter, UnstructureStrategy +from .errors import ( + BaseValidationError, + ClassValidationError, + ForbiddenExtraKeysError, + IterableValidationError, + StructureHandlerNotFoundError, +) + from .gen import override __all__ = ( "BaseConverter", + "BaseValidationError", + "ClassValidationError", "Converter", "converters", "disambiguators", "dispatch", "errors", + "ForbiddenExtraKeysError", "gen", "GenConverter", "global_converter", + "IterableValidationError", "override", "preconf", - "register_structure_hook_func", "register_structure_hook", - "register_unstructure_hook_func", + "register_structure_hook_func", "register_unstructure_hook", + "register_unstructure_hook_func", + "structure", "structure_attrs_fromdict", "structure_attrs_fromtuple", - "structure", + "StructureHandlerNotFoundError", "unstructure", "UnstructureStrategy", )