From 4643e1f512ec97747e0762c352d7340f8c4cce9f Mon Sep 17 00:00:00 2001 From: Alexandru Fikl <alexfikl@gmail.com> Date: Fri, 10 Jan 2025 10:52:15 +0200 Subject: [PATCH] tests: use Optional and Tuple to test decorator --- arraycontext/impl/pytato/fake_numpy.py | 2 +- test/test_utils.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arraycontext/impl/pytato/fake_numpy.py b/arraycontext/impl/pytato/fake_numpy.py index 21dc71e..a9158fd 100644 --- a/arraycontext/impl/pytato/fake_numpy.py +++ b/arraycontext/impl/pytato/fake_numpy.py @@ -240,6 +240,6 @@ class PytatoFakeNumpyNamespace(LoopyBasedFakeNumpyNamespace): return self.abs(a) def vdot(self, a: Array, b: Array): - return rec_multimap_array_container(pt.vdot, a, b) + # }}} diff --git a/test/test_utils.py b/test/test_utils.py index 3b74a42..eeef772 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import logging -from typing import cast +from typing import Optional, Tuple, cast # noqa: UP035 import numpy as np import pytest @@ -63,7 +63,7 @@ def test_dataclass_array_container() -> None: class ArrayContainerWithOptional: x: np.ndarray # Deliberately left as Optional to test compatibility. - y: np.ndarray | None + y: Optional[np.ndarray] # noqa: UP045 with pytest.raises(TypeError, match="Field 'y' union contains non-array"): # NOTE: cannot have wrapped annotations (here by `Optional`) @@ -76,7 +76,8 @@ def test_dataclass_array_container() -> None: @dataclass class ArrayContainerWithTuple: x: Array - y: tuple[Array, Array] + # Deliberately left as Tuple to test compatibility. + y: Tuple[Array, Array] # noqa: UP006 with pytest.raises(TypeError, match="Typing annotation not supported on field 'y'"): dataclass_array_container(ArrayContainerWithTuple) -- GitLab