Repository navigation
chore: use built-in generic types in annotations - #1889
Merged
Merged
Conversation
spydon
added a commit
that referenced
this pull request
Nov 2, 2026
Stacked on #1889. Review that first; this PR only contains the last commit. ## Why A bare `# type: ignore` silences every mypy error on its line, including new ones introduced later. A bare `# noqa` does the same for Ruff. With 47 bare `type: ignore` comments and 11 bare `noqa` comments, a new bug on one of those lines would go unnoticed. ## What changed - Each bare `# type: ignore` now names the codes mypy actually reports on that line, for example `# type: ignore[method-assign]`. I found them by removing each comment, running mypy and putting back exactly the codes it reported. All of them were still needed, and none were removed. - The bare `# noqa` comments are gone, replaced by real fixes: - The `supabase_auth/__init__.py` re-exports use `X as X`, the same as realtime since #1887. - `AsyncGoTrueBaseAPI._request` uses `raise handle_exception(e) from e`, which `B904` asks for. This keeps the original HTTP error as `__cause__` instead of `__context__`. - Enabled `PGH003` and `PGH004` in the root Ruff config, so new bare `type: ignore` and `noqa` comments fail CI. Combined with `warn_unused_ignores`, which auth, postgrest, realtime and storage already enable, these comments now have to stay accurate. ## Verification - Ruff passes on all of `src/`, and mypy passes for all six packages. - The `_sync` trees were regenerated with `build-sync`.
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.
Why
The root Ruff config ignored
UP006andUP035, so annotations still usedtyping.List,Dict,Tuple,Typeand similar, plus imports thattypingdeprecated in Python 3.9. Built-in generics (list[str],dict[str, Any]) work at runtime on every Python version we support (3.9 and later, PEP 585), so the ignores no longer serve a purpose.What changed
UP006andUP035from the root Ruffignorelist.typingimports now come fromcollections.abcor the built-ins._synctrees withbuild-sync.No behavior changes. Every edit is a Ruff fix and changes only which name an annotation uses.
Why it is safe on Python 3.9
Ruff counts the
UP006fix as unsafe because an annotation evaluated at runtime (pydantic fields, type aliases,cast) now evaluates a different expression. On 3.9 and later,list[...]and the others are valid at runtime, so I checked: