Skip to content

Fix make ty warnings in browser table-view code - #749

Merged
ajslater merged 1 commit into
developfrom
fix-ty-warnings
May 9, 2026
Merged

ajslater merged 1 commit into
developfrom
fix-ty-warnings

Conversation

@ajslater

@ajslater ajslater commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

make ty reported 5 diagnostics (4 in intersections.py, 1 in columns.py). All fixed by tightening type signatures rather than blanket ignores — the only # ty: ignore additions match existing # pyright: ignore comments for the same Django-field shape.

What changed

codex/views/browser/columns.py

  • default_columns_filtered: annotate show_map: dict explicitly. ty was inferring dict[Never, Never] from the show if isinstance(show, dict) else {} ternary because the {} branch had no inferred element types. The annotation gives ty enough information for .get(flag) (where flag: str) to type-check.

codex/views/browser/intersections.py

  • Tighten the group_model parameter on every helper that calls MODEL_REL_MAP.get(...) or group_model._meta: typetype[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 Folder narrowing preserves the BrowserGroupModel bound, so the subsequent MODEL_REL_MAP.get(group_model) and group_model._meta.db_table calls type-check cleanly.

  • Add # ty: ignore[unresolved-attribute] to two field.remote_field.through accesses (lines 540 and 736). ManyToManyRel.through is exposed at runtime but not in stubs — the same reason both lines already carried # pyright: ignore[reportAttributeAccessIssue]. The ty ignore is now adjacent to the matching pyright ignore (line 542 already had both).

Test plan

  • make ty clean
  • ruff check clean
  • ruff format --check clean
  • 193 backend pytest tests pass

Reviewer notes

  • BrowserGroupModel is 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 (each qs.model is one of those), so this is a no-op at runtime — pure documentation of the existing contract.

🤖 Generated with Claude Code

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.
@ajslater
ajslater merged commit d4b9fb8 into develop May 9, 2026
3 checks passed
@ajslater
ajslater deleted the fix-ty-warnings branch May 11, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant