Skip to content

Commit 6807bd3

Browse files
radarherewiredfool
authored andcommitted
Added type hints
1 parent 78887f6 commit 6807bd3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.ci/requirements-mypy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IceSpringPySideStubs-PySide6
44
ipython
55
numpy
66
packaging
7+
pyarrow-stubs
78
pytest
89
sphinx
910
types-atheris

Tests/test_pyarrow.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
is_big_endian,
1414
)
1515

16-
pyarrow = pytest.importorskip("pyarrow", reason="PyArrow not installed")
16+
TYPE_CHECKING = False
17+
if TYPE_CHECKING:
18+
import pyarrow
19+
else:
20+
pyarrow = pytest.importorskip("pyarrow", reason="PyArrow not installed")
1721

1822
TEST_IMAGE_SIZE = (10, 10)
1923

@@ -94,14 +98,14 @@ def _test_img_equals_int32_pyarray(
9498
("HSV", fl_uint8_4_type, [0, 1, 2]),
9599
),
96100
)
97-
def test_to_array(mode: str, dtype: Any, mask: list[int] | None) -> None:
101+
def test_to_array(mode: str, dtype: pyarrow.DataType, mask: list[int] | None) -> None:
98102
img = hopper(mode)
99103

100104
# Resize to non-square
101105
img = img.crop((3, 0, 124, 127))
102106
assert img.size == (121, 127)
103107

104-
arr = pyarrow.array(img)
108+
arr = pyarrow.array(img) # type: ignore[call-overload]
105109
_test_img_equals_pyarray(img, arr, mask)
106110
assert arr.type == dtype
107111

@@ -118,8 +122,8 @@ def test_lifetime() -> None:
118122

119123
img = hopper("L")
120124

121-
arr_1 = pyarrow.array(img)
122-
arr_2 = pyarrow.array(img)
125+
arr_1 = pyarrow.array(img) # type: ignore[call-overload]
126+
arr_2 = pyarrow.array(img) # type: ignore[call-overload]
123127

124128
del img
125129

@@ -136,8 +140,8 @@ def test_lifetime2() -> None:
136140

137141
img = hopper("L")
138142

139-
arr_1 = pyarrow.array(img)
140-
arr_2 = pyarrow.array(img)
143+
arr_1 = pyarrow.array(img) # type: ignore[call-overload]
144+
arr_2 = pyarrow.array(img) # type: ignore[call-overload]
141145

142146
assert arr_1.sum().as_py() > 0
143147
del arr_1
@@ -152,7 +156,7 @@ def test_lifetime2() -> None:
152156

153157

154158
class DataShape(NamedTuple):
155-
dtype: Any
159+
dtype: pyarrow.DataType
156160
# Strictly speaking, elt should be a pixel or pixel component, so
157161
# list[uint8][4], float, int, uint32, uint8, etc. But more
158162
# correctly, it should be exactly the dtype from the line above.

0 commit comments

Comments
 (0)