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
+28 -14
View File
@@ -9,23 +9,37 @@ string, so Doxygen does not read the backticks in the art as markup.
## The game logo.
logo = (
"\n"
r" __ ___ __ " "\n"
r" / / / (_)___ _/ /_ ___ _____" "\n"
r" / /_/ / / __ `/ __ \/ _ \/ ___/" "\n"
r" / __ / / /_/ / / / / __/ / " "\n"
r"/_/ ///_/\__, /_/ /_/\___/_/ " "\n"
r" / / /____/_ _____ _____" "\n"
r" / / / __ \ | /| / / _ \/ ___/" "\n"
r" / /___/ /_/ / |/ |/ / __/ / " "\n"
r"/_____/\____/|__/|__/\___/_/ " "\n"
r" __ ___ __ "
"\n"
r" / / / (_)___ _/ /_ ___ _____"
"\n"
r" / /_/ / / __ `/ __ \/ _ \/ ___/"
"\n"
r" / __ / / /_/ / / / / __/ / "
"\n"
r"/_/ ///_/\__, /_/ /_/\___/_/ "
"\n"
r" / / /____/_ _____ _____"
"\n"
r" / / / __ \ | /| / / _ \/ ___/"
"\n"
r" / /___/ /_/ / |/ |/ / __/ / "
"\n"
r"/_____/\____/|__/|__/\___/_/ "
"\n"
)
## The "vs" shown between the two accounts.
vs = (
"\n"
r" _ __ " "\n"
r"| | / /____" "\n"
r"| | / / ___/" "\n"
r"| |/ (__ ) " "\n"
r"|___/____(_)" "\n"
r" _ __ "
"\n"
r"| | / /____"
"\n"
r"| | / / ___/"
"\n"
r"| |/ (__ ) "
"\n"
r"|___/____(_)"
"\n"
)
+6 -4
View File
@@ -2,11 +2,13 @@
@brief Constants shared by the game modules.
"""
from typing import Final
## Keys of an account dictionary.
KEY_NAME = "name"
KEY_FOLLOWER_COUNT = "follower_count"
KEY_DESCRIPTION = "description"
KEY_COUNTRY = "country"
KEY_NAME: Final = "name"
KEY_FOLLOWER_COUNT: Final = "follower_count"
KEY_DESCRIPTION: Final = "description"
KEY_COUNTRY: Final = "country"
## The two choices the player can type, in lower case.
CHOICE_A = "a"
+2 -2
View File
@@ -1,5 +1,5 @@
"""@file game_logic.py
@brief Pure functions of the game: drawing accounts, describing them and checking guesses.
@brief Pure game functions: draw accounts, describe them, check guesses.
"""
import random
@@ -9,9 +9,9 @@ from higher_lower.constants import (
ACCOUNT_TEMPLATE,
CHOICE_A,
CHOICE_B,
KEY_COUNTRY,
KEY_DESCRIPTION,
KEY_NAME,
KEY_COUNTRY,
)
from higher_lower.game_data import Account, data