refactor: annotate method return type
Add missing annotations for methods that return None.
This commit is contained in:
parent
45a003270a
commit
12b4e2367c
2 changed files with 12 additions and 12 deletions
10
cell.py
10
cell.py
|
@ -11,7 +11,7 @@ class Cell:
|
||||||
x1: int, y1: int,
|
x1: int, y1: int,
|
||||||
x2: int, y2: int,
|
x2: int, y2: int,
|
||||||
window: Window
|
window: Window
|
||||||
):
|
) -> None:
|
||||||
# Define the cell walls
|
# Define the cell walls
|
||||||
top_wall = Line(Point(x1, y1), Point(x2, y1))
|
top_wall = Line(Point(x1, y1), Point(x2, y1))
|
||||||
bottom_wall = Line(Point(x1, y2), Point(x2, y2))
|
bottom_wall = Line(Point(x1, y2), Point(x2, y2))
|
||||||
|
@ -37,7 +37,7 @@ class Cell:
|
||||||
bottom: bool = True,
|
bottom: bool = True,
|
||||||
left: bool = True,
|
left: bool = True,
|
||||||
right: bool = True,
|
right: bool = True,
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
configure_walls configures the existence of the Cell's walls.
|
configure_walls configures the existence of the Cell's walls.
|
||||||
"""
|
"""
|
||||||
|
@ -52,7 +52,7 @@ class Cell:
|
||||||
"""
|
"""
|
||||||
return self.__centre
|
return self.__centre
|
||||||
|
|
||||||
def draw(self):
|
def draw(self) -> None:
|
||||||
"""
|
"""
|
||||||
draw draws the cell onto the canvas
|
draw draws the cell onto the canvas
|
||||||
"""
|
"""
|
||||||
|
@ -65,7 +65,7 @@ class Cell:
|
||||||
if self.__right_wall.exists:
|
if self.__right_wall.exists:
|
||||||
self.__window.draw_line(self.__right_wall.line)
|
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
|
draw_move draws a path between the centre of this cell and
|
||||||
the centre of the given cell.
|
the centre of the given cell.
|
||||||
|
@ -83,6 +83,6 @@ class CellWall:
|
||||||
a Cell's wall.
|
a Cell's wall.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, line: Line):
|
def __init__(self, line: Line) -> None:
|
||||||
self.exists = True
|
self.exists = True
|
||||||
self.line = line
|
self.line = line
|
||||||
|
|
14
graphics.py
14
graphics.py
|
@ -16,11 +16,11 @@ class Line:
|
||||||
Line represents a graphical 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_a = point_a
|
||||||
self.point_b = point_b
|
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.
|
draw draws a line on a given canvas.
|
||||||
"""
|
"""
|
||||||
|
@ -37,7 +37,7 @@ class Window:
|
||||||
Window is a Graphical 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 = Tk()
|
||||||
self.__root.title("Maze Solver")
|
self.__root.title("Maze Solver")
|
||||||
self.__root.protocol("WM_DELETE_WINDOW", self.close)
|
self.__root.protocol("WM_DELETE_WINDOW", self.close)
|
||||||
|
@ -59,14 +59,14 @@ class Window:
|
||||||
|
|
||||||
self.__is_running = False
|
self.__is_running = False
|
||||||
|
|
||||||
def redraw(self):
|
def redraw(self) -> None:
|
||||||
"""
|
"""
|
||||||
redraw redraws all the graphics in the window.
|
redraw redraws all the graphics in the window.
|
||||||
"""
|
"""
|
||||||
self.__root.update_idletasks()
|
self.__root.update_idletasks()
|
||||||
self.__root.update()
|
self.__root.update()
|
||||||
|
|
||||||
def wait_for_close(self):
|
def wait_for_close(self) -> None:
|
||||||
"""
|
"""
|
||||||
wait_for_close continuously redraws the window until
|
wait_for_close continuously redraws the window until
|
||||||
it is set to close.
|
it is set to close.
|
||||||
|
@ -75,13 +75,13 @@ class Window:
|
||||||
while self.__is_running:
|
while self.__is_running:
|
||||||
self.redraw()
|
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.
|
draw_line draws a line on the canvas.
|
||||||
"""
|
"""
|
||||||
line.draw(self.__canvas, fill_colour)
|
line.draw(self.__canvas, fill_colour)
|
||||||
|
|
||||||
def close(self):
|
def close(self) -> None:
|
||||||
"""
|
"""
|
||||||
close sets the window to close.
|
close sets the window to close.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue