fix(types): clear all remaining mypy errors, make mypy gating in CI - #11
Merged
Conversation
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.
This was referenced Sep 6, 2026
…-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.
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.
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.