Skip to content

Commit

Permalink
[2018] Fixes for the latest pylint (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarnung authored Dec 3, 2023
1 parent b640ea2 commit 4fb119d
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions 2018/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ min-public-methods=2
[EXCEPTIONS]

# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception


[FORMAT]
Expand Down
2 changes: 1 addition & 1 deletion 2018/day07/day07.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _get_execution_time(node, base_time=0):
def _parse_instruction(line):
match = _INSTRUCTION_REGEX.match(line)
if not match:
raise Exception('Failed to parse input')
raise ValueError('Failed to parse input')

return (match.group(1), match.group(2))

Expand Down
2 changes: 1 addition & 1 deletion 2018/day09/day09.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def remove(self):
def _parse_instruction(instruction):
match = _INSTRUCTION_REGEX.match(instruction)
if not match:
raise Exception('Invalid instruction')
raise ValueError('Invalid instruction')

return (int(match.group(1)), int(match.group(2)))

Expand Down
2 changes: 1 addition & 1 deletion 2018/day10/day10.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _parse_entry(input_str):
"""Parse the entry that contains the starting point and velocity."""
match = _ENTRY_REGEX.match(input_str)
if not match:
raise Exception('Invalid input string')
raise ValueError('Invalid input string')

return LightPoint(
Point2D(int(match.group(1)), int(match.group(2))),
Expand Down
4 changes: 2 additions & 2 deletions 2018/day12/day12.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _parse_input(file_content):
list_iter = iter(file_content)
match = _INITIAL_STATE_REGEX.match(next(list_iter))
if not match:
raise Exception('Invalid initial state')
raise ValueError('Invalid initial state')

initial_state = match.group(1)

Expand All @@ -30,7 +30,7 @@ def _parse_input(file_content):
for rule in list_iter:
match = _RULE_REGEX.match(rule)
if not match:
raise Exception('Invalid rule pattern')
raise ValueError('Invalid rule pattern')

rules.append((match.group(1), match.group(2)))

Expand Down
4 changes: 2 additions & 2 deletions 2018/day13/day13.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def update_direction(self, next_track):
# Nothing to do
pass
else:
raise Exception('Unexpected track')
raise ValueError('Unexpected track')

def move_once(self):
"""Update the position of the cart."""
Expand All @@ -69,7 +69,7 @@ def move_once(self):
elif self.direction == 3:
self.cell_index -= 1
else:
raise Exception('Invalid direction')
raise ValueError('Invalid direction')

def _turn(self, delta):
self.direction = (self.direction + delta) % len(_CART_DIRECTIONS)
Expand Down
2 changes: 1 addition & 1 deletion 2018/day15/day15.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, initial_state, elf_power=3):
Unit(col, (row_index, col_index), elf_power))
row[col_index] = '.'
elif col not in ('#', '.'):
raise Exception('Unexpected tile type')
raise ValueError('Unexpected tile type')

def __str__(self):
board = [col for col in row for row in self.board]
Expand Down
2 changes: 1 addition & 1 deletion 2018/day17/day17.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _parse_clay(file_content):
for line in file_content:
match = _SPAN_REGEX.match(line)
if not match:
raise Exception('Invalid line')
raise ValueError('Invalid line')

flipped = match.group(1) == 'y'
first = int(match.group(2))
Expand Down
2 changes: 1 addition & 1 deletion 2018/day18/day18.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def execute_minute(self):
self._has_neighbors(position, '|', 1)):
area_copy[position] = '.'
else:
raise Exception('Unexpected character')
raise ValueError('Unexpected character')

self.area = area_copy

Expand Down
8 changes: 4 additions & 4 deletions 2018/day20/day20.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, input_str):
current_node = current_root

if input_str[current_index] != '^':
raise Exception('Invalid pattern')
raise ValueError('Invalid pattern')

current_index += 1
while current_index < len(input_str):
Expand All @@ -63,11 +63,11 @@ def __init__(self, input_str):
current_node = current_node.connect(TreeNode(current))
break
else:
raise Exception('Invalid character')
raise ValueError('Invalid character')
current_index += 1

if root_stack:
raise Exception('Malformed input')
raise ValueError('Malformed input')

self.root = current_root

Expand Down Expand Up @@ -186,7 +186,7 @@ def _get_door_type(direction):
if direction in ('E', 'W'):
return '|'

raise Exception('Invalid direction')
raise ValueError('Invalid direction')

@staticmethod
def _get_direction(direction):
Expand Down
4 changes: 2 additions & 2 deletions 2018/day22/day22.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ def _is_item_valid(self, position, item):
# Nothing or torch
return item in (0, 1)

raise Exception('Invalid region type')
raise ValueError('Invalid region type')

def _get_intersecting_item(self, current_position, next_position):
for item in range(3):
if (self._is_item_valid(current_position, item) and
self._is_item_valid(next_position, item)):
return item

raise Exception('Invalid combination of types')
raise ValueError('Invalid combination of types')

def _get_region_type(self, position):
return self._get_erosion_level(position) % 3
Expand Down
2 changes: 1 addition & 1 deletion 2018/day23/day23.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def from_string(data):
"""Create a nanobot from input data."""
match = _POSITIONS_REGEX.match(data)
if not match:
raise Exception('Invalid nanobot data')
raise ValueError('Invalid nanobot data')

position = Point3D(
int(match.group(1)),
Expand Down
10 changes: 5 additions & 5 deletions 2018/day24/day24.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def parse_modifiers(self, line):
for modifier in line.split('; '):
match = _MODIFIER_REGEX.match(modifier)
if not match:
raise Exception('Could not locate modifiers')
raise ValueError('Could not locate modifiers')

modifier_set = None
modifier_category = match.group(1)
Expand All @@ -96,7 +96,7 @@ def parse_modifiers(self, line):
elif modifier_category == 'immune':
modifier_set = self._immunities
else:
raise Exception('Unknown modifier category encountered')
raise ValueError('Unknown modifier category encountered')

for modifier_type in match.group(2).split(', '):
modifier_set.add(modifier_type)
Expand All @@ -123,7 +123,7 @@ def parse(team_name, line):
"""Parse the group from the provided text."""
group_match = _GROUP_REGEX.match(line)
if not group_match:
raise Exception('Could not locate group')
raise ValueError('Could not locate group')

group = Group(
team_name,
Expand Down Expand Up @@ -228,7 +228,7 @@ def _parse_team(group_list, lines):
"""Parse the team from the provided lines of text."""
team_match = _TEAM_REGEX.match(next(lines))
if not team_match:
raise Exception('Could not locate team')
raise ValueError('Could not locate team')

team_name = team_match.group(1)

Expand All @@ -253,7 +253,7 @@ def _load_groups(file_content):
pass

if team_count != 2:
raise Exception('Failed to find two teams')
raise ValueError('Failed to find two teams')

return groups

Expand Down

0 comments on commit 4fb119d

Please sign in to comment.