Skip to content

Fix template mypy errors and make CI mypy blocking - #28

Merged
webbpinner merged 1 commit into
devfrom
issue_025
Sep 23, 2026
Merged

webbpinner merged 1 commit into
devfrom
issue_025

Conversation

@webbpinner

Copy link
Copy Markdown
Contributor

Closes #25.

main/dev had 15 mypy errors. That made the pre-commit mypy hook (added in #13) block every commit touching app/, while CI's mypy step was set to continue-on-error. This PR fixes all 15 and makes the CI step blocking, so the hook and CI agree.

Changes

File Fix
pyproject.toml Enable the pydantic.mypy plugin, so Settings() isn't flagged for fields BaseSettings reads from the environment (5 errors)
app/config.py database_url: str = "" instead of Optional[str] = None. BaseSettings validates defaults, so build_db_url always produces a URL. Checked: same result with and without DATABASE_URL set
app/db/session.py async_sessionmaker instead of sessionmaker for the async engine (the SQLAlchemy 2.0 API; same call interface)
app/db/users.py Stop reusing result for the Role query, which caused the reported User.name error; that one wasn't a real bug. Assign a list to user.roles
app/db/apikeys.py get_permissions_for_apikey(apikey_id: str | UUID): str on SQLite, UUID with the TimescaleDB models
app/deps.py, app/api/auth.py JWT claims from payload.get() typed Optional[str]
.github/workflows/ci.yml Remove continue-on-error from the mypy step

No behavior changes.

Checks

  • black / isort / flake8 / mypy (no issues) / pytest (6 passed)
  • alembic upgrade head on a fresh SQLite database
  • Committed with the pre-commit hooks enabled (all passed)

Once this is released, the OpenRVDAS branches get it with the next rebase. openrvdas_dev has no other mypy errors left after #26.

🤖 Generated with Claude Code

- Enable the pydantic mypy plugin so Settings() isn't flagged for
  fields BaseSettings reads from the environment
- Type database_url as str (BaseSettings validates defaults, so
  build_db_url always produces a URL); behavior unchanged
- Use async_sessionmaker instead of sessionmaker for the async engine
- users.update_user: don't reuse `result` for the Role query, and
  assign a list to user.roles
- get_permissions_for_apikey accepts str | UUID (str on SQLite, UUID
  on the TimescaleDB models)
- Annotate JWT claims read with payload.get() as Optional[str]
- Drop continue-on-error from the CI mypy step now that mypy is clean,
  so CI and the pre-commit hook agree

Closes #25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@webbpinner
webbpinner merged commit b11c810 into dev Sep 23, 2026
2 checks 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