From 12b4e2367c4ccfab2a443d8c6798bda8af45d3b7 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Tue, 13 Feb 2024 10:59:47 +0000 Subject: [PATCH] refactor: annotate method return type Add missing annotations for methods that return None. --- cell.py | 10 +++++----- graphics.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cell.py b/cell.py index 97eb636..7b20d18 100644 --- a/cell.py +++ b/cell.py @@ -11,7 +11,7 @@ class Cell: x1: int, y1: int, x2: int, y2: int, window: Window - ): + ) -> None: # Define the cell walls top_wall = Line(Point(x1, y1), Point(x2, y1)) bottom_wall = Line(Point(x1, y2), Point(x2, y2)) @@ -37,7 +37,7 @@ class Cell: bottom: bool = True, left: bool = True, right: bool = True, - ): + ) -> None: """ configure_walls configures the existence of the Cell's walls. """ @@ -52,7 +52,7 @@ class Cell: """ return self.__centre - def draw(self): + def draw(self) -> None: """ draw draws the cell onto the canvas """ @@ -65,7 +65,7 @@ class Cell: if self.__right_wall.exists: self.__window.draw_line(self.__right_wall.line) - def draw_move(self, to_cell: 'Cell', undo: bool = False): + def draw_move(self, to_cell: 'Cell', undo: bool = False) -> None: """ draw_move draws a path between the centre of this cell and the centre of the given cell. @@ -83,6 +83,6 @@ class CellWall: a Cell's wall. """ - def __init__(self, line: Line): + def __init__(self, line: Line) -> None: self.exists = True self.line = line diff --git a/graphics.py b/graphics.py index 8eda20d..9aebfac 100644 --- a/graphics.py +++ b/graphics.py @@ -16,11 +16,11 @@ class Line: Line represents a graphical line. """ - def __init__(self, point_a: Point, point_b: Point): + def __init__(self, point_a: Point, point_b: Point) -> None: self.point_a = point_a self.point_b = point_b - def draw(self, canvas: Canvas, fill_colour: str): + def draw(self, canvas: Canvas, fill_colour: str) -> None: """ draw draws a line on a given canvas. """ @@ -37,7 +37,7 @@ class Window: Window is a Graphical window. """ - def __init__(self, width: int, height: int): + def __init__(self, width: int, height: int) -> None: self.__root = Tk() self.__root.title("Maze Solver") self.__root.protocol("WM_DELETE_WINDOW", self.close) @@ -59,14 +59,14 @@ class Window: self.__is_running = False - def redraw(self): + def redraw(self) -> None: """ redraw redraws all the graphics in the window. """ self.__root.update_idletasks() self.__root.update() - def wait_for_close(self): + def wait_for_close(self) -> None: """ wait_for_close continuously redraws the window until it is set to close. @@ -75,13 +75,13 @@ class Window: while self.__is_running: self.redraw() - def draw_line(self, line: Line, fill_colour: str = "black"): + def draw_line(self, line: Line, fill_colour: str = "black") -> None: """ draw_line draws a line on the canvas. """ line.draw(self.__canvas, fill_colour) - def close(self): + def close(self) -> None: """ close sets the window to close. """