@@ -85,9 +85,7 @@ def poisson_disc_samples(
8585 if not (0 <= new_point [0 ] < width and 0 <= new_point [1 ] < height ):
8686 continue
8787
88- grid_x , grid_y = int (new_point [0 ] // cell_size ), int (
89- new_point [1 ] // cell_size
90- )
88+ grid_x , grid_y = int (new_point [0 ] // cell_size ), int (new_point [1 ] // cell_size )
9189 too_close = False
9290
9391 for i in range (max (0 , grid_x - 2 ), min (grid_width , grid_x + 3 )):
@@ -229,9 +227,7 @@ def num(num: str) -> float | int:
229227 elif cmd in "Aa" :
230228 # arc commands have boolean parameters
231229 rx , ry , angle , la , sw , px , py = params
232- path_data .append (
233- command_map [cmd ](rx , ry , angle , bool (la ), bool (sw ), px , py )
234- )
230+ path_data .append (command_map [cmd ](rx , ry , angle , bool (la ), bool (sw ), px , py ))
235231 else :
236232 path_data .append (command_map [cmd ](* params ))
237233
@@ -259,9 +255,7 @@ def get_events(start: Week, end: Week) -> list[dict]:
259255 return group_events (events )
260256
261257
262- def backtrack (
263- groups : list [tuple [int , list [int ]]], grid : list [list [int ]]
264- ) -> list [list [int ]] | None :
258+ def backtrack (groups : list [tuple [int , list [int ]]], grid : list [list [int ]]) -> list [list [int ]] | None :
265259 """backtracking algorithm to fit items into grid"""
266260
267261 # base case, just return grid, we good :)
@@ -277,9 +271,7 @@ def backtrack(
277271 for col in range (num_cols - width + 1 ):
278272 # check if space is free
279273 is_free = all (
280- grid [i ][j ] == - 1
281- for i in range (row , row + height )
282- for j in range (col , col + width )
274+ grid [i ][j ] == - 1 for i in range (row , row + height ) for j in range (col , col + width )
283275 )
284276
285277 # try again if not free
@@ -385,9 +377,7 @@ def get_event_circle(event: dict) -> svg.G:
385377 title_size = CIRCLE_SIZE / 8 if len (title ) == 1 else CIRCLE_SIZE / 10
386378 location_size = CIRCLE_SIZE / 13 if len (location ) == 1 else CIRCLE_SIZE / 16
387379 time_size = location_size
388- font_sizes = (
389- [title_size ] * len (title ) + [location_size ] * len (location ) + [time_size ]
390- )
380+ font_sizes = [title_size ] * len (title ) + [location_size ] * len (location ) + [time_size ]
391381
392382 elements : list [svg .Element ] = [svg .Circle (cx = 0 , cy = 0 , r = radius , fill = colour )]
393383
@@ -415,7 +405,7 @@ def get_event_circle(event: dict) -> svg.G:
415405
416406 lines = title + location + [time_str ]
417407 current_y = text_top
418- for line , size in zip (lines , font_sizes ):
408+ for line , size in zip (lines , font_sizes , strict = True ):
419409 elements .append (
420410 svg .Text (
421411 text = line ,
@@ -472,10 +462,8 @@ def get_socials(width: float, height: float) -> svg.G:
472462 class_ = ["title" ],
473463 ),
474464 ]
475- for i , (icon , social_text ) in enumerate (zip (icons , text ), start = 2 ):
476- path , icon_width , icon_height , min_x , min_y = convert_path_to_list (
477- icon_paths [icon ]
478- )
465+ for i , (icon , social_text ) in enumerate (zip (icons , text , strict = True ), start = 2 ):
466+ path , icon_width , icon_height , min_x , min_y = convert_path_to_list (icon_paths [icon ])
479467 scale = desired_icon_width / icon_width
480468 cx = (min_x + icon_width / 2 ) * scale
481469 cy = (min_y + icon_height / 2 ) * scale
@@ -550,9 +538,7 @@ def create_single_week( # noqa: PLR0912, PLR0915
550538 num_rows , num_cols = len (grid ), len (grid [0 ])
551539
552540 # find position and sizing of grid
553- grid_height = (
554- (POST_HEIGHT / 1.5 ) if num_rows < 3 else (POST_HEIGHT / 1.35 ) # noqa: PLR2004
555- )
541+ grid_height = (POST_HEIGHT / 1.5 ) if num_rows < 3 else (POST_HEIGHT / 1.35 ) # noqa: PLR2004
556542 grid_width = POST_WIDTH
557543 grid_top = POST_HEIGHT / 4 + (POST_HEIGHT - POST_HEIGHT / 4 - grid_height ) / 2
558544
@@ -639,9 +625,7 @@ def create_single_week( # noqa: PLR0912, PLR0915
639625
640626 # work out extra translation required
641627 translate_x = base_x + row * cell_width + cell_width / 2
642- translate_y = (
643- base_y + col * cell_height + cell_height / 2 + DAY_TEXT_HEIGHT / 2
644- )
628+ translate_y = base_y + col * cell_height + cell_height / 2 + DAY_TEXT_HEIGHT / 2
645629
646630 # if spanning multiple columns, pull towards centre
647631 pull_y = 0 if col_width == 1 else pull_factor
@@ -682,7 +666,7 @@ def create_multi_week(events: list[dict], start: Week, end: Week) -> list[svg.El
682666 ]
683667
684668 # find the list of weeks in term
685- term_weeks = events [start .academic_year ]["terms" ][0 ]["weeks" ]
669+ term_weeks = events [start .academic_year ]["terms" ][0 ]["weeks" ] # noqa: F841
686670
687671 return elements
688672
@@ -788,8 +772,4 @@ def create_svg(start: Week, end: Week) -> str:
788772 else :
789773 elements .extend (create_multi_week (events , start , end ))
790774
791- return str (
792- svg .SVG (
793- elements = elements , viewBox = svg .ViewBoxSpec (0 , 0 , POST_WIDTH , POST_HEIGHT )
794- )
795- )
775+ return str (svg .SVG (elements = elements , viewBox = svg .ViewBoxSpec (0 , 0 , POST_WIDTH , POST_HEIGHT )))
0 commit comments