Upgrade ty to 0.0.69 and fix typing bugs it newly catches - #97
Draft
davegaeddert wants to merge 1 commit into
Draft
Upgrade ty to 0.0.69 and fix typing bugs it newly catches#97davegaeddert wants to merge 1 commit into
davegaeddert wants to merge 1 commit into
Conversation
Bumps the pinned `ty` type checker from 0.0.65 to 0.0.69. The newer version's more accurate typeshed bundling and stricter checking surfaced several latent bugs that were previously masked: - `SimpleCookie[str]` was an invalid subscript (SimpleCookie isn't generic in typeshed); drop it. - `ImmutableList` was declared as a plain `tuple` subclass despite being used as `ImmutableList[T]` everywhere; make it properly generic (`class ImmutableList[T](tuple[T, ...])`). - Fixing ImmutableList's genericity made plain-postgres's Meta properties correctly typed for the first time, which surfaced ~37 further errors from code that duck-types across heterogeneous Field subtypes. Left those collections as bare `ImmutableList` (except `related_objects`, which is homogeneous and stays precisely typed) rather than forcing full parametrization that the field hierarchy doesn't support yet. - plain-admin's AdminViewset wired cross-linked URLs onto view classes via dynamic attribute assignment suppressed with `# ty: ignore[unresolved-attribute]`. Hoisted the five duplicated URL-getter stub methods onto the shared AdminView base class and typed `get_views()` against AdminView instead of the generic View, so the assignments type-check for real and the ignores are gone. - plain-auth's test `login_client` helper built a cookie-attributes dict that didn't type-check against Morsel's update() signature; rebuilt it on top of `Response.set_cookie()` (the same path `plain.sessions`'s middleware uses), which also fixes a staleness bug where the test helper omitted `httponly`/`samesite`. Net effect: type-ignore count across the workspace drops from 160 to 153, with zero new ignores added. `./scripts/type-validate` and the full test suite pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzceyCD3hNuNjQwi1pLDej
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.
Summary
Bumps the pinned
tytype checker from 0.0.65 to 0.0.69 (checked the changelog for 0.0.66–0.0.69) and fixes several latent typing bugs the newer version's more accurate typeshed bundling and stricter checking newly caught — rather than just silencing them with more ignores.plain/plain/test/client.py:SimpleCookie[str]was an invalid subscript —SimpleCookieisn't generic in typeshed (it hardcodesBaseCookie[str]). Dropped the subscript.plain/plain/utils/datastructures.py:ImmutableListwas declared as a plaintuplesubclass despite being used asImmutableList[T]everywhere. Made it properly generic:class ImmutableList[T](tuple[T, ...]).plain-postgres/plain/postgres/meta.py/query.py: fixingImmutableList's genericity madeMeta's field-collection properties correctly typed for the first time, which surfaced ~37 further errors from internals code that duck-types across heterogeneousFieldsubtypes (baseField[T]doesn't declareremote_field/required/clean/etc., which only exist on subclasses, and several call sites rely on runtime type guardstycan't see through). Left those collections as bareImmutableListrather than forcing a parametrization the field hierarchy doesn't actually support — exceptrelated_objects, which is genuinely homogeneous (ForeignObjectRel) and stays precisely typed. Also collapsed a set of@overloadstubs inmeta.pythat had gone dead (all branches now return the same type).plain-admin/plain/admin/views/{base,objects,viewsets}.py:AdminViewset.get_views()wired cross-linked URLs onto view classes via dynamic attribute assignment, suppressed with# ty: ignore[unresolved-attribute]. Hoisted the five duplicated URL-getter stub methods (previously copy-pasted acrossAdminListView/AdminCreateView/AdminDetailView/AdminUpdateView/AdminDeleteView) onto the sharedAdminViewbase class, and typedget_views()againstAdminViewinstead of the genericView, so the assignments type-check for real and the ignore comments are gone.plain-admin/plain/admin/cards/base.py: removed one stale, now-unused blanket# type: ignore.plain-auth/plain/auth/test.py: the testlogin_clienthelper built a cookie-attributes dict that didn't type-check againstMorsel.update()'s signature. Rebuilt it on top ofResponse.set_cookie()— the same pathplain.sessions's middleware uses in production — which also fixes a real staleness bug where the test helper had drifted and stopped settinghttponly/samesite.Net effect: type-ignore count across the workspace drops from 160 to 153, with zero new ignores added.
Test plan
./scripts/type-validate— 27/27 paths pass, no diagnostics./scripts/fix— ruff check/format clean (oxlint/oxfmt couldn't be reinstalled in this sandbox due to a proxy/TLS limitation unrelated to this change; no non-Python files were touched)./scripts/test(full suite, local Postgres) — all packages pass/simplify— ran a 4-angle review (reuse/simplification/efficiency/altitude) over the diff and applied the fixes it surfaced (collapsed dead overloads, restoredrelated_objects's precise type, reusedResponse.set_cookie()instead of hand-rolling cookie attributes)Note: I wasn't able to route out-of-scope review findings to PullApprove — the PullApprove5 connector didn't come online in this session. There weren't any left to route in the end; everything the review turned up got fixed.
Generated by Claude Code