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:
+23
-6
@@ -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]
|
||||
|
||||
|
||||
@@ -58,8 +58,7 @@ def test_format_data_describes_the_account() -> None:
|
||||
"country": "United States",
|
||||
}
|
||||
assert (
|
||||
format_data(account)
|
||||
== "Nike, a Sportswear multinational, from United States"
|
||||
format_data(account) == "Nike, a Sportswear multinational, from United States"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user