@@ -110,7 +110,7 @@ def __init__(
110110 width : int ,
111111 height : int ,
112112 order : Literal ["C" , "F" ] = "C" ,
113- buffer : Optional [np .ndarray ] = None ,
113+ buffer : " Optional[np.ndarray[Any, Any]]" = None ,
114114 ):
115115 self ._key_color = None # type: Optional[Tuple[int, int, int]]
116116 self ._order = tcod ._internal .verify_order (order )
@@ -181,7 +181,7 @@ def _init_setup_console_data(self, order: Literal["C", "F"] = "C") -> None:
181181 else :
182182 self ._console_data = ffi .cast ("struct TCOD_Console*" , self .console_c )
183183
184- self ._tiles = np .frombuffer (
184+ self ._tiles = np .frombuffer ( # type: ignore
185185 ffi .buffer (self ._console_data .tiles [0 : self .width * self .height ]),
186186 dtype = self .DTYPE ,
187187 ).reshape ((self .height , self .width ))
@@ -199,7 +199,7 @@ def height(self) -> int:
199199 return lib .TCOD_console_get_height (self .console_c ) # type: ignore
200200
201201 @property
202- def bg (self ) -> np .ndarray :
202+ def bg (self ) -> " np.ndarray[Any, np.dtype[np.uint8]]" :
203203 """A uint8 array with the shape (height, width, 3).
204204
205205 You can change the consoles background colors by using this array.
@@ -208,27 +208,27 @@ def bg(self) -> np.ndarray:
208208 ``console.bg[x, y, channel] # order='F'``.
209209
210210 """
211- bg = self ._tiles ["bg" ][..., :3 ] # type: np.ndarray
211+ bg : np . ndarray [ Any , np . dtype [ np . uint8 ]] = self ._tiles ["bg" ][..., :3 ]
212212 if self ._order == "F" :
213213 bg = bg .transpose (1 , 0 , 2 )
214214 return bg
215215
216216 @property
217- def fg (self ) -> np .ndarray :
217+ def fg (self ) -> " np.ndarray[Any, np.dtype[np.uint8]]" :
218218 """A uint8 array with the shape (height, width, 3).
219219
220220 You can change the consoles foreground colors by using this array.
221221
222222 Index this array with ``console.fg[i, j, channel] # order='C'`` or
223223 ``console.fg[x, y, channel] # order='F'``.
224224 """
225- fg = self ._tiles ["fg" ][..., :3 ] # type: np.ndarray
225+ fg : np . ndarray [ Any , np . dtype [ np . uint8 ]] = self ._tiles ["fg" ][..., :3 ]
226226 if self ._order == "F" :
227227 fg = fg .transpose (1 , 0 , 2 )
228228 return fg
229229
230230 @property
231- def ch (self ) -> np .ndarray :
231+ def ch (self ) -> " np.ndarray[Any, np.dtype[np.intc]]" :
232232 """An integer array with the shape (height, width).
233233
234234 You can change the consoles character codes by using this array.
@@ -240,7 +240,7 @@ def ch(self) -> np.ndarray:
240240
241241 @property # type: ignore
242242 @deprecate ("This attribute has been renamed to `rgba`." )
243- def tiles (self ) -> np .ndarray :
243+ def tiles (self ) -> " np.ndarray[Any, Any]" :
244244 """An array of this consoles raw tile data.
245245
246246 This acts as a combination of the `ch`, `fg`, and `bg` attributes.
@@ -256,7 +256,7 @@ def tiles(self) -> np.ndarray:
256256
257257 @property # type: ignore
258258 @deprecate ("This attribute has been renamed to `rgba`." )
259- def buffer (self ) -> np .ndarray :
259+ def buffer (self ) -> " np.ndarray[Any, Any]" :
260260 """An array of this consoles raw tile data.
261261
262262 .. versionadded:: 11.4
@@ -268,7 +268,7 @@ def buffer(self) -> np.ndarray:
268268
269269 @property # type: ignore
270270 @deprecate ("This attribute has been renamed to `rgb`." )
271- def tiles_rgb (self ) -> np .ndarray :
271+ def tiles_rgb (self ) -> " np.ndarray[Any, Any]" :
272272 """An array of this consoles data without the alpha channel.
273273
274274 .. versionadded:: 11.8
@@ -280,7 +280,7 @@ def tiles_rgb(self) -> np.ndarray:
280280
281281 @property # type: ignore
282282 @deprecate ("This attribute has been renamed to `rgb`." )
283- def tiles2 (self ) -> np .ndarray :
283+ def tiles2 (self ) -> " np.ndarray[Any, Any]" :
284284 """This name is deprecated in favour of :any:`rgb`.
285285
286286 .. versionadded:: 11.3
@@ -291,7 +291,7 @@ def tiles2(self) -> np.ndarray:
291291 return self .rgb
292292
293293 @property
294- def rgba (self ) -> np .ndarray :
294+ def rgba (self ) -> " np.ndarray[Any, Any]" :
295295 """An array of this consoles raw tile data.
296296
297297 The axes of this array is affected by the `order` parameter given to
@@ -312,7 +312,7 @@ def rgba(self) -> np.ndarray:
312312 return self ._tiles .T if self ._order == "F" else self ._tiles
313313
314314 @property
315- def rgb (self ) -> np .ndarray :
315+ def rgb (self ) -> " np.ndarray[Any, Any]" :
316316 """An array of this consoles data without the alpha channel.
317317
318318 The axes of this array is affected by the `order` parameter given to
@@ -888,13 +888,13 @@ def __getstate__(self) -> Any:
888888 "back" : self .default_bg ,
889889 }
890890 if self .console_c == ffi .NULL :
891- state ["_tiles" ] = np .copy (self ._tiles )
891+ state ["_tiles" ] = np .array (self ._tiles , copy = True )
892892 return state
893893
894894 def __setstate__ (self , state : Any ) -> None :
895895 self ._key_color = None
896896 if "_tiles" not in state :
897- tiles = np .ndarray ((self .height , self .width ), dtype = self .DTYPE )
897+ tiles : np . ndarray [ Any , Any ] = np .ndarray ((self .height , self .width ), dtype = self .DTYPE )
898898 tiles ["ch" ] = state ["_ch" ]
899899 tiles ["fg" ][..., :3 ] = state ["_fg" ]
900900 tiles ["fg" ][..., 3 ] = 255
0 commit comments