Skip to content

Commit cd648ef

Browse files
committed
fix: use specific exception types and add strict=False to zip calls
1 parent cf79972 commit cd648ef

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

bughog/evaluation/file_structure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def parse(cls, path: str) -> Folder:
9191
def get_file(self, name: str) -> File:
9292
matched = [file for file in self.files if file.name == name]
9393
if len(matched) == 0:
94-
raise Exception(f'Could not find {name} in {self.path}.')
94+
raise FileNotFoundError(f'Could not find {name} in {self.path}.')
9595
return matched[0]
9696

9797
def create_file(self, name: str, content: bytes):
@@ -103,7 +103,7 @@ def create_file(self, name: str, content: bytes):
103103
def get_folder(self, name: str) -> Folder:
104104
matched = [file for file in self.subfolders if file.name == name]
105105
if len(matched) == 0:
106-
raise Exception(f'Could not find folder {name}.')
106+
raise FileNotFoundError(f'Could not find folder {name} in {self.path}.')
107107
return matched[0]
108108

109109
def create_folder(self, name: str) -> Folder:

bughog/search_strategy/bgb_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __create_pairs_between_clean_states(states: list[State]) -> list[tuple[State
118118
We assume there are no other clean states in this range.
119119
"""
120120
return[
121-
pair for pair in zip(states, states[1:])
121+
pair for pair in zip(states, states[1:], strict=False)
122122
if not (pair[0].has_dirty_result() and pair[1].has_dirty_result())
123123
]
124124

bughog/search_strategy/bgb_sequence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def next(self, wait=True) -> State:
4343
self._add_state(self._upper_state)
4444
return self._upper_state
4545

46-
pairs = list(zip(self._considered_states, self._considered_states[1:]))
46+
pairs = list(zip(self._considered_states, self._considered_states[1:], strict=False))
4747
while pairs:
4848
filtered_pairs = [pair for pair in pairs if not self._pair_is_in_unavailability_gap(pair)]
4949
furthest_pair = max(filtered_pairs, key=lambda x: x[1].index - x[0].index)

test/experiments/test_file_structure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ def test_ignores_readme(self):
157157
def test_get_file_raises_when_missing(self):
158158
with tempfile.TemporaryDirectory() as tmpdir:
159159
folder = Folder.parse(tmpdir)
160-
with pytest.raises(Exception):
160+
with pytest.raises(FileNotFoundError):
161161
folder.get_file('nonexistent.html')
162162

163163
def test_get_folder_raises_when_missing(self):
164164
with tempfile.TemporaryDirectory() as tmpdir:
165165
folder = Folder.parse(tmpdir)
166-
with pytest.raises(Exception):
166+
with pytest.raises(FileNotFoundError):
167167
folder.get_folder('nonexistent')
168168

169169

test/states/test_version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from packaging.version import InvalidVersion
23

34
from bughog.version_control.version import Version
45

@@ -56,7 +57,7 @@ def test_padded_version():
5657

5758

5859
def test_invalid_version():
59-
with pytest.raises(Exception):
60+
with pytest.raises(InvalidVersion):
6061
Version('not-a-version')
6162

6263

0 commit comments

Comments
 (0)