Repository navigation
chore: unify ruff config and enable more lint rules - #1887
Merged
Merged
Conversation
grdsdev
approved these changes
Oct 30, 2026
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`.
spydon
added a commit
that referenced
this pull request
Nov 6, 2026
…y rules (#2008) ## Summary SDK-2910. The shared ruff config from #1887 (SDK-1689) was lost when v3 became `main` in #1370. Every package except `utils` had its own `[tool.ruff.lint]` section again. Ruff does not merge those with the root, so `auth`, `postgrest`, `storage`, `realtime` and `functions` skipped the root's `B` and `ANN2` rules. That hid a regression of the `text_search` mutable default that #1887 had fixed. This restores the shared config, adds more rule families, and tightens pyrefly now that the minimum is Python 3.12. ## Config - Every package `pyproject.toml` uses `[tool.ruff] extend = "../../pyproject.toml"` instead of its own rule list. - The root config brings back `PLE`, `PLW`, `PIE`, `LOG`, `FLY` and `YTT` from #1887, and adds `ASYNC`, `C4`, `RSE`, `SIM`, `RET`, `PYI`, `PT`, `TC`, `PERF` and `RUF`. The full `PT` and `RUF` families replace `PT014` and `RUF100`. `RUF006` and `ASYNC` also cover SDK-2832. - `TC` treats `pydantic.BaseModel` subclasses and standard and pydantic dataclasses as runtime-evaluated. The imports their fields need stay at runtime, so pydantic validation and `typing.get_type_hints` on them still work. - `pyrefly.toml` pins `python-version = "3.12"`. Before, pyrefly used whatever interpreter the virtual environment had. It also promotes `unreachable`, `division-by-zero`, `no-any-return-explicit` and `untyped-namedtuple` to errors. All four were clean. ## Library fixes - **postgrest:** `text_search` no longer uses a mutable `{}` default (`B006`). `APIError` raised after a failed response validation chains the `ValidationError` (`B904`). - **realtime:** `MaxRetriesExceeded` chains the last connection error (`B904`). `RealtimePresence` no longer overwrites its loop variable (`PLW2901`). `__aexit__` uses `contextlib.suppress` (`SIM105`). - **storage:** The missing-trailing-slash warning now points at the code that creates the client (`B028`). - **All clients:** `__enter__` and `__aenter__` return `Self` instead of the concrete class, so subclasses get the right type (`PYI034`). - Imports used only in annotations moved under `TYPE_CHECKING` (`TC`). `__all__` lists are sorted (`RUF022`). - `auth`'s `AMREntry.method` and `Factor.factor_type` keep `Literal[...] | str` with `# noqa: PYI051`, because the literals are there for editor completion. ## Test fixes - **realtime:** Tests keep a reference to the tasks they start with `asyncio.create_task` and await them (`RUF006`). Nested `async with` blocks are merged (`SIM117`). - **storage:** Removed the unused `delete_left_buckets` fixture, along with the global bucket list and finalizer helpers that only it used (`PT021`, `PLW0602`). - Fixtures that only returned a value no longer `yield` (`PT022`). Their return types now match what they return, which pyrefly checks. - Parametrize names are tuples (`PT006`). `pytest.raises` and `pytest.warns` calls set `match` (`PT011`, `PT030`, `RUF043`). The duplicate `sanitize_param` case is removed (`PT014`). - The auth sync tests were regenerated with `make auth.build-sync`. ## Testing - `make ruff` and `make pyrefly` pass on all packages. - `functions`, `utils`, `supabase`, `postgrest`, `realtime` and `storage` test suites pass locally. - `auth`: the local runs failed with connection errors to the auth server on `localhost:9998`, so CI is the check for it.
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
realtime,postgrestandsupabaseeach had their own[tool.ruff.lint]section. Ruff does not merge those with the root config, so any rule added at the root never reached those packages. postgrest and realtime also had bugbear (B) andANN2turned off and ignoredF401,F841andE712. That is how the missingraisefixed in #1881 got through:PLW0133would have caught it, but it could not have been enabled for postgrest.What changed
Config
extend = "../../pyproject.toml", so every package uses the root rules. Each package keeps its own project root, so import sorting (first-party vs third-party) is unchanged.PLEPLWraise(PLW0133)PIELOGFLYstr.jointhat should be an f-stringYTTsys.versioncomparisonsPT014pytest.mark.parametrizecasesRUF100# noqadirectivesFixes for what the rules found
raise APIError(...) from ewhen the error body fails validation, so the original error stays in the chain (B904).text_searchno longer uses a mutable{}default (B006).BasePostgrestClientno longer inherits fromABC; it has no abstract methods (B024).parametrizecase intest_utils.py(PT014), a deadfield_validatorimport and other unused imports and variables.__init__.pyuseX as Xso they count as public.TrueandFalsewithis.globalstatements that never assign.# noqacomments that no longer suppress anything.ANN2): Added to postgrest and realtime, mostly-> Noneon tests. mypy only checks functions that have annotations, so it now also checks those test bodies. Fixing what it found:range_gt,range_gte,range_lt,range_lte,range_adjacentand the underlyingsl,sr,nxl,nxr,adjwere typedTuple[int, int], but Postgres ranges are often dates or timestamps, and the integration tests pass timestamp strings. They now takeTuple[FilterValue, FilterValue]. This widens the accepted type, so existing callers are unaffected.maybe_single()results withassert res is not Noneand the CSV response withisinstance.Not included
RUF006(fire-and-forgetasyncio.create_task) has 6 hits in realtime and the supabase client, andASYNChas 2 blockingopen()calls in async storage code. Fixing those changes behavior, so they will come in a separate PR.Verification
ruff checkpasses on all ofsrc/._synctrees matchbuild-syncoutput, anduv.lockis unchanged.