Skip to content

Commit c913a3e

Browse files
authored
Run lints
Signed-off-by: GitHub <noreply@github.com>
1 parent 89d690e commit c913a3e

File tree

7 files changed

+55
-53
lines changed

7 files changed

+55
-53
lines changed

events/advent_of_code/2015/03/python/aoc_2015_03.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def part_one(movements: list[str]) -> int:
66
delivered_presets = defaultdict(int)
77
current_x, current_y = 0, 0
8-
delivered_presets[(current_x, current_y)] += 1
8+
delivered_presets[current_x, current_y] += 1
99
for movement in movements:
1010
match movement:
1111
case "^":
@@ -16,15 +16,15 @@ def part_one(movements: list[str]) -> int:
1616
current_x -= 1
1717
case ">":
1818
current_x += 1
19-
delivered_presets[(current_x, current_y)] += 1
19+
delivered_presets[current_x, current_y] += 1
2020
return len(delivered_presets.keys())
2121

2222

2323
def part_two(movements: list[str]) -> int:
2424
delivered_presets = defaultdict(int)
2525
santa_x, santa_y = 0, 0
2626
robot_x, robot_y = 0, 0
27-
delivered_presets[(0, 0)] += 2
27+
delivered_presets[0, 0] += 2
2828
for index, movement in enumerate(movements):
2929
diff_x, diff_y = 0, 0
3030
match movement:
@@ -39,11 +39,11 @@ def part_two(movements: list[str]) -> int:
3939
if index % 2 == 0:
4040
santa_x += diff_x
4141
santa_y += diff_y
42-
delivered_presets[(santa_x, santa_y)] += 1
42+
delivered_presets[santa_x, santa_y] += 1
4343
else:
4444
robot_x += diff_x
4545
robot_y += diff_y
46-
delivered_presets[(robot_x, robot_y)] += 1
46+
delivered_presets[robot_x, robot_y] += 1
4747
return len(delivered_presets.keys())
4848

4949

events/advent_of_code/2015/06/python/aoc_2015_06.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def part_two(events: list[Event]) -> int:
5050
for y in range(event.start_y, event.end_y + 1):
5151
match event.action:
5252
case "on":
53-
brightnesses[(x, y)] += 1
53+
brightnesses[x, y] += 1
5454
case "off":
55-
brightnesses[(x, y)] -= 1
56-
brightnesses[(x, y)] = max(brightnesses[(x, y)], 0)
55+
brightnesses[x, y] -= 1
56+
brightnesses[x, y] = max(brightnesses[x, y], 0)
5757
case "toggle":
58-
brightnesses[(x, y)] += 2
58+
brightnesses[x, y] += 2
5959

6060
return sum(brightnesses.values())
6161

events/advent_of_code/2023/03/python/aoc_2023_03.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def find_part_numbers_in_grid(
5656
grid[row_index][number_started_on : number_ended_on + 1],
5757
),
5858
)
59-
part_numbers[(number, row_index, number_started_on)] = find_adjacent_symbol(
59+
part_numbers[number, row_index, number_started_on] = find_adjacent_symbol(
6060
grid,
6161
row_index,
6262
number_started_on,

events/advent_of_code/2024/01/python/aoc_2024_01.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def parse_input(text: str) -> tuple[list[int], list[int]]:
66
rows = text.strip().split("\n")
7-
7+
88
left = []
99
right = []
1010
for row in rows:
@@ -28,4 +28,4 @@ def part2(left: list[int], right: list[int]) -> int:
2828
if __name__ == "__main__":
2929
rows = Path("../input.txt").read_text(encoding="locale")
3030
print(part1(*parse_input(rows)))
31-
print(part2(*parse_input(rows)))
31+
print(part2(*parse_input(rows)))

events/advent_of_code/2024/01/python/test_aoc_2024_01.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
from aoc_2024_01 import parse_input, part1, part2
32

43
TEST_INPUT = """
@@ -10,11 +9,14 @@
109
3 3
1110
"""
1211

12+
1313
def test_parse_input() -> None:
1414
assert parse_input(TEST_INPUT) == ([1, 2, 3, 3, 3, 4], [3, 3, 3, 4, 5, 9])
1515

16+
1617
def test_part1() -> None:
1718
assert part1(*parse_input(TEST_INPUT)) == 11
1819

20+
1921
def test_part2() -> None:
2022
assert part2(*parse_input(TEST_INPUT)) == 31

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@ ignore = [
6666
"D103", # (Missing docstring in public function) - Not really doc-ing here
6767
"D104", # (Missing docstring in public package) - Not really doc-ing here
6868
"D105", # (Missing docstring in magic method) - Not really doc-ing here
69+
"DOC", # (pydoclint) - Not really doc-ing here
6970
"S311", # (Standard pseudo-random generators are not suitable for security/cryptographic purposes) - Not doing crypto here
7071
"PLR2004", # (Magic value used in comparison) - Lots of single use numbers in AoC
7172
"PLC2701", # (Private name import `x` from external module `x`) - Testing internal methods in AoC
7273
"C901", # (Function is too complex) - I completely agree, but it's AoC
7374
]
7475

76+
[tool.ruff.lint.extend-per-file-ignores]
77+
"scratch/games/the-farmer-was-replaced/code.py" = [
78+
"F821", # (Undefined name `x`)
79+
"ANN001", # (Missing type annotation for function argument `x`)
80+
]
81+
7582
[tool.ruff.lint.pydocstyle]
7683
convention = "numpy"

scratch/games/the-farmer-was-replaced/code.py

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def move_to_pos(x, y):
1+
def move_to_pos(x, y) -> None:
22
current_x = get_pos_x()
33
current_y = get_pos_y()
44

@@ -26,62 +26,55 @@ def move_to_pos(x, y):
2626
move_to_pos(0, 0)
2727

2828

29-
def odd(a):
30-
if a % 2 == 0:
31-
return False
32-
else:
33-
return True
29+
def odd(a) -> bool:
30+
return a % 2 != 0
3431

3532

36-
def even(a):
37-
if a % 2 == 0:
38-
return True
39-
else:
40-
return False
33+
def even(a) -> bool:
34+
return a % 2 == 0
4135

4236

43-
def tplace():
44-
if odd(get_pos_x()) == False and odd(get_pos_y()) == False:
37+
def tplace() -> bool | None:
38+
if odd(get_pos_x()) is False and odd(get_pos_y()) is False:
4539
return True
46-
elif odd(get_pos_x()) == True and odd(get_pos_y()) == True:
40+
if odd(get_pos_x()) is True and odd(get_pos_y()) is True:
4741
return True
42+
return None
4843

4944

5045
while True:
51-
for i in range(get_world_size()):
46+
for _i in range(get_world_size()):
5247
if get_pos_y() == 0:
5348
plant(Entities.grass)
5449
if can_harvest():
5550
harvest()
5651

57-
else:
58-
if tplace() == True:
59-
if get_ground_type() == Grounds.Soil:
60-
pass
61-
else:
62-
till()
52+
elif tplace() is True:
53+
if get_ground_type() == Grounds.Soil:
54+
pass
55+
else:
56+
till()
6357

64-
plant(Entities.Tree)
58+
plant(Entities.Tree)
6559

66-
if get_water() < 0.5:
67-
use_item(Items.Water_Tank)
60+
if get_water() < 0.5:
61+
use_item(Items.Water_Tank)
6862

69-
else:
70-
if (
71-
get_ground_type() == Grounds.soil
72-
and get_entity_type() == Entities.Carrots
73-
and can_harvest() == True
74-
):
75-
harvest()
76-
trade(Items.Carrot_Seed)
77-
plant(Entities.Carrots)
78-
elif get_ground_type() != Grounds.Soil:
79-
till()
80-
trade(Items.Carrot_Seed)
81-
plant(Entities.Carrots)
82-
elif get_ground_type() == Grounds.Soil and get_entity_type() != Entities.Carrots:
83-
trade(Items.Carrot_Seed)
84-
plant(Entities.Carrots)
63+
elif (
64+
get_ground_type() == Grounds.soil
65+
and get_entity_type() == Entities.Carrots
66+
and can_harvest() is True
67+
):
68+
harvest()
69+
trade(Items.Carrot_Seed)
70+
plant(Entities.Carrots)
71+
elif get_ground_type() != Grounds.Soil:
72+
till()
73+
trade(Items.Carrot_Seed)
74+
plant(Entities.Carrots)
75+
elif get_ground_type() == Grounds.Soil and get_entity_type() != Entities.Carrots:
76+
trade(Items.Carrot_Seed)
77+
plant(Entities.Carrots)
8578
move(East)
8679
if can_harvest():
8780
harvest()

0 commit comments

Comments
 (0)