Skip to content

Commit 4fb119d

Browse files
authored
[2018] Fixes for the latest pylint (#51)
1 parent b640ea2 commit 4fb119d

File tree

13 files changed

+24
-24
lines changed

13 files changed

+24
-24
lines changed

2018/.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ min-public-methods=2
206206
[EXCEPTIONS]
207207

208208
# Exceptions that will emit a warning when caught.
209-
overgeneral-exceptions=BaseException,
210-
Exception
209+
overgeneral-exceptions=builtins.BaseException,
210+
builtins.Exception
211211

212212

213213
[FORMAT]

2018/day07/day07.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _get_execution_time(node, base_time=0):
113113
def _parse_instruction(line):
114114
match = _INSTRUCTION_REGEX.match(line)
115115
if not match:
116-
raise Exception('Failed to parse input')
116+
raise ValueError('Failed to parse input')
117117

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

2018/day09/day09.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def remove(self):
5858
def _parse_instruction(instruction):
5959
match = _INSTRUCTION_REGEX.match(instruction)
6060
if not match:
61-
raise Exception('Invalid instruction')
61+
raise ValueError('Invalid instruction')
6262

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

2018/day10/day10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _parse_entry(input_str):
115115
"""Parse the entry that contains the starting point and velocity."""
116116
match = _ENTRY_REGEX.match(input_str)
117117
if not match:
118-
raise Exception('Invalid input string')
118+
raise ValueError('Invalid input string')
119119

120120
return LightPoint(
121121
Point2D(int(match.group(1)), int(match.group(2))),

2018/day12/day12.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _parse_input(file_content):
2020
list_iter = iter(file_content)
2121
match = _INITIAL_STATE_REGEX.match(next(list_iter))
2222
if not match:
23-
raise Exception('Invalid initial state')
23+
raise ValueError('Invalid initial state')
2424

2525
initial_state = match.group(1)
2626

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

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

2018/day13/day13.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def update_direction(self, next_track):
5656
# Nothing to do
5757
pass
5858
else:
59-
raise Exception('Unexpected track')
59+
raise ValueError('Unexpected track')
6060

6161
def move_once(self):
6262
"""Update the position of the cart."""
@@ -69,7 +69,7 @@ def move_once(self):
6969
elif self.direction == 3:
7070
self.cell_index -= 1
7171
else:
72-
raise Exception('Invalid direction')
72+
raise ValueError('Invalid direction')
7373

7474
def _turn(self, delta):
7575
self.direction = (self.direction + delta) % len(_CART_DIRECTIONS)

2018/day15/day15.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, initial_state, elf_power=3):
4848
Unit(col, (row_index, col_index), elf_power))
4949
row[col_index] = '.'
5050
elif col not in ('#', '.'):
51-
raise Exception('Unexpected tile type')
51+
raise ValueError('Unexpected tile type')
5252

5353
def __str__(self):
5454
board = [col for col in row for row in self.board]

2018/day17/day17.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _parse_clay(file_content):
113113
for line in file_content:
114114
match = _SPAN_REGEX.match(line)
115115
if not match:
116-
raise Exception('Invalid line')
116+
raise ValueError('Invalid line')
117117

118118
flipped = match.group(1) == 'y'
119119
first = int(match.group(2))

2018/day18/day18.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def execute_minute(self):
6363
self._has_neighbors(position, '|', 1)):
6464
area_copy[position] = '.'
6565
else:
66-
raise Exception('Unexpected character')
66+
raise ValueError('Unexpected character')
6767

6868
self.area = area_copy
6969

2018/day20/day20.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, input_str):
3636
current_node = current_root
3737

3838
if input_str[current_index] != '^':
39-
raise Exception('Invalid pattern')
39+
raise ValueError('Invalid pattern')
4040

4141
current_index += 1
4242
while current_index < len(input_str):
@@ -63,11 +63,11 @@ def __init__(self, input_str):
6363
current_node = current_node.connect(TreeNode(current))
6464
break
6565
else:
66-
raise Exception('Invalid character')
66+
raise ValueError('Invalid character')
6767
current_index += 1
6868

6969
if root_stack:
70-
raise Exception('Malformed input')
70+
raise ValueError('Malformed input')
7171

7272
self.root = current_root
7373

@@ -186,7 +186,7 @@ def _get_door_type(direction):
186186
if direction in ('E', 'W'):
187187
return '|'
188188

189-
raise Exception('Invalid direction')
189+
raise ValueError('Invalid direction')
190190

191191
@staticmethod
192192
def _get_direction(direction):

2018/day22/day22.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ def _is_item_valid(self, position, item):
9898
# Nothing or torch
9999
return item in (0, 1)
100100

101-
raise Exception('Invalid region type')
101+
raise ValueError('Invalid region type')
102102

103103
def _get_intersecting_item(self, current_position, next_position):
104104
for item in range(3):
105105
if (self._is_item_valid(current_position, item) and
106106
self._is_item_valid(next_position, item)):
107107
return item
108108

109-
raise Exception('Invalid combination of types')
109+
raise ValueError('Invalid combination of types')
110110

111111
def _get_region_type(self, position):
112112
return self._get_erosion_level(position) % 3

2018/day23/day23.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def from_string(data):
190190
"""Create a nanobot from input data."""
191191
match = _POSITIONS_REGEX.match(data)
192192
if not match:
193-
raise Exception('Invalid nanobot data')
193+
raise ValueError('Invalid nanobot data')
194194

195195
position = Point3D(
196196
int(match.group(1)),

2018/day24/day24.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def parse_modifiers(self, line):
8787
for modifier in line.split('; '):
8888
match = _MODIFIER_REGEX.match(modifier)
8989
if not match:
90-
raise Exception('Could not locate modifiers')
90+
raise ValueError('Could not locate modifiers')
9191

9292
modifier_set = None
9393
modifier_category = match.group(1)
@@ -96,7 +96,7 @@ def parse_modifiers(self, line):
9696
elif modifier_category == 'immune':
9797
modifier_set = self._immunities
9898
else:
99-
raise Exception('Unknown modifier category encountered')
99+
raise ValueError('Unknown modifier category encountered')
100100

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

128128
group = Group(
129129
team_name,
@@ -228,7 +228,7 @@ def _parse_team(group_list, lines):
228228
"""Parse the team from the provided lines of text."""
229229
team_match = _TEAM_REGEX.match(next(lines))
230230
if not team_match:
231-
raise Exception('Could not locate team')
231+
raise ValueError('Could not locate team')
232232

233233
team_name = team_match.group(1)
234234

@@ -253,7 +253,7 @@ def _load_groups(file_content):
253253
pass
254254

255255
if team_count != 2:
256-
raise Exception('Failed to find two teams')
256+
raise ValueError('Failed to find two teams')
257257

258258
return groups
259259

0 commit comments

Comments
 (0)