Remove unnecessary T.let from literal declarations#21542
Open
Conversation
- 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
Contributor
There was a problem hiding this comment.
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.letaround regexp literals. - Keep
T.letin 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.
T.let from literal declarations
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.
brew lgtm(style, typechecking and tests) with your changes locally?At some point, Sorbet became able to infer the types of simple literals, and it was no longer necessary to use
T.let, even attyped: strict. I worked with a coding agent to remove T.let declarations that were not necessary for type checking to succeed:T.letdeclarations