Skip to content

sorbet: Bump more tests to typed: true#22532

Closed
issyl0 wants to merge 4 commits into
mainfrom
sorbet-yet-more-tests
Closed

sorbet: Bump more tests to typed: true#22532
issyl0 wants to merge 4 commits into
mainfrom
sorbet-yet-more-tests

Conversation

@issyl0
Copy link
Copy Markdown
Member

@issyl0 issyl0 commented Jun 3, 2026


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

  • I had these changes hanging around locally since the weekend, so here they are.
  • See commit messages for more details.

@issyl0 issyl0 force-pushed the sorbet-yet-more-tests branch from 6219e70 to 5577f1e Compare June 3, 2026 23:12
issyl0 added 4 commits June 4, 2026 00:15
- `File.delete` expects a `String` or `Pathname`, but the test was
  passing it a `File`.
- `__dir__` is always a String, but Sorbet can't tell that.
- The `env` test is testing the BuildEnvironment env.
- Follow up to 8862004.
- Also slim down the comments added in that commit, as it was too
  verbose to put everywhere else.
@issyl0 issyl0 force-pushed the sorbet-yet-more-tests branch from 5577f1e to 4a4b06c Compare June 3, 2026 23:19
@github-code-quality
Copy link
Copy Markdown

github-code-quality Bot commented Jun 3, 2026

Code Coverage Overview

Languages: Ruby

Ruby / code-coverage/simplecov

The overall coverage in the branch remains at 78%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File c6a08de 4a4b06c +/-
utils/tty.rb 92% 91% -1%
download_queue.rb 74% 73% -1%
bundle/cask.rb 97% 97% 0%
bundle/tap.rb 98% 98% 0%
bundle/brew.rb 98% 98% 0%
trust.rb 88% 89% +1%
extend/pathname.rb 75% 79% +4%
services/cli.rb 62% 67% +5%

Updated June 03, 2026 23:34 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@issyl0 issyl0 marked this pull request as ready for review June 3, 2026 23:34
Copilot AI review requested due to automatic review settings June 3, 2026 23:34
@issyl0 issyl0 enabled auto-merge June 3, 2026 23:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 continues the Sorbet adoption effort in Homebrew/brew by raising Sorbet strictness in a number of spec files and adding minimal scaffolding (dummy lets and RBI shims) so those tests typecheck cleanly.

Changes:

  • Bump multiple RSpec files from typed: false to typed: true (and one to typed: strict) and add Sorbet-friendly dummy let defaults where needed.
  • Add/adjust Sorbet annotations in specs (e.g., T.must(__dir__), T.bind) to satisfy type inference.
  • Extend the RSpec shim RBI to include additional Formula DSL methods used in typed specs.
Show a summary per file
File Description
Library/Homebrew/test/utils/user_spec.rb Condenses Sorbet-only dummy let commentary to an inline note.
Library/Homebrew/test/utils/string_inreplace_extension_spec.rb Simplifies Sorbet dummy let explanation into an inline comment.
Library/Homebrew/test/utils/ruby_check_version_script_spec.rb Converts multi-line Sorbet dummy let note into an inline comment.
Library/Homebrew/test/system_command_result_spec.rb Bumps to typed: true and adds a Sorbet dummy stdout let for typechecking.
Library/Homebrew/test/services/formula_wrapper_spec.rb Bumps to typed: true and adjusts a stub to satisfy Sorbet typing.
Library/Homebrew/test/install_spec.rb Bumps from typed: true to typed: strict.
Library/Homebrew/test/dev-cmd/lgtm_spec.rb Bumps to typed: true and adds T.must around __dir__ for Sorbet.
Library/Homebrew/test/cmd/update_spec.rb Bumps to typed: true and adds T.must around __dir__ for Sorbet.
Library/Homebrew/test/cmd/bundle/remove_subcommand_spec.rb Bumps to typed: true and introduces Sorbet-only dummy lets for inferred values.
Library/Homebrew/test/cleaner_spec.rb Bumps to typed: true.
Library/Homebrew/test/cask/dsl/container_spec.rb Bumps to typed: true and adds dummy params let for Sorbet.
Library/Homebrew/test/cask/dsl_spec.rb Simplifies Sorbet dummy let explanation into an inline comment.
Library/Homebrew/test/cask/depends_on_spec.rb Bumps to typed: true and adds dummy cask let for Sorbet in top-level subject.
Library/Homebrew/test/cask/artifact/zshcompletion_spec.rb Bumps to typed: true and adds dummy cask_token let for Sorbet.
Library/Homebrew/test/cask/artifact/manpage_spec.rb Bumps to typed: true and adds dummy cask_token let for Sorbet.
Library/Homebrew/test/cask/artifact/fishlcompletion_spec.rb Bumps to typed: true and adds dummy cask_token let for Sorbet.
Library/Homebrew/test/cask/artifact/bashcompletion_spec.rb Bumps to typed: true and adds dummy cask_token let for Sorbet.
Library/Homebrew/test/bundle/bundle_spec.rb Bumps to typed: true and adds dummy brewfile_content let for Sorbet.
Library/Homebrew/test/build_environment_spec.rb Adds a T.bind in a class body to help Sorbet infer the DSL receiver.
Library/Homebrew/sorbet/rbi/shims/rspec.rbi Extends shims to include Formula#keg_only and Formula#skip_clean for typed spec DSL blocks.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/shims/rspec.rbi: Language not supported
  • Files reviewed: 19/20 changed files
  • Comments generated: 1

Comment on lines 181 to +184
tempfile = File.new("/tmp/foo", File::CREAT)
allow(service).to receive_messages(installed?: true, service_file: Pathname.new(tempfile))
allow(service).to receive_messages(installed?: true, service_file: tempfile_path = Pathname.new(tempfile))
expect(service.plist?).to be(true)
File.delete(tempfile)
File.delete(tempfile_path)
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks! Same comment as previous PR.


# Some helper blocks are inferred as Formula instances or class contexts.
class Formula
sig { params(reason: T.any(String, Symbol), explanation: String).void }
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.

As in the other PR: let's cast to Formula in relevant places and remove this here.

@issyl0 issyl0 closed this Jun 4, 2026
auto-merge was automatically disabled June 4, 2026 10:41

Pull request was closed

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