Skip to content

Commit 61d4399

Browse files
committed
Update type ignores for newest Numpy
1 parent 19784d3 commit 61d4399

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

examples/samples_tcod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ def on_draw(self) -> None:
12081208
# new pixels are based on absolute elapsed time
12091209
int_abs_t = int(self.abs_t)
12101210

1211-
texture = np.roll(texture, -int_t, 1) # type: ignore[assignment]
1211+
texture = np.roll(texture, -int_t, 1)
12121212
# replace new stretch of texture with new values
12131213
for v in range(RES_V - int_t, RES_V):
12141214
for u in range(RES_U):

tcod/path.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(
115115
super().__init__(callback, shape)
116116

117117

118-
class NodeCostArray(np.ndarray): # type: ignore[type-arg]
118+
class NodeCostArray(np.ndarray):
119119
"""Calculate cost from a numpy array of nodes.
120120
121121
`array` is a NumPy array holding the path-cost of each node.
@@ -596,7 +596,7 @@ def _world_array(shape: tuple[int, ...], dtype: DTypeLike = np.int32) -> NDArray
596596
)
597597

598598

599-
def _as_hashable(obj: np.ndarray[Any, Any] | None) -> object | None:
599+
def _as_hashable(obj: NDArray[Any] | None) -> object | None:
600600
"""Return NumPy arrays as a more hashable form."""
601601
if obj is None:
602602
return obj
@@ -772,7 +772,7 @@ def add_edge(
772772
cost = cost.T
773773
if condition is not None:
774774
condition = condition.T
775-
key = (_as_hashable(cost), _as_hashable(condition))
775+
key = (_as_hashable(cost), _as_hashable(condition)) # type: ignore[arg-type]
776776
try:
777777
rule = self._graph[key]
778778
except KeyError:
@@ -789,7 +789,7 @@ def add_edge(
789789
def add_edges(
790790
self,
791791
*,
792-
edge_map: ArrayLike,
792+
edge_map: ArrayLike | NDArray[np.integer],
793793
cost: NDArray[Any],
794794
condition: ArrayLike | None = None,
795795
) -> None:
@@ -894,16 +894,20 @@ def add_edges(
894894
# edge_map needs to be converted into C.
895895
# The other parameters are converted by the add_edge method.
896896
edge_map = edge_map.T
897-
edge_center = tuple(i // 2 for i in edge_map.shape)
898-
edge_map[edge_center] = 0
899-
edge_map[edge_map < 0] = 0
900-
edge_nz = edge_map.nonzero()
901-
edge_costs = edge_map[edge_nz]
897+
edge_center = tuple(i // 2 for i in edge_map.shape) # type: ignore[union-attr]
898+
edge_map[edge_center] = 0 # type: ignore[index]
899+
edge_map[edge_map < 0] = 0 # type: ignore[index, operator]
900+
edge_nz = edge_map.nonzero() # type: ignore[union-attr]
901+
edge_costs = edge_map[edge_nz] # type: ignore[index]
902902
edge_array = np.transpose(edge_nz)
903903
edge_array -= edge_center
904-
for edge, edge_cost in zip(edge_array, edge_costs, strict=True):
904+
for edge, edge_cost in zip(
905+
edge_array,
906+
edge_costs, # type: ignore[arg-type]
907+
strict=True,
908+
):
905909
self.add_edge(
906-
tuple(edge.tolist()), # type: ignore[arg-type]
910+
tuple(edge.tolist()),
907911
edge_cost,
908912
cost=cost,
909913
condition=condition,
@@ -1170,7 +1174,7 @@ def traversal(self) -> NDArray[Any]:
11701174
"""
11711175
if self._order == "F":
11721176
axes = range(self._travel.ndim)
1173-
return self._travel.transpose((*axes[-2::-1], axes[-1]))[..., ::-1]
1177+
return self._travel.transpose((*axes[-2::-1], axes[-1]))[..., ::-1] # type: ignore[no-any-return]
11741178
return self._travel
11751179

11761180
def clear(self) -> None:

tcod/sdl/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def convert_audio(
188188
out_length,
189189
)
190190
)
191-
return (
191+
return ( # type: ignore[no-any-return]
192192
np.frombuffer(ffi.buffer(out_buffer[0], out_length[0]), dtype=out_format).reshape(-1, out_channels).copy()
193193
)
194194
except RuntimeError as exc:

0 commit comments

Comments
 (0)