feat!: adopt Python 3.15 and support BattlesnakeArena

- Require Python 3.15 in project metadata, runtime pin, and Docker stages.
- Use lazy imports for database backends and type-only dependencies.
- Defer benchmark dependencies until their code paths are used.
- Rely on deferred annotations and use Path.info for file discovery.
- Accept BattlesnakeArena alongside BattlesnakeEngine on game endpoints.
- Advance quart_common for Python 3.15 and multi-agent validation.
- Add pytest development dependencies and refresh the uv lockfile.
- Test lazy backend loading, import order, and fresh file discovery.
- Document the runtime requirements and locked uv workflow.

BREAKING CHANGE: Python 3.15 or newer is required; earlier runtimes cannot parse the lazy import syntax.
This commit is contained in:
2026-11-03 10:02:40 +01:00
parent f14d780f29
commit 5efab77248
35 changed files with 226 additions and 202 deletions
+14 -5
View File
@@ -6,18 +6,27 @@ An official Battlesnake template written in Python. Get started at [play.battles
This project is a great starting point for anyone wanting to program their first Battlesnake in Python. It can be run locally or easily deployed to a cloud provider of your choosing. See the [Battlesnake API Docs](https://docs.battlesnake.com/api) for more detail.
## Technologies Used
This project uses [Python 3](https://www.python.org/) and [Flask](https://flask.palletsprojects.com/). It also comes with an optional [Dockerfile](https://docs.docker.com/engine/reference/builder/) to help with deployment.
This project requires [Python 3.15+](https://www.python.org/) and uses [Quart](https://quart.palletsprojects.com/) with Hypercorn. The Dockerfile uses the uv Python 3.15 runtime.
## Run Your Battlesnake
Install dependencies using pip
Install the pinned Python runtime and locked dependencies using uv:
```sh
pip install -r requirements.txt
uv python install 3.15
uv sync --locked
```
Python modernization (2026-11-03):
- Python 3.15 `lazy` imports defer database backend loading and benchmark-only dependencies. Optional-dependency `try`/`except` imports keep their fallback behavior.
- Python 3.14 deferred annotations replace `from __future__ import annotations`. Type-only dependencies use lazy bindings to avoid loading circular imports at startup.
- Python 3.14 `Path.info` checks reuse directory-entry metadata during dataset and customization asset discovery. Paths reused after mutations retain fresh checks.
- The shared `quart_common` submodule also requires Python 3.15 and already uses Python 3.14 UUIDv7 request IDs.
Run tests with `uv run --locked pytest tests quart_common/tests/test_user_agent.py`.
Python 3.14 is **not** a supported runtime: this project uses 3.15-only syntax.
Start your Battlesnake
```sh
python main.py
uv run --locked python main.py
```
You should see the following output once it is running