Files
Anthias/.github/workflows/python-mypy.yaml
Viktor Petersson 8dbf4eabdb refactor(packaging): adopt src/ layout with split server/viewer packages
Move all Python source under src/ following modern packaging conventions.
Server, viewer, host-agent, and shared common code now live as four
top-level packages with clear excision boundaries — anthias_viewer can
be removed wholesale when the rewrite-out-of-Python lands without
touching the server.

  src/anthias_common/         shared: errors, utils, internal_auth, device_helper
  src/anthias_server/         Django app, REST API, Celery tasks, manage.py
    lib/                      server-only: auth, backup_helper, diagnostics, github, telemetry
  src/anthias_viewer/         player runtime (was viewer/)
  src/anthias_host_agent/     systemd-driven host shim (was host_agent.py)
  tools/raspberry_pi_imager/  moved from repo root
  tests/conftest.py           moved from repo root

pyproject.toml gets [build-system], setuptools src/ discovery, and an
anthias-manage console script. Django AppConfigs keep label='anthias_app'
and label='api' so existing migration dependency tuples don't move.
BASE_DIR computed from parents[3] to keep templates/static at repo root.
mypy_path set to ["src", "stubs"] with explicit_package_bases.

Dockerfile templates set PYTHONPATH=/usr/src/app/src; bin/start_*.sh
and CI workflows use python -m anthias_server.manage / python -m
anthias_viewer instead of bare ./manage.py and python -m viewer.
Ansible host-agent unit invokes python -m anthias_host_agent.

Verified end-to-end in the docker test container:
  - 430 unit tests pass (matches baseline)
  - 7 integration tests pass, 5 skipped (matches baseline)
  - ruff, mypy clean

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 06:35:19 +00:00

61 lines
1.5 KiB
YAML

name: Run mypy
on:
push:
branches:
- 'master'
paths:
- pyproject.toml
- uv.lock
- '**/*.py'
- '.github/workflows/python-mypy.yaml'
pull_request:
branches:
- master
paths:
- pyproject.toml
- uv.lock
- '**/*.py'
- '.github/workflows/python-mypy.yaml'
jobs:
run-mypy:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: '0.9.17'
- name: Install dependencies
run: |
uv venv
uv pip install --group mypy
- name: Prepare config directory
run: |
# The django-stubs plugin imports anthias_server.django_project.settings, which
# transitively instantiates AnthiasSettings(). On first run that
# tries to read ~/.anthias/anthias.conf — write a minimal valid
# one with the section headers AnthiasSettings expects.
mkdir -p ~/.anthias
cat > ~/.anthias/anthias.conf <<'CONF'
[main]
[viewer]
[auth_basic]
CONF
- name: Run mypy
run: |
uv run mypy .