Remove redundant T.let annotations Sorbet can infer#23013
Merged
Conversation
Apply the autocorrections from two new rubocop-sorbet cops, Sorbet/RedundantTLet and Sorbet/RedundantTLetForLiteral, which flag T.let annotations that Sorbet infers automatically: - constants assigned a constructor call (optionally .freeze'd) - constants assigned literals and frozen literal arrays - initialize instance variables assigned from signature parameters These rely on Sorbet's freeze-transparent inference (0.6.13304+); brew ships sorbet-static 0.6.13316. `brew typecheck` passes with the annotations removed.
Contributor
There was a problem hiding this comment.
Pull request overview
Removes redundant Sorbet T.let annotations in typed: strict Ruby code where Sorbet can infer the same types automatically, reducing noise while preserving type safety across Homebrew’s core and Linux-specific code.
Changes:
- Drop
T.let(..., T::Array[String])for frozen string-array constants in multiple files. - Drop
T.let(..., Regexp)for a regexp constant in theuvbundle extension. - Drop redundant
T.letfor aninitializeivar assignment and a constructor-based constant.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/tap.rb | Removes redundant T.let from a frozen %W[...] constant. |
| Library/Homebrew/install_steps.rb | Removes redundant T.let from a TemplateVersion constant and an initialize ivar assignment. |
| Library/Homebrew/extend/os/linux/sandbox.rb | Removes redundant T.let from a frozen string-array constant. |
| Library/Homebrew/extend/os/linux/linkage_checker.rb | Removes redundant T.let from a frozen %W[...] allowlist constant. |
| Library/Homebrew/extend/os/linux/install.rb | Removes redundant T.let from a frozen %W[...] runtime libs constant. |
| Library/Homebrew/dev-cmd/generate-zap.rb | Removes redundant T.let from a frozen string-array constant. |
| Library/Homebrew/bundle/extensions/uv.rb | Removes redundant T.let from a Regexp constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
p-linnane
approved these changes
Jul 8, 2026
Member
|
Nice, thanks! |
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.
Remove
T.lettype annotations that Sorbet can infer on its own, applying the autocorrections from two newrubocop-sorbetcops:Sorbet/RedundantTLet— constants assigned a constructor call (optionally.freeze'd), andinitializeinstance variables assigned directly from signature parameters.Sorbet/RedundantTLetForLiteral— constants assigned simple literals and frozen literal arrays.Eight annotations across seven files are removed:
bundle/extensions/uv.rb— regexp literaldev-cmd/generate-zap.rb,extend/os/linux/{install,linkage_checker,sandbox}.rb,tap.rb— frozen literal arraysinstall_steps.rb— a constructor-constant (X = Foo.new.freeze) and aninitializeivarWhy
These annotations are pure noise: Sorbet already infers the identical type, so they add maintenance cost (a type that must be kept in sync) without buying any checking. The constructor/frozen-literal cases depend on Sorbet's freeze-transparent inference (0.6.13304+); brew ships sorbet-static 0.6.13316, so the inference holds.
These two cops are new and not yet released — they come from the final version of Shopify/rubocop-sorbet#381 before it is opened for review. Landing their autocorrections here is a small, low-risk change that doubles as further public validation of the cops against a large real-world Sorbet codebase ahead of that PR's review.
brew typecheckpasses with every annotation removed, confirming the inference is equivalent.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?AI (Claude Code) ran the two unreleased cops from a local checkout of the rubocop-sorbet branch against the brew source and applied their autocorrections. I reviewed the full diff, confirmed
brew typecheckreports no errors andbrew stylepasses on all changed files, and verified each removed annotation matches what Sorbet infers.