Convert Tab attributes to keyword arguments - #23430
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors AbstractTab, Tab, and Cask::Tab to use keyword arguments instead of a free-form attributes hash, improving Sorbet visibility into Tab attribute types while still allowing forward/backward compatibility for receipt loading via keyword splats.
Changes:
- Convert
AbstractTab,Tab, andCask::Tabinitialisers to explicit keyword arguments and move per-class attribute handling into each class. - Update JSON/hash call sites to symbolise top-level keys before splatting into keyword arguments.
- Add/adjust tests to cover unknown attributes and
installed_on_request_present?, and update existing tests to use keyword-based construction.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/test/tab_spec.rb | Updates Tab construction to kwargs; adds coverage for unknown attributes and installed_on_request_present?; adjusts JSON round-trip tests for kwargs. |
| Library/Homebrew/test/installed_dependents_spec.rb | Updates Tab construction in tests to kwargs to match new initialisers. |
| Library/Homebrew/test/cask/tab_spec.rb | Updates Cask::Tab construction and JSON round-trip test to use kwargs. |
| Library/Homebrew/tab/tab.rb | Refactors Tab#initialize to typed keyword arguments and normalises changed_files to Pathname. |
| Library/Homebrew/tab.rb | Refactors AbstractTab#initialize/constructors to keyword arguments; updates receipt loading to symbolise top-level keys before splatting. |
| Library/Homebrew/cask/tab.rb | Refactors Cask::Tab#initialize to typed keyword arguments and forwards remaining kwargs to AbstractTab. |
| Library/Homebrew/bottle.rb | Updates bottle tab construction to symbolise keys and splat kwargs into Tab.new. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
AbstractTab#initializetook a hash and assigned attributes viainstance_variable_set, so Sorbet checked nothing — a typo (homebrew_versoin) or a wrong type (time: "yesterday") was silently ignored and only surfaced later. Subclasses also neededT.let(nil, ...)for every ivar just to give Sorbet a type. ATODOalready asked for this change.AbstractTab,TabandCask::Tabnow take keyword arguments:super.**and ignored, so receipts from other Homebrew versions (e.g. the removedinstalled_as_dependency) still load.sourceandbuilt_onstay string-keyed, since the code reads them assource["tap"].tabfileis now always aPathname; it could previously hold aString, which did not match its signature.Most typing-only
T.let(nil, ...)lines are gone, and every attribute is now listed in one place in the signatures. I added two tests first (unknown attributes,installed_on_request_present?); both pass before and after. Refactor, not a bug fix.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?AI (Claude Code) assisted in writing the code and tests.
I reviewed the change and ran brew lgtm locally