diff --git a/changes/2572-paxcodes.md b/changes/2572-paxcodes.md new file mode 100644 index 0000000..aacad15 --- /dev/null +++ b/changes/2572-paxcodes.md @@ -0,0 +1 @@ +Add `__version__` attribute to pydantic module. diff --git a/pydantic/__init__.py b/pydantic/__init__.py index 2e7aab4..19e5432 100644 --- a/pydantic/__init__.py +++ b/pydantic/__init__.py @@ -14,6 +14,8 @@ from .tools import * from .types import * from .version import VERSION +__version__ = VERSION + # WARNING __all__ from .errors is not included here, it will be removed as an export here in v2 # please use "from pydantic.errors import ..." instead __all__ = [ diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..ef7c928 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,9 @@ +import pydantic + + +def test_version_attribute_is_present(): + assert hasattr(pydantic, '__version__') + + +def test_version_attribute_is_a_string(): + assert isinstance(pydantic.__version__, str)