diff --git a/PYTHON/lichess_bot/engine.py b/PYTHON/lichess_bot/engine.py index 4008224..859fcbf 100644 --- a/PYTHON/lichess_bot/engine.py +++ b/PYTHON/lichess_bot/engine.py @@ -1,5 +1,6 @@ """Chess engine wrapper for the C-based random/scoring engine.""" +import json import os import subprocess @@ -129,14 +130,12 @@ class RandomEngine: out = self._call_engine(args, timeout=max(0.1, time_budget_sec)) # Try to parse the engine's JSON explanation - import json as _json - cand_score = 0.0 best_move: chess.Move | None = None cand_expl = out best_expl = out try: - data = _json.loads(out) + data = json.loads(out) # candidate score if provided analyze = data.get("analyze") or {} cs = analyze.get("candidate_score") @@ -152,8 +151,8 @@ class RandomEngine: except Exception: best_move = None # Store compact explanations for debugging - cand_expl = _json.dumps(analyze, ensure_ascii=False) - best_expl = _json.dumps( + cand_expl = json.dumps(analyze, ensure_ascii=False) + best_expl = json.dumps( { "chosen_index": data.get("chosen_index"), "chosen_move": data.get("chosen_move"), diff --git a/PYTHON/lichess_bot/main.py b/PYTHON/lichess_bot/main.py index 1c3f13b..3904aae 100644 --- a/PYTHON/lichess_bot/main.py +++ b/PYTHON/lichess_bot/main.py @@ -1,6 +1,7 @@ """Main entry point for the Lichess bot.""" import argparse +import datetime import json import logging import os @@ -96,8 +97,6 @@ def run_bot(log_level: str = "INFO", decline_correspondence: bool = False) -> No "createdAtDate" ) if created_ms: - import datetime - game_date_iso = datetime.datetime.utcfromtimestamp( int(created_ms) / 1000 ).strftime("%Y.%m.%d") diff --git a/pyproject.toml b/pyproject.toml index 9d9874f..a982801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ ignore = [ "FBT003", # Boolean positional value - common pattern "ARG001", # Unused function argument - often needed for API compatibility "ARG002", # Unused method argument - often needed for API compatibility - "PLC0415", # import-outside-top-level - sometimes necessary "N816", # mixed-case-variable-in-global-scope - often constants "N806", # non-lowercase-variable - sometimes intentional "N803", # invalid-argument-name - chess notation uses uppercase @@ -100,6 +99,7 @@ unfixable = [] ] "**/test_*.py" = [ "S101", # Allow assert in tests + "PLC0415", # Allow late imports for test isolation ] "**/conftest.py" = [ "D100", # Allow missing module docstring