Skip to content

Commit f278914

Browse files
authored
Run lints
Signed-off-by: Bradley Reynolds <[email protected]>
1 parent c1212ed commit f278914

File tree

11 files changed

+26
-17
lines changed

11 files changed

+26
-17
lines changed

events/advent_of_code/2022/05/python/aoc_2022_05.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import re
2-
from collections.abc import Iterable
32
from dataclasses import dataclass
43
from pathlib import Path
4+
from typing import TYPE_CHECKING
55

66
from darbia.utils.iterables import chunks
77

8+
if TYPE_CHECKING:
9+
from collections.abc import Iterable
10+
811

912
@dataclass(frozen=True)
1013
class Movement:
@@ -18,7 +21,7 @@ class Ship:
1821
stacks: dict[int, list[str]]
1922

2023
@classmethod
21-
def build_from(cls, text: str) -> "Ship":
24+
def build_from(cls, text: str) -> Ship:
2225
header, *lines = list(reversed(text.splitlines()))
2326
stack_count = len(header.split())
2427
ship = Ship({index: [] for index in range(1, stack_count + 1)})

events/advent_of_code/2022/07/python/aoc_2022_07.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_item_at_path(self, keypath: list[str], item: File | Folder) -> None:
3939
def walk(
4040
self,
4141
top: type[Self] | None = None,
42-
) -> Generator[tuple[list[Folder], list[File]], None, None]:
42+
) -> Generator[tuple[list[Folder], list[File]]]:
4343
if top is None:
4444
top = self
4545
folders = [item for item in top.contents.values() if isinstance(item, Folder)]

events/advent_of_code/2022/09/python/aoc_2022_09.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Movement:
2424
steps: int
2525

2626
@classmethod
27-
def build_from(cls, text: str) -> "Movement":
27+
def build_from(cls, text: str) -> Movement:
2828
direction_, steps_ = text.split()
2929
return cls(DIRECTION_MAP[direction_], int(steps_))
3030

events/advent_of_code/2022/11/python/aoc_2022_11.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import operator
2-
from collections.abc import Callable
32
from dataclasses import dataclass, field
43
from math import floor, prod
54
from pathlib import Path
6-
from typing import Final, Self
5+
from typing import TYPE_CHECKING, Final, Self
76

87
from parse import parse
98

9+
if TYPE_CHECKING:
10+
from collections.abc import Callable
11+
1012
OPERATOR_FUNCTIONS: Final[dict[str, Callable]] = {
1113
"+": operator.add,
1214
"-": operator.sub,

events/advent_of_code/2023/02/python/aoc_2023_02.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SetOfDice:
1616
dice: list[Dice]
1717

1818
@classmethod
19-
def from_str(cls, text: str) -> "SetOfDice":
19+
def from_str(cls, text: str) -> SetOfDice:
2020
dice = []
2121
dice_chunks = text.split(",")
2222
for dice_chunk in dice_chunks:
@@ -31,7 +31,7 @@ class Game:
3131
sets: list[SetOfDice]
3232

3333
@classmethod
34-
def from_row(cls, row: str) -> "Game":
34+
def from_row(cls, row: str) -> Game:
3535
game_id_text, dice_sets = row.split(":")
3636
game_id = int(game_id_text[5:])
3737
sets = [SetOfDice.from_str(dice_set) for dice_set in dice_sets.split(";")]

events/advent_of_code/2023/05/python/aoc_2023_05.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Almanac:
99
maps: list[list[tuple[int, int, int]]]
1010

1111
@classmethod
12-
def from_text(cls, text: str) -> "Almanac":
12+
def from_text(cls, text: str) -> Almanac:
1313
lines = text.split("\n\n")
1414
seeds = [int(s) for s in lines[0].split(":")[1].split()]
1515

events/advent_of_code/2023/06/python/aoc_2023_06.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dataclasses import dataclass
2-
from itertools import starmap
32
from math import prod
43
from pathlib import Path
54

@@ -20,11 +19,11 @@ class Paper:
2019
races: list[Race]
2120

2221
@classmethod
23-
def from_text(cls, text: str) -> "Paper":
22+
def from_text(cls, text: str) -> Paper:
2423
time_line, distance_line = text.strip().split("\n")
2524
times = [int(time) for time in time_line.split()[1:]]
2625
distances = [int(distance) for distance in distance_line.split()[1:]]
27-
return cls(races=list(starmap(Race, zip(times, distances, strict=False))))
26+
return cls(races=list(map(Race, times, distances, strict=False)))
2827

2928
def count_possible_wins(self) -> int:
3029
return Race(

events/advent_of_code/2024/02/python/aoc_2024_02.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import collections
2-
from collections.abc import Generator, Iterable
32
from dataclasses import dataclass
43
from itertools import islice
54
from pathlib import Path
6-
from typing import Any
5+
from typing import TYPE_CHECKING, Any
6+
7+
if TYPE_CHECKING:
8+
from collections.abc import Generator, Iterable
79

810

911
def sliding_window(iterable: Iterable, n: int) -> Generator[tuple[Any, ...]]:

events/code-jam-qualifier-9/code-jam-9-qualifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self) -> None:
2222
"""Instantiate the staff."""
2323
self.staff = {}
2424

25-
def register_worker(self, request: "Request") -> None:
25+
def register_worker(self, request: Request) -> None:
2626
"""Register a worker."""
2727
self.staff[request.scope["id"]] = Worker(request)
2828

scratch/languages/python/fizzbuzz/fizzbuzz.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Example FizzBuzz snippet."""
22

3-
from collections.abc import Iterator
3+
from typing import TYPE_CHECKING
4+
5+
if TYPE_CHECKING:
6+
from collections.abc import Iterator
47

58

69
def fizzbuzz(

0 commit comments

Comments
 (0)