Skip to content

Commit 7053a99

Browse files
committed
Prevent the ArrayLike type from expanding into a mess in the documentation.
This type will need to be quoted until future annotations are enabled.
1 parent 0715349 commit 7053a99

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

tcod/noise.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def __getitem__(self, indexes: Any) -> "np.ndarray[Any, np.dtype[np.float32]]":
287287

288288
return out
289289

290-
def sample_mgrid(self, mgrid: ArrayLike) -> "np.ndarray[Any, np.dtype[np.float32]]":
290+
def sample_mgrid(self, mgrid: "ArrayLike") -> "np.ndarray[Any, np.dtype[np.float32]]":
291291
"""Sample a mesh-grid array and return the result.
292292
293293
The :any:`sample_ogrid` method performs better as there is a lot of
@@ -319,7 +319,7 @@ def sample_mgrid(self, mgrid: ArrayLike) -> "np.ndarray[Any, np.dtype[np.float32
319319
)
320320
return out
321321

322-
def sample_ogrid(self, ogrid: Sequence[ArrayLike]) -> "np.ndarray[Any, np.dtype[np.float32]]":
322+
def sample_ogrid(self, ogrid: "Sequence[ArrayLike]") -> "np.ndarray[Any, np.dtype[np.float32]]":
323323
"""Sample an open mesh-grid array and return the result.
324324
325325
Args

tcod/path.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class NodeCostArray(np.ndarray): # type: ignore
135135
np.uint32: ("uint32_t*", _get_pathcost_func("PathCostArrayUInt32")),
136136
}
137137

138-
def __new__(cls, array: ArrayLike) -> "NodeCostArray":
138+
def __new__(cls, array: "ArrayLike") -> "NodeCostArray":
139139
"""Validate a numpy array and setup a C callback."""
140140
self = np.asarray(array).view(cls)
141141
return self
@@ -353,8 +353,8 @@ def _compile_cost_edges(edge_map: Any) -> Tuple[Any, int]:
353353

354354

355355
def dijkstra2d(
356-
distance: ArrayLike,
357-
cost: ArrayLike,
356+
distance: "ArrayLike",
357+
cost: "ArrayLike",
358358
cardinal: Optional[int] = None,
359359
diagonal: Optional[int] = None,
360360
*,
@@ -512,7 +512,7 @@ def dijkstra2d(
512512
return out
513513

514514

515-
def _compile_bool_edges(edge_map: ArrayLike) -> Tuple[Any, int]:
515+
def _compile_bool_edges(edge_map: "ArrayLike") -> Tuple[Any, int]:
516516
"""Return an edge array using a boolean map."""
517517
edge_map = np.array(edge_map, copy=True)
518518
edge_center = edge_map.shape[0] // 2, edge_map.shape[1] // 2
@@ -523,7 +523,7 @@ def _compile_bool_edges(edge_map: ArrayLike) -> Tuple[Any, int]:
523523

524524

525525
def hillclimb2d(
526-
distance: ArrayLike,
526+
distance: "ArrayLike",
527527
start: Tuple[int, int],
528528
cardinal: Optional[bool] = None,
529529
diagonal: Optional[bool] = None,
@@ -781,7 +781,7 @@ def add_edge(
781781
def add_edges(
782782
self,
783783
*,
784-
edge_map: ArrayLike,
784+
edge_map: "ArrayLike",
785785
cost: "np.ndarray[Any, Any]",
786786
condition: "Optional[np.ndarray[Any, Any]]" = None,
787787
) -> None:
@@ -1024,7 +1024,7 @@ class SimpleGraph:
10241024
.. versionadded:: 11.15
10251025
"""
10261026

1027-
def __init__(self, *, cost: ArrayLike, cardinal: int, diagonal: int, greed: int = 1):
1027+
def __init__(self, *, cost: "ArrayLike", cardinal: int, diagonal: int, greed: int = 1):
10281028
cost = np.asarray(cost)
10291029
if cost.ndim != 2:
10301030
raise TypeError("The cost array must e 2 dimensional, array of shape %r given." % (cost.shape,))

tcod/tileset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_tile(self, codepoint: int) -> "np.ndarray[Any, np.dtype[np.uint8]]":
8484
)
8585
return tile
8686

87-
def set_tile(self, codepoint: int, tile: ArrayLike) -> None:
87+
def set_tile(self, codepoint: int, tile: "ArrayLike") -> None:
8888
"""Upload a tile into this array.
8989
9090
The tile can be in 32-bit color (height, width, rgba), or grey-scale

0 commit comments

Comments
 (0)