refactor: declutter main.py and fix datasets linting#17
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
startup.py_serve_flows+lifespan) intolifecycle.py/ogcapiredirect endpoint intorouters/root.pyalongside other system routesmain.pyfrom 138 lines to ~25 lines of pure app wiringdatasets/and fix all linting issues (docstrings, type annotations, deprecatedtempfile.mktemp)__init__.pythat broke mypyTest plan
make lintpasses (ruff, mypy, pyright -- 0 errors)make testpasses (19/19)curl http://localhost:8000/ogcapistill redirects to/ogcapi/