diff --git a/HISTORY.md b/HISTORY.md index 1f6b12a3..e6dc974b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # erdantic Changelog +## v1.0.1 (2024-04-10) + +- Fixed `ModuleNotFoundError` when importing from `erdantic.examples` without attrs installed. + ## v1.0.0.post2 (2024-04-10) - Fixed missing LICENSE file in sdist. diff --git a/erdantic/examples/__init__.py b/erdantic/examples/__init__.py index 8d432c8c..17dabe9c 100644 --- a/erdantic/examples/__init__.py +++ b/erdantic/examples/__init__.py @@ -1,10 +1,18 @@ """Example data model classes.""" -from erdantic.examples import attrs, dataclasses, pydantic, pydantic_v1 +from erdantic.examples import dataclasses, pydantic, pydantic_v1 __all__ = [ - "attrs", "dataclasses", "pydantic", "pydantic_v1", ] + +try: + from erdantic.examples import attrs + + attrs + __all__.append("attrs") +except ModuleNotFoundError as e: + if e.name != "attrs": + raise diff --git a/noxfile.py b/noxfile.py index 4077c522..5c9e3211 100644 --- a/noxfile.py +++ b/noxfile.py @@ -106,7 +106,9 @@ def test_wheel(session, extras): else: session.install(str(wheel_path) + extras) session.run("python", "-m", "erdantic", "--version") - session.run("python", "-c", "import erdantic; print(erdantic.list_plugins())") + session.run( + "python", "-c", "import erdantic; import erdantic.examples; print(erdantic.list_plugins())" + ) @nox.session(venv_backend="mamba|conda", python="3.12", reuse_venv=False) @@ -120,6 +122,9 @@ def test_sdist(session): else: session.install(sdist_path) session.run("python", "-m", "erdantic", "--version") + session.run( + "python", "-c", "import erdantic; import erdantic.examples; print(erdantic.list_plugins())" + ) def _docs_base(session): diff --git a/pyproject.toml b/pyproject.toml index ae060848..07178ce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "erdantic" -version = "1.0.0.post2" +version = "1.0.1" description = "Entity relationship diagrams for Python data model classes like Pydantic." readme = "README.md" authors = [{ name = "DrivenData", email = "info@drivendata.org" }, { name = "Jay Qi" }]