Skip to content

fix(types): clear all remaining mypy errors, make mypy gating in CI - #11

Merged
magi8101 merged 3 commits into
mainfrom
fix/mypy-cleanup-issue-7
Sep 6, 2026
Merged

fix(types): clear all remaining mypy errors, make mypy gating in CI#11
magi8101 merged 3 commits into
mainfrom
fix/mypy-cleanup-issue-7

Conversation

@magi8101

@magi8101 magi8101 commented Sep 6, 2026

Copy link
Copy Markdown
Member

Closes issue #7. All 13 tracked errors are gone (2 were fixed as a side effect of PR #10's router/openapi rewrite, the other 11 fixed here) — mypy velocix --ignore-missing-imports now reports 0 errors. Flipped CI's mypy step from advisory (|| true) to gating since there's nothing left for it to be advisory about. Full 252-test suite still green.

One thing worth a follow-up, not fixed here: brute_force.py's record_failure/mark_success call backend.incr_sync/reset_sync, which _patch_backend() only monkey-patches onto MemoryBackend — a RedisBackend passed as backend= would AttributeError. Documented inline; didn't fix since it's a behavior change (making those methods async) beyond this PR's scope.

Closes issue #7's tracked debt (13 errors, 2 already fixed as a side
effect of the router/openapi rewrite in #10):

- depends.py: narrow Any | None before .__metadata__ access
- jwt.py: type the options dict as jwt.types.Options instead of a bare dict
- router.py: type handler dunder-attr assignment with the same
  # type: ignore[attr-defined] pattern app.py's own route() already uses
- security/base.py: HookManager._hooks typed as list[SecurityHook] instead
  of list[Any], so on_request's declared Response | None return survives
- brute_force.py: incr_sync/reset_sync are a MemoryBackend-only monkey-patch,
  not part of the async StorageBackend Protocol -- documented why, ignored
  the attr-defined error, and typed count explicitly so no-any-return clears
- app.py: typed the raw ASGI scope headers list instead of leaving it Any;
  asserted the two docs handlers' already-guaranteed-non-None openapi_url

mypy velocix --ignore-missing-imports: 0 errors. Full 252-test suite green.
CI's mypy step is no longer advisory-only.
Copilot AI lite review requested due to automatic review settings September 6, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…-ignore

ignore_missing_imports = true in [tool.mypy] was suppressing every missing
stub, not just the ones that needed it. Removed it and dealt with what
mypy actually found:

- aiofiles: http/client.py's download() imports it unconditionally (not
  guarded), but it was never in requirements.txt -- only in pyproject.toml's
  dependency list. Anyone installing from requirements.txt alone (CI, and
  any app built on velocix) would ImportError the first time .download()
  ran. Added it for real, plus types-aiofiles for mypy.
- yaml, redis: both are genuinely optional, try/except-ImportError-guarded
  integrations (openapi YAML export, RedisBackend), not installed by
  default. Scoped ignore_missing_imports to just those two modules instead
  of the whole codebase.

mypy velocix (no --ignore-missing-imports anywhere): 0 errors. ruff and
full 252-test suite still green.
The CLI flag would've silently re-blanket-suppressed everything the
scoped pyproject.toml overrides no longer do. Verified in a fresh venv
matching CI's exact install steps: mypy velocix, ruff check ., pytest
all clean/green.
@magi8101
magi8101 merged commit aad73d0 into main Sep 6, 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.

2 participants