Skip to content

sorbet: Add a Tapioca compiler for Cask::DSL to type some more tests - #23534

Merged
MikeMcQuaid merged 2 commits into
mainfrom
cask-dsl-generated-stanza-rbis
Aug 17, 2026
Merged

sorbet: Add a Tapioca compiler for Cask::DSL to type some more tests#23534
MikeMcQuaid merged 2 commits into
mainfrom
cask-dsl-generated-stanza-rbis

Conversation

@issyl0

@issyl0 issyl0 commented Aug 15, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Opus 5 (Ultracode 🤯) with human prompting, review and big edits when it went very wrong and massively overcomplicated things.


  • 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 duplication to use it in the Tapioca compiler.

issyl0 added 2 commits August 15, 2026 21:16
- `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.
Copilot AI lite review requested due to automatic review settings August 15, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::DSL dynamic stanza APIs (artifacts, flight blocks, install-step artifacts).
  • Add the generated RBI file for Cask::DSL so Sorbet can typecheck calls like app, preflight, postflight, etc.
  • Promote several specs to typed: true/typed: strict and expose AbstractFlightBlock.class_for_dsl_key for 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 MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! Good when 🟢

@issyl0
issyl0 enabled auto-merge August 16, 2026 22:50
@issyl0
issyl0 added this pull request to the merge queue Aug 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 17, 2026
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit df30fd3 Aug 17, 2026
70 of 72 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the cask-dsl-generated-stanza-rbis branch August 17, 2026 13:55
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.

3 participants