1
0

fix: Replace assert with ValueError for empty sample_filter check

This commit is contained in:
Jon Michael Aanes (aider) 2025-04-08 22:53:53 +02:00
parent b60b8c7416
commit f38923e8fb
5 changed files with 7 additions and 4 deletions

View File

@ -19,7 +19,8 @@ def filter_samples(
samples: list[ActivitySample],
sample_filter: set[str],
) -> 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)]

1
scripts/__init__.py Normal file
View File

@ -0,0 +1 @@
# This file marks the scripts directory as a package.

View File

@ -32,9 +32,9 @@ def parse_results(response) -> list[Result]:
link = cells[0].a
if link is None:
continue
id = link['href'].removeprefix('viewsimfile.php?simfileid=')
simfile_id = link['href'].removeprefix('viewsimfile.php?simfileid=')
levels = cells[1].get_text().strip()
results.append(Result(title, int(id), levels))
results.append(Result(title, int(simfile_id), levels))
return results

1
tests/__init__.py Normal file
View File

@ -0,0 +1 @@
# This file marks the tests directory as a package.

View File

@ -4,7 +4,7 @@ from personal_data.fetchers.myanimelist import parse_name
@pytest.mark.parametrize(
'input_str, expected_group1, expected_group2',
("input_str", "expected_group1", "expected_group2"),
[
('"Soundscape"', 'Soundscape', None),
('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケープ'),