Skip to content

refactor: declutter main.py and fix datasets linting#17

Merged
mortenoh merged 4 commits intomainfrom
refactor/declutter-main
Feb 26, 2026
Merged

refactor: declutter main.py and fix datasets linting#17
mortenoh merged 4 commits intomainfrom
refactor/declutter-main

Conversation

@mortenoh
Copy link
Member

@mortenoh mortenoh commented Feb 26, 2026

Summary

  • Extract early-boot side effects (env vars, PROJ config, logging, dotenv, OpenAPI generation) into startup.py
  • Extract Prefect lifespan management (_serve_flows + lifespan) into lifecycle.py
  • Move /ogcapi redirect endpoint into routers/root.py alongside other system routes
  • Reduce main.py from 138 lines to ~25 lines of pure app wiring
  • Enable pydantic mypy plugin
  • Remove ruff/mypy/pyright excludes for datasets/ and fix all linting issues (docstrings, type annotations, deprecated tempfile.mktemp)
  • Remove accidental root __init__.py that broke mypy

Test plan

  • make lint passes (ruff, mypy, pyright -- 0 errors)
  • make test passes (19/19)
  • Manual: curl http://localhost:8000/ogcapi still redirects to /ogcapi/

Extract early-boot side effects (env vars, PROJ config, logging, dotenv,
OpenAPI generation) into startup.py, Prefect lifespan management into
lifecycle.py, and the /ogcapi redirect into routers/root.py. Reduces
main.py from 138 lines to ~25 lines of pure app wiring.
Add type annotation for FeatureCollection variable to satisfy the
stricter checking from the pydantic plugin.
Resolve merge conflict in main.py by incorporating the new datasets
router into the refactored module structure. Fix dropped pyproject.toml
entries (dependencies, ruff/mypy excludes) from the auto-merge. Remove
accidental root __init__.py that broke mypy. Add pyright exclude for the
datasets module to match ruff and mypy.
Remove ruff, mypy, and pyright exclude entries for src/eo_api/datasets.
Add module docstrings, function docstrings, and type annotations across
all datasets files. Replace deprecated tempfile.mktemp with
NamedTemporaryFile. Add missing third-party modules to mypy
ignore_missing_imports. Remove accidental root __init__.py.
@mortenoh mortenoh changed the title refactor: declutter main.py refactor: declutter main.py and fix datasets linting Feb 26, 2026
@mortenoh mortenoh merged commit 18336a0 into main Feb 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant