mirror of
https://github.com/rr-/pq-cli.git
synced 2026-11-12 22:40:36 -07:00
misc: drop typing as T, use builtin generics
Python 3.10 is the minimum, so annotations use `X | None`, `list[X]` and friends, enforced by ruff's pyupgrade rules. The remaining typing names are imported directly, with abstract types coming from collections.abc. first() is now generic over the item and default.
This commit is contained in:
40 files changed
+248
-236
No files matched your search
+2
-3
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
import typing as T
|
||||
from pathlib import Path
|
||||
|
||||
from pqcli import random
|
||||
@@ -20,7 +19,7 @@ STATS = {
|
||||
}
|
||||
|
||||
|
||||
def run_trace(seed: str, ticks: int = 3000) -> T.List[str]:
|
||||
def run_trace(seed: str, ticks: int = 3000) -> list[str]:
|
||||
"""Play a deterministic game and return everything that happened."""
|
||||
data = load_game_data()
|
||||
player = Player(
|
||||
@@ -34,7 +33,7 @@ def run_trace(seed: str, ticks: int = 3000) -> T.List[str]:
|
||||
random.seed(seed)
|
||||
simulation = Simulation(player, data)
|
||||
|
||||
lines: T.List[str] = []
|
||||
lines: list[str] = []
|
||||
player.connect(
|
||||
"new_task",
|
||||
lambda: lines.append(f"task: {player.task.description}"),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import datetime
|
||||
import json
|
||||
import pickle
|
||||
import typing as T
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -18,7 +18,7 @@ from pqcli.game_data import (
|
||||
from pqcli.mechanic import Player, Stats, monster_task
|
||||
|
||||
|
||||
def write(directory: Path, name: str, value: T.Any) -> Path:
|
||||
def write(directory: Path, name: str, value: Any) -> Path:
|
||||
path = directory / f"{name}.json"
|
||||
path.write_text(json.dumps(value), encoding="utf-8")
|
||||
return path
|
||||
@@ -98,7 +98,7 @@ def test_unknown_file_warns(
|
||||
],
|
||||
)
|
||||
def test_invalid_override_raises(
|
||||
tmp_path: Path, name: str, value: T.Any, message: str
|
||||
tmp_path: Path, name: str, value: Any, message: str
|
||||
) -> None:
|
||||
write(tmp_path, name, value)
|
||||
with pytest.raises(DataError) as excinfo:
|
||||
|
||||
Reference in new issue
Block a user