v1.2.1 - fix dtypeerror inheritance

This commit is contained in:
sneakers-the-rat 2024-06-27 22:24:57 -07:00
parent 3544ce2bdc
commit a45967818c
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
3 changed files with 10 additions and 3 deletions

View file

@ -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)

View file

@ -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"},

View file

@ -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"])