From a45967818c4614828085cfb30a02c8f21b98d20f Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Thu, 27 Jun 2024 22:24:57 -0700 Subject: [PATCH] v1.2.1 - fix dtypeerror inheritance --- docs/changelog.md | 7 +++++++ pyproject.toml | 2 +- tests/test_ndarray.py | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 41c0a7c..5066eb2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,13 @@ ## 1.* +### 1.2.1 - 24-06-27 + +Fix a minor bug where {class}`~numpydantic.exceptions.DtypeError` would not cause +pydantic to throw a {class}`pydantic.ValidationError` because custom validator functions +need to raise either `AssertionError` or `ValueError` - made `DtypeError` also +inherit from `ValueError` because that is also technically true. + ### 1.2.0 - 24-06-13 - Shape ranges - Add ability to specify shapes as ranges - see [shape ranges](shape-ranges) diff --git a/pyproject.toml b/pyproject.toml index ecb57ab..9f7996e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "numpydantic" -version = "1.2.0" +version = "1.2.1" description = "Type and shape validation and serialization for numpy arrays in pydantic models" authors = [ {name = "sneakers-the-rat", email = "sneakers-the-rat@protonmail.com"}, diff --git a/tests/test_ndarray.py b/tests/test_ndarray.py index f30cc98..9e45c1e 100644 --- a/tests/test_ndarray.py +++ b/tests/test_ndarray.py @@ -33,7 +33,7 @@ def test_ndarray_type(): with pytest.raises(ValidationError): instance = Model(array=np.zeros((4, 6))) - with pytest.raises(DtypeError): + with pytest.raises(ValidationError): instance = Model(array=np.ones((2, 3), dtype=bool)) instance = Model(array=np.zeros((2, 3)), array_any=np.ones((3, 4, 5))) @@ -112,7 +112,7 @@ def test_ndarray_coercion(): amod = Model(array=[1, 2, 3, 4.5]) assert np.allclose(amod.array, np.array([1, 2, 3, 4.5])) - with pytest.raises(DtypeError): + with pytest.raises(ValidationError): amod = Model(array=["a", "b", "c"])