mirror of
https://github.com/Paillat-dev/esc-dramatic-unpause.git
synced 2026-01-02 01:06:21 +00:00
🐛 Fix types, python version and linter warnings
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user