Skip to content

Remove unnecessary T.let from literal declarations#21542

Open
dduugg wants to merge 1 commit intomainfrom
remove-unnecessary-t-let
Open

Remove unnecessary T.let from literal declarations#21542
dduugg wants to merge 1 commit intomainfrom
remove-unnecessary-t-let

Conversation

@dduugg
Copy link
Member

@dduugg dduugg commented Feb 8, 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?
  • Have you written new 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. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

At some point, Sorbet became able to infer the types of simple literals, and it was no longer necessary to use T.let, even at typed: strict. I worked with a coding agent to remove T.let declarations that were not necessary for type checking to succeed:

  • Remove T.let from regexp literals in tap_constants, keg_relocate, extend/os/mac/keg_relocate, utils/github/api, livecheck/strategy/gnu (keep T.let for Regexp.new/union)
  • Remove T.let from string constants in keg_relocate placeholders, utils/github/api (API_URL, etc.), services/system, mcp_server, rubocops/cask/uninstall_methods_order
  • Remove T.let from integer constants in utils/github, services/system, dev-cmd/contributions, mcp_server
  • Skip collection literals (arrays, hashes) and T::Boolean, as these require T.let declarations

- Remove T.let from regexp literals in tap_constants, keg_relocate,
  extend/os/mac/keg_relocate, utils/github/api, livecheck/strategy/gnu
  (keep T.let for Regexp.new/union and interpolated regexes)
- Remove T.let from string constants in keg_relocate placeholders,
  utils/github/api (API_URL, etc.), services/system, mcp_server,
  rubocops/cask/uninstall_methods_order
- Remove T.let from integer constants in utils/github, services/system,
  dev-cmd/contributions, mcp_server
- Skip collection literals (arrays, hashes) and T::Boolean per convention
Copilot AI review requested due to automatic review settings February 8, 2026 01:06
Copy link
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 removes now-unnecessary Sorbet T.let wrappers from simple literal constants (strings/integers/regexp literals) across Homebrew’s Ruby codebase, relying on Sorbet’s constant type inference to keep typed: strict files typecheckable while reducing verbosity.

Changes:

  • Simplify string/integer constants by removing T.let(...) where the RHS is a simple literal.
  • Simplify regexp constants by removing T.let around regexp literals.
  • Keep T.let in places where the RHS isn’t a simple literal (e.g., Regexp.new(...), some heredocs).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Library/Homebrew/utils/github/api.rb Removes T.let from simple URL/integer constants and a regexp literal.
Library/Homebrew/utils/github.rb Removes T.let from an integer constant.
Library/Homebrew/tap_constants.rb Removes T.let wrappers from multiple regexp constants.
Library/Homebrew/services/system.rb Removes T.let wrappers from integer/string constants.
Library/Homebrew/rubocops/cask/uninstall_methods_order.rb Removes T.let wrappers from string message constants.
Library/Homebrew/mcp_server.rb Removes T.let wrappers from protocol/version/error-code constants.
Library/Homebrew/livecheck/strategy/gnu.rb Removes T.let from a multiline regexp literal constant.
Library/Homebrew/keg_relocate.rb Removes T.let wrappers from placeholder strings and a regexp literal constant.
Library/Homebrew/extend/os/mac/keg_relocate.rb Removes T.let from regexp constants used in Mach-O relocation logic.
Library/Homebrew/dev-cmd/contributions.rb Removes T.let from integer constants controlling query limits.

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

@dduugg dduugg changed the title Remove unnecessary T.let from literal constants Remove unnecessary T.let from literal declarations Feb 8, 2026
@dduugg dduugg changed the title Remove unnecessary T.let from literal declarations Remove unnecessary T.let from literal declarations Feb 8, 2026
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