🐛 Fix types, python version and linter warnings

This commit is contained in:
2025-11-05 16:25:25 +01:00
parent 10695c378c
commit 46c268d1d4
4 changed files with 101 additions and 101 deletions

View File

@@ -34,20 +34,18 @@ class ESCData(TypedDict):
winner: str
participating_countries: int
with open(DATASET_BASE / "countries.json", "rb") as f:
with (DATASET_BASE / "countries.json").open("rb") as f:
COUNTRY_NAMES: dict[str, str] = orjson.loads(f.read())
def get_country_name(country_code: str) -> str:
"""Convert country code to full country name."""
return COUNTRY_NAMES.get(country_code.upper(), country_code)
def get_country_mapping(year: int) -> dict[int, str]:
"""
Map contestant IDs to country codes by reading the contestants directory.
Returns a dict: {contestant_id: country_code}
"""
"""Map contestant IDs to country codes by reading the contestants directory."""
contestants_dir = DATASET_PATH / str(year) / "contestants"
country_mapping: dict[int, str] = {}
@@ -93,8 +91,8 @@ def parse_year_data(year: int) -> ESCData:
# Count participating countries
participating_countries = count_participating_countries(year)
jury_scores = {}
televote_scores = {}
jury_scores: dict[str, int] = {}
televote_scores: dict[str, int] = {}
winner = None
performances = data.get("performances", [])
@@ -171,8 +169,10 @@ def test_esc_grand_final(year: int, data: ESCData) -> None:
result = runner.invoke(
app,
[
"--jury-path", f.name,
"--participating-countries", str(participating_countries),
"--jury-path",
f.name,
"--participating-countries",
str(participating_countries),
"--rest-of-world-vote" if rest_of_world_vote else "--no-rest-of-world-vote",
],
input="\n".join(inputs),
@@ -183,4 +183,4 @@ def test_esc_grand_final(year: int, data: ESCData) -> None:
except Exception:
pytest.fail(f"Could not parse winner from output:\n{result.output}", pytrace=False)
assert actual == expected_winner, f"For {year}, expected winner {expected_winner} but got {actual!r}"
assert actual == expected_winner, f"For {year}, expected winner {expected_winner} but got {actual!r}"