Skip to content

Commit

Permalink
tests: use Optional and Tuple to test decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Jan 10, 2025
1 parent bc7139f commit 4643e1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion arraycontext/impl/pytato/fake_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ def absolute(self, a):
return self.abs(a)

def vdot(self, a: Array, b: Array):

return rec_multimap_array_container(pt.vdot, a, b)

# }}}
7 changes: 4 additions & 3 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
THE SOFTWARE.
"""
import logging
from typing import cast
from typing import Optional, Tuple, cast # noqa: UP035

import numpy as np
import pytest
Expand Down Expand Up @@ -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`)
Expand All @@ -76,7 +76,8 @@ class ArrayContainerWithOptional:
@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)
Expand Down

0 comments on commit 4643e1f

Please sign in to comment.