sorbet: Add a Tapioca compiler for Cask::DSL to type some more tests - #23534
Merged
Conversation
- `Cask::DSL` calls `define_method` which Sorbet can't see directly, so `typed: true` files can't call `app`, `preflight` and friends. - I originally tried `T.bind(self, Cask::DSL)` in the blocks themselves, as with `Formula`, but this doesn't work with `preflight do |dsl|` because the block is passed to `define_method`. - For `preflight` and `postflight` specifically there's a pre-existing `AbstractFlightBlock.class_for_dsl_key` method, and making it public meant less rewriting to use it in the Tapioca compiler.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Sorbet typechecking coverage for Cask-related tests by teaching Tapioca how to generate RBI signatures for Cask::DSL’s dynamically-defined stanza methods (created via define_method), enabling more specs to be marked typed: true/strict.
Changes:
- Add a custom Tapioca DSL compiler that generates RBI methods for
Cask::DSLdynamic stanza APIs (artifacts, flight blocks, install-step artifacts). - Add the generated RBI file for
Cask::DSLso Sorbet can typecheck calls likeapp,preflight,postflight, etc. - Promote several specs to
typed: true/typed: strictand exposeAbstractFlightBlock.class_for_dsl_keyfor reuse by the compiler.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb | New Tapioca compiler to emit RBI methods for dynamically-defined Cask::DSL stanzas. |
| Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi | New generated RBI defining Cask::DSL stanza methods (artifacts, flight blocks, install-step stanzas). |
| Library/Homebrew/cask/artifact/abstract_flight_block.rb | Makes class_for_dsl_key a public class method and updates internal call site to match. |
| Library/Homebrew/test/cask/artifact/preflight_block_spec.rb | Switches to typed: strict now that preflight is typeable. |
| Library/Homebrew/test/cask/artifact/postflight_block_spec.rb | Switches to typed: strict now that postflight is typeable. |
| Library/Homebrew/test/cask/artifact/generated_script_spec.rb | Switches to typed: true to enable Sorbet checking for generated-script cask DSL usage. |
| Library/Homebrew/test/cask/artifact/generated_completion_spec.rb | Switches to typed: true to enable Sorbet checking for completion-generation cask DSL usage. |
| Library/Homebrew/test/cask/artifact/app_spec.rb | Switches to typed: true to typecheck cask DSL usage like app. |
| Library/Homebrew/test/cask/artifact/alt_target_spec.rb | Switches to typed: true to typecheck app ... target: DSL usage. |
| Library/Homebrew/test/utils/github/api_spec.rb | Switches to typed: strict. |
| Library/Homebrew/test/rubocops/install_steps_source_independence_spec.rb | Switches to typed: strict. |
| Library/Homebrew/test/github_releases_spec.rb | Switches to typed: strict. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Files not reviewed (1)
- Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi: File type not supported
- Files reviewed: 11/12 changed files
- Comments generated: 0
- Review effort level: Lite
MikeMcQuaid
reviewed
Aug 16, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Nice, thanks! Good when 🟢
issyl0
enabled auto-merge
August 16, 2026 22:50
MikeMcQuaid
approved these changes
Aug 17, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 17, 2026
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.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Opus 5 (Ultracode 🤯) with human prompting, review and big edits when it went very wrong and massively overcomplicated things.
Cask::DSLcallsdefine_methodwhich Sorbet can't see directly, sotyped: truefiles can't callapp,preflightand friends.T.bind(self, Cask::DSL)in the blocks themselves, as withFormula, but this doesn't work withpreflight do |dsl|because the block is passed todefine_method.preflightandpostflightspecifically there's a pre-existingAbstractFlightBlock.class_for_dsl_keymethod, and making it public meant less duplication to use it in the Tapioca compiler.