22import functools
33import textwrap
44from pathlib import Path
5- from typing import Callable , Dict , List , Tuple
5+ from typing import Callable
66
77import numpy as np
88from PIL import Image
@@ -125,7 +125,7 @@ def grid_print(grid: np.ndarray, generation: int) -> None:
125125
126126@timeit ()
127127def parse_grid (
128- text : str , size : Tuple [int , int ], pos : str = "C" , live : str = "O"
128+ text : str , size : tuple [int , int ], pos : str = "C" , live : str = "O"
129129) -> np .ndarray :
130130 lines = textwrap .dedent (text ).strip ().splitlines ()
131131 text_width = max (len (line ) for line in lines )
@@ -139,7 +139,7 @@ def parse_grid(
139139
140140 grid = np .zeros ((height , width ), dtype = "uint8" )
141141
142- pos_idx : Dict [str , Tuple [int , int ]] = {
142+ pos_idx : dict [str , tuple [int , int ]] = {
143143 "C" : (height // 2 - text_height // 2 , width // 2 - text_width // 2 ),
144144 "T" : (0 , width // 2 - text_width // 2 ),
145145 "B" : (height - text_height , width // 2 - text_width // 2 ),
@@ -166,7 +166,7 @@ def parse_grid(
166166def add_grid_frame (
167167 grid : np .ndarray ,
168168 generation : int ,
169- grid_frames : List [np .ndarray ],
169+ grid_frames : list [np .ndarray ],
170170 pixels_per_cell : int ,
171171) -> None :
172172 """Add the grid to the grid_frames"""
@@ -185,7 +185,7 @@ def enlarge_image(image: np.ndarray, ratio: int) -> np.ndarray:
185185
186186@timeit ()
187187def save_frames (
188- grid_frames : List [Image .Image ], filename : str , duration : int = 50
188+ grid_frames : list [Image .Image ], filename : str , duration : int = 50
189189) -> None :
190190 grid_frames [0 ].save (
191191 filename ,
@@ -196,7 +196,7 @@ def save_frames(
196196 )
197197
198198
199- def get_demo (name : str , size : Tuple [int , int ], pos : str = "C" ) -> np .ndarray :
199+ def get_demo (name : str , size : tuple [int , int ], pos : str = "C" ) -> np .ndarray :
200200 if name == "random" :
201201 return np .random .randint (0 , 2 , size , dtype = "uint8" )
202202
@@ -321,7 +321,7 @@ def main() -> None:
321321 grid = get_demo (args .demo , size , pos )
322322
323323 # Run Game of Life
324- grid_frames : List [Image .Image ] = []
324+ grid_frames : list [Image .Image ] = []
325325
326326 if args .debug_print :
327327 driver (grid , handler = grid_print , max_gen = max_gen )
0 commit comments