From 40e25757c72d801004f574d000836235a59fadaf Mon Sep 17 00:00:00 2001 From: maoake Date: Tue, 31 Mar 2026 22:31:48 +0200 Subject: [PATCH] starting mypy with maze --- src/amaz_lib/Maze.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/amaz_lib/Maze.py b/src/amaz_lib/Maze.py index dccd0c6..d4ffdc6 100644 --- a/src/amaz_lib/Maze.py +++ b/src/amaz_lib/Maze.py @@ -1,16 +1,16 @@ from dataclasses import dataclass - -import numpy +from numpy.typing import NDArray +from typing import Optional, Any @dataclass class Maze: - maze: numpy.ndarray + maze: Optional[NDArray[Any]] = None - def get_maze(self) -> numpy.ndarray | None: + def get_maze(self) -> Optional[NDArray[Any]]: return self.maze - def set_maze(self, new_maze: numpy.ndarray) -> None: + def set_maze(self, new_maze: NDArray[Any]) -> None: self.maze = new_maze def __str__(self) -> str: @@ -24,6 +24,9 @@ class Maze: return res def ascii_print(self) -> None: + if self.maze is None: + print("None") + return for cell in self.maze[0]: print("_", end="") if cell.get_north():