13
13
is_big_endian ,
14
14
)
15
15
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" )
17
21
18
22
TEST_IMAGE_SIZE = (10 , 10 )
19
23
@@ -94,14 +98,14 @@ def _test_img_equals_int32_pyarray(
94
98
("HSV" , fl_uint8_4_type , [0 , 1 , 2 ]),
95
99
),
96
100
)
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 :
98
102
img = hopper (mode )
99
103
100
104
# Resize to non-square
101
105
img = img .crop ((3 , 0 , 124 , 127 ))
102
106
assert img .size == (121 , 127 )
103
107
104
- arr = pyarrow .array (img )
108
+ arr = pyarrow .array (img ) # type: ignore[call-overload]
105
109
_test_img_equals_pyarray (img , arr , mask )
106
110
assert arr .type == dtype
107
111
@@ -118,8 +122,8 @@ def test_lifetime() -> None:
118
122
119
123
img = hopper ("L" )
120
124
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]
123
127
124
128
del img
125
129
@@ -136,8 +140,8 @@ def test_lifetime2() -> None:
136
140
137
141
img = hopper ("L" )
138
142
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]
141
145
142
146
assert arr_1 .sum ().as_py () > 0
143
147
del arr_1
@@ -152,7 +156,7 @@ def test_lifetime2() -> None:
152
156
153
157
154
158
class DataShape (NamedTuple ):
155
- dtype : Any
159
+ dtype : pyarrow . DataType
156
160
# Strictly speaking, elt should be a pixel or pixel component, so
157
161
# list[uint8][4], float, int, uint32, uint8, etc. But more
158
162
# correctly, it should be exactly the dtype from the line above.
0 commit comments