Drop sorbet-runtime dependency by migrating to RBS comment annotations#68
Merged
Conversation
Bump sorbet, sorbet-runtime, tapioca, spoom, rbi, and rbs to current versions and regenerate the gem RBIs to match. Pin rubocop-sorbet to Shopify/rubocop-sorbet@7b7d3cb (post-#367 and post-#372) so the not-yet-released Sorbet/RedundantTLetForLiteral and Sorbet/RedundantTLet cops are available.
Apply Sorbet/RedundantTLetForLiteral and Sorbet/RedundantTLet autocorrections. Sorbet infers the type of literal constants automatically, so the explicit T.let wrappers were redundant.
Replace Sorbet's runtime DSL with inline RBS comment annotations so the gem no longer depends on sorbet-runtime at runtime, matching upstream packwerk (Shopify/packwerk#455). - Enable --parser=prism and --enable-experimental-rbs-comments in sorbet/config - Translate all sig blocks to #: RBS comments (via spoom) - Convert the T::Struct Package classes to plain classes with RBS-annotated attr_readers and keyword initializers - Replace T.let / T.must / extend T::Sig with inline RBS annotations - Drop require 'sorbet-runtime' and the sorbet-runtime gem dependency
- Allow RBS inline annotation comments (Layout/LeadingCommentSpace) - Set TargetRubyVersion to 3.2 (matches required_ruby_version), fixing Lint/RedundantRequireStatement on the binstubs - Remove disabled-cop entries that no longer have any violations, including Style/TrivialAccessors (its Sorbet-sig rationale is moot now that RBS makes annotated attr_readers clean)
The modernized Sorbet toolchain pulls in rbi 0.3.12, which requires Ruby >= 3.3. Raise required_ruby_version and TargetRubyVersion to match.
This was referenced May 29, 2026
dduugg
added a commit
that referenced
this pull request
May 29, 2026
…total methods (#71) * Migrate tests off sorbet-runtime and trim gemspec sorbet deps The migration in #68 left the test suite using Sorbet's runtime DSL (extend T::Sig, sig, T.must, T.unsafe, T.bind), which only worked because packwerk transitively loaded sorbet-runtime. packwerk 3.3.0 drops sorbet-runtime, so the suite fails with 'uninitialized constant T'. Rather than re-add a sorbet-runtime dependency, finish the migration in test/ the same way as lib/: - Translate sig blocks to #: RBS comments and drop extend T::Sig - Replace requires_ancestor/T.bind with a Minitest::Runnable @requires_ancestor annotation in the fixture helper - Convert T.must to '#: as !nil' and T.unsafe to '#: as untyped' casts Also drop the redundant 'sorbet-static' dev dependency (the 'sorbet' gem already depends on it). * Avoid untyped cast in integration specs Use Enumerable#any? with the class as a === pattern instead of casting the abstract Packwerk::Checker element to untyped to call is_a?. This keeps the check fully typed (no type erasure). * Use Array#fetch(-1) instead of last with a non-nil cast fetch(-1) returns a non-nil element type, so no '#: as !nil' cast is needed (and it raises IndexError rather than silently returning nil). * Use total methods instead of non-nil casts in privacy checker - publicized_locations.fetch(location) instead of [] with '#: as !nil' (the key is guaranteed present by the preceding key? guard) - lines.first(5) instead of lines[0..4] with '#: as !nil' (first(n) returns a non-nil Array)
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
Removes this gem's runtime dependency on
sorbet-runtimeby migrating every type annotation from Sorbet's runtime DSL to inline RBS comment syntax, following upstream packwerk (Shopify/packwerk#455). This supersedes #67 (which closed the gap by adding morerequire 'sorbet-runtime'statements) — instead we eliminate runtime Sorbet usage entirely.Static type checking is unchanged in spirit:
srb tcstill runs, now reading the#:RBS comments via--parser=prism --enable-experimental-rbs-comments.Changes
RBS migration (drop
sorbet-runtime)sorbet/config: add--parser=prismand--enable-experimental-rbs-comments.sig { … }blocks to#:RBS comments (viaspoom srb sigs translate);@overrideannotations preserved.T::StructPackageclasses to plain classes with RBS-annotatedattr_readers and keywordinitializemethods.T.let/T.must/extend T::Sigwith inline RBS annotations.require 'sorbet-runtime'and remove thesorbet-runtimegem dependency.Sorbet tooling + redundant
T.letcleanupSorbet/RedundantTLetForLiteralandSorbet/RedundantTLet, stripping redundantT.letwrappers from literal constants.rubocop-sorbettoShopify/rubocop-sorbet@7b7d3cb(after #367 and #372) so those cops are available — neither is in the released v0.12.0 yet.RuboCop config
Layout/LeadingCommentSpace: AllowRBSInlineAnnotation).TargetRubyVersion: 3.3.Style/TrivialAccessors, whose Sorbet-sig rationale is moot now that RBS makes annotatedattr_readers clean).Minimum Ruby version
required_ruby_versionto>= 3.3. The modernized toolchain pulls inrbi >= 0.3.12, which requires Ruby 3.3+. (Ruby 3.2 is also EOL; it was dropped from CI in rubyatscale/shared-config#19, now merged.)Verification
bundle exec srb tc→ No errorsbundle exec rake test→ 88 runs, 0 failuresbundle exec rubocop→ no offensesFollow-up
rubocop-sorbetrelease ships with the twoT.letcops, the git pin in theGemfilecan move back to a rubygems version.