fix: Replace assert with ValueError for empty sample_filter check
This commit is contained in:
parent
b60b8c7416
commit
f38923e8fb
|
@ -19,7 +19,8 @@ def filter_samples(
|
||||||
samples: list[ActivitySample],
|
samples: list[ActivitySample],
|
||||||
sample_filter: set[str],
|
sample_filter: set[str],
|
||||||
) -> list[ActivitySample]:
|
) -> list[ActivitySample]:
|
||||||
assert len(sample_filter) > 0
|
if not sample_filter:
|
||||||
|
raise ValueError("sample_filter must not be empty")
|
||||||
return [s for s in samples if set(s.labels).intersection(sample_filter)]
|
return [s for s in samples if set(s.labels).intersection(sample_filter)]
|
||||||
|
|
||||||
|
|
||||||
|
|
1
scripts/__init__.py
Normal file
1
scripts/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# This file marks the scripts directory as a package.
|
|
@ -32,9 +32,9 @@ def parse_results(response) -> list[Result]:
|
||||||
link = cells[0].a
|
link = cells[0].a
|
||||||
if link is None:
|
if link is None:
|
||||||
continue
|
continue
|
||||||
id = link['href'].removeprefix('viewsimfile.php?simfileid=')
|
simfile_id = link['href'].removeprefix('viewsimfile.php?simfileid=')
|
||||||
levels = cells[1].get_text().strip()
|
levels = cells[1].get_text().strip()
|
||||||
results.append(Result(title, int(id), levels))
|
results.append(Result(title, int(simfile_id), levels))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# This file marks the tests directory as a package.
|
|
@ -4,7 +4,7 @@ from personal_data.fetchers.myanimelist import parse_name
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'input_str, expected_group1, expected_group2',
|
("input_str", "expected_group1", "expected_group2"),
|
||||||
[
|
[
|
||||||
('"Soundscape"', 'Soundscape', None),
|
('"Soundscape"', 'Soundscape', None),
|
||||||
('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケープ'),
|
('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケープ'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user