Fix lint, format and typing findings and pin dev tools

Order imports, format with ruff, make the account key constants Final
so mypy --strict accepts them, and type the test helpers. Configure
ruff and mypy in pyproject.toml and pin the dev tool versions. All
modules, classes and functions already carry Doxygen comments;
doxygen Doxyfile builds without warnings.

Task: MIL-004#2
Closes #18
This commit is contained in:
2026-10-04 23:59:15 +08:00
parent 6e52a242fa
commit 4abf984382
6 changed files with 74 additions and 29 deletions
+23 -6
View File
@@ -14,20 +14,37 @@ from higher_lower.game import ask_choice, play_game, show_round
from higher_lower.game_data import Account
ACCOUNTS: list[Account] = [
{"name": "First", "follower_count": 30, "description": "Test one", "country": "Denmark"},
{"name": "Second", "follower_count": 20, "description": "Test two", "country": "Norway"},
{"name": "Third", "follower_count": 10, "description": "Test three", "country": "Sweden"},
{
"name": "First",
"follower_count": 30,
"description": "Test one",
"country": "Denmark",
},
{
"name": "Second",
"follower_count": 20,
"description": "Test two",
"country": "Norway",
},
{
"name": "Third",
"follower_count": 10,
"description": "Test three",
"country": "Sweden",
},
]
class FirstRng(random.Random):
"""@brief Random generator that always takes the first entries, so a game is fixed."""
"""@brief Random generator that takes the first entries, so a game is fixed."""
def sample(self, population: Sequence, k: int, **kwargs: object) -> list: # type: ignore[override]
def sample( # type: ignore[override]
self, population: Sequence[Account], k: int, **kwargs: object
) -> list[Account]:
"""@brief Return the first k entries."""
return list(population)[:k]
def choice(self, seq: Sequence) -> Account: # type: ignore[override]
def choice(self, seq: Sequence[Account]) -> Account: # type: ignore[override]
"""@brief Return the first entry."""
return seq[0]