Skip to content

Add annotation for pagy - #420

Merged
KaanOzkan merged 1 commit into
Shopify:mainfrom
mokevnin:add-pagy-annotation
Sep 9, 2026
Merged

KaanOzkan merged 1 commit into
Shopify:mainfrom
mokevnin:add-pagy-annotation

Conversation

@mokevnin

@mokevnin mokevnin commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Add RBI for a new gem
  • Modify RBI for an existing gem
  • Other:

Changes

Annotates a single method, Pagy::Method#pagy — the entry point users include into
their controllers/views.

It is defined with define_method inside an anonymous Module.new, so tapioca's runtime
reflection picks up its arity and protected visibility but emits no signature.

  • paginator is Symbol: it is used only as a key into the frozen paginator lookup hash
    in method.rb, so anything else raises.
  • collection and options are T.untyped: they are forwarded verbatim to whichever
    paginator is selected, and each accepts a different kind of collection (AR relation,
    Array, Pagy::Search::Arguments, …).
  • The return is deliberately T.untyped rather than a tuple, because it varies by
    paginator: [Pagy, records] for the offset/countless/countish/keyset family,
    [Pagy::Calendar, Pagy, records] for :calendar, and a bare Pagy object for the
    search paginators in passive mode. A tuple type would be wrong for those callers, and
    Sorbet cannot discriminate on the symbol literal to overload them apart. The comment
    above the sig documents the three shapes instead.

bundle exec repo check --gem --ref origin/main passes locally (index, rubocop, rubygems,
runtime, static).

@mokevnin
mokevnin requested a review from a team as a code owner September 2, 2026 17:40
`Pagy::Method#pagy` is built with `define_method` inside an anonymous
module, so tapioca emits it without a signature.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mokevnin
mokevnin force-pushed the add-pagy-annotation branch from b38468c to 7f8f0aa Compare September 6, 2026 16:53
@KaanOzkan
KaanOzkan merged commit 64591a7 into Shopify:main Sep 9, 2026
4 checks passed
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.

2 participants