Fix make ty warnings in browser table-view code - #749
Merged
Merged
Conversation
Five diagnostics. All worth fixing — none required ``# ty: ignore``
fallbacks except for two lines that already carried matching
``# pyright: ignore`` comments for the same Django-field shape:
- ``columns.default_columns_filtered`` — annotate ``show_map: dict``
so ty doesn't infer ``dict[Never, Never]`` from the
``isinstance(show, dict) else {}`` ternary. The ``.get(flag)``
call now type-checks cleanly.
- ``intersections._intersection_relation`` and
``_comic_correlation_sql`` (plus the four
``_build_*_intersection_sort_sql`` helpers,
``_build_simple_m2m_intersection_sort_sql``,
``scalar_intersection_sort_expr``, and
``m2m_intersection_sort_expr``) — tighten ``group_model: type``
to ``group_model: type[BrowserGroupModel]``. The narrowing after
``if group_model is Folder`` then preserves the BrowserGroupModel
bound, so ``MODEL_REL_MAP.get(...)`` and ``group_model._meta``
type-check. ``BrowserGroupModel`` was already exported from
``codex.models.groups``.
- Two ``field.remote_field.through`` accesses (lines 540 and 736)
pick up ``# ty: ignore[unresolved-attribute]`` to match the
existing ``# pyright: ignore[reportAttributeAccessIssue]``
comments. ``ManyToManyRel.through`` is exposed at runtime but
not in stubs — same reason pyright already ignored it.
Verified: ``make ty`` clean, ``ruff check`` clean, 193 backend
tests pass.
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
make tyreported 5 diagnostics (4 inintersections.py, 1 incolumns.py). All fixed by tightening type signatures rather than blanket ignores — the only# ty: ignoreadditions match existing# pyright: ignorecomments for the same Django-field shape.What changed
codex/views/browser/columns.pydefault_columns_filtered: annotateshow_map: dictexplicitly. ty was inferringdict[Never, Never]from theshow if isinstance(show, dict) else {}ternary because the{}branch had no inferred element types. The annotation gives ty enough information for.get(flag)(whereflag: str) to type-check.codex/views/browser/intersections.pyTighten the
group_modelparameter on every helper that callsMODEL_REL_MAP.get(...)orgroup_model._meta:type→type[BrowserGroupModel]. Functions touched:_intersection_relation,_comic_correlation_sql,_build_simple_m2m_intersection_sort_sql,_build_universes_intersection_sort_sql,_build_credits_intersection_sort_sql,_build_identifiers_intersection_sort_sql,_build_story_arcs_intersection_sort_sql,scalar_intersection_sort_expr,m2m_intersection_sort_expr.After the tightening,
if group_model is Foldernarrowing preserves theBrowserGroupModelbound, so the subsequentMODEL_REL_MAP.get(group_model)andgroup_model._meta.db_tablecalls type-check cleanly.Add
# ty: ignore[unresolved-attribute]to twofield.remote_field.throughaccesses (lines 540 and 736).ManyToManyRel.throughis exposed at runtime but not in stubs — the same reason both lines already carried# pyright: ignore[reportAttributeAccessIssue]. Thetyignore is now adjacent to the matching pyright ignore (line 542 already had both).Test plan
make tycleanruff checkcleanruff format --checkcleanReviewer notes
BrowserGroupModelis the existing base class for Publisher / Imprint / Series / Volume / Folder / StoryArc / Comic. The tightened parameter type is what every caller of these functions already passes (eachqs.modelis one of those), so this is a no-op at runtime — pure documentation of the existing contract.🤖 Generated with Claude Code