Skip to content

Ship RBS type signatures under sig/#151

Open
satoryu wants to merge 1 commit into
masterfrom
add-rbs-signatures
Open

Ship RBS type signatures under sig/#151
satoryu wants to merge 1 commit into
masterfrom
add-rbs-signatures

Conversation

@satoryu

@satoryu satoryu commented Jun 1, 2026

Copy link
Copy Markdown
Member

Why

This gem currently ships no type information, so users who type-check their
code (Steep / TypeProf / tapioca) see this gem's API as untyped. This PR
bundles RBS signatures under sig/ and distributes them via RubyGems so that
consumers can resolve the gem's types (e.g. through rbs collection).

What

  • sig/**/*.rbs — generated with rbs prototype rb mirroring lib/, then
    hand-refined for the public API: RakutenWebService.configure /
    Configuration, Resource, SearchResult, Response, AllProxy,
    Client, the Error hierarchy, GenreInformation, BaseGenre, and
    Ichiba::Item.
  • sig/manifest.yaml — declares the default-gem dependencies (json,
    uri) so consumers resolving these types pick them up too.
  • rakuten_web_service.gemspec — adds rbs (~> 4.0) as a development
    dependency. (sig/ is distributed automatically since spec.files uses
    git ls-files.)
  • .github/workflows/ci.yml — adds a job running rbs validate.
  • Version bumped to 1.17.0; CHANGELOG updated.

Note on dynamic accessors

Resource subclasses declare fields via the attribute DSL, which defines
reader methods (and *? predicates) dynamically at load time. These cannot be
expressed statically in RBS, so per-attribute access is typed through #[]
(returning untyped); each affected class documents this in a comment.

Verification

  • bundle exec rbs -r uri -r json -I sig validate → passes
  • bundle exec rake spec → 217 examples, 0 failures (no runtime behavior change)
  • bundle exec rake build → confirmed all sig/ files are included in the
    built gem

🤖 Generated with Claude Code

Provide type information to users of this gem by bundling RBS signatures.

- Generate sig/ mirroring lib/ via `rbs prototype rb`, then refine the
  public API (configure/Configuration, Resource, SearchResult, Response,
  AllProxy, Client, Error hierarchy, GenreInformation, Ichiba::Item).
- Add sig/manifest.yaml declaring json/uri so consumers resolving these
  types via `rbs collection` pick up the default-gem dependencies.
- Add rbs (~> 4.0) as a development dependency.
- Add a CI job running `rbs validate`.
- Bump version to 1.17.0 and update CHANGELOG.

Dynamically defined `attribute` accessors cannot be expressed statically
in RBS, so per-attribute readers are accessed through `#[]` (untyped).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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