Auto merge dev → main (#1225)

* fix BOT.data_parser import in render_recap.py

render_recap.py runs as a subprocess (Path(__file__).parent.parent on
sys.path) and used `from BOT.data_parser import ...`. After the SHARED
move, data_parser is no longer in the BOT package. Add BOTS/SHARED to
sys.path and switch to the absolute `from data_parser import ...`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* centralize SHARED sys.path bootstrap in BOT/__init__.py

Drop per-file `sys.path.insert(SHARED)` bandaids from BOT/scoreboard.py,
gob.py, utils.py, and game_api.py. The bootstrap now happens exactly
once when the BOT package is imported (via BOT/__init__.py), which is
implicit for any `from BOT.X import …` / `import BOT.X` and any
`python -m BOT.x` invocation.

`SHARED_DIR` is exposed as a public name on the BOT package; siblings
import it via `from . import SHARED_DIR` for building asset paths
(MAPS, ICONS, FONTS, vromfs) instead of recomputing the location.

render_recap.py is the one subprocess entry point that runs as
__main__, so it keeps a minimal bootstrap: add SREBOT to sys.path
then `import BOT` to fire the package init once.

Also move pyrightconfig.json to the BOTS monorepo root so pyright
resolves data_parser and third-party imports regardless of which
subproject the editor opens from.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
NotSoToothless
2026-05-13 23:42:47 -07:00
committed by GitHub
parent ff420e131f
commit 39ef90b3fd
7 changed files with 35 additions and 56 deletions
+6 -4
View File
@@ -69,11 +69,13 @@ def _sanitize_render_text(s: str) -> str:
)
_repo_root = Path(__file__).resolve().parent.parent
if str(_repo_root) not in sys.path:
sys.path.insert(0, str(_repo_root))
# This script runs as a subprocess entry point (python BOT/render_recap.py …),
# so BOT/__init__.py is not invoked automatically. Put SREBOT on sys.path,
# then `import BOT` to trigger the package's SHARED bootstrap once.
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import BOT # noqa: F401, E402 — side effect: adds BOTS/SHARED to sys.path
from BOT.data_parser import apply_vehicle_name_filters # noqa: E402
from data_parser import apply_vehicle_name_filters # noqa: E402
LOCALES_DIR = Path(__file__).resolve().parent.parent / "web" / "locales"
DEFAULT_LANG = "en"