linkage_cache_store: typed: strict#21594
Conversation
f2fe850 to
e640fd0
Compare
|
The What's happening: The Verification: The merge ref ( Filed: Homebrew/actions#796 |
Add Sorbet `sig` annotations to all methods and `T.let` for instance variables to enable `typed: strict` in `linkage_cache_store.rb`. Contributes to Homebrew#17297 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `CacheStore` base class used `*args` with `raise NotImplementedError` as a pseudo-abstract pattern. When subclasses add Sorbet `sig` annotations, the Sorbet runtime's override shape validation rejects the incompatible signatures (child methods have fixed params, parent has `*args`). Replace this pattern with Sorbet's proper `abstract!` declaration and remove the pseudo-abstract methods entirely. `CacheStore` is never instantiated directly - all callers use concrete subclasses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass `path.to_s` instead of `path` (a Pathname) to `LinkageCacheStore.new`, matching the pattern used in `linkage_checker.rb`. The sig on `initialize` correctly requires a String since the value is used as a JSON-serializable database key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e640fd0 to
1a89ca4
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Great work so far! One question then good to merge.
| # | ||
| # @param hash_values [Hash] hash containing KVPs of { :type => Hash } | ||
| # @return [nil] | ||
| sig { params(hash_values: T::Hash[Symbol, T.untyped]).void } |
There was a problem hiding this comment.
Can you see if this or any other T.untyped in this file can use T.anything instead?
Summary
linkage_cache_store.rbfromtyped: truetotyped: strictsigannotations to all 6 methods (initialize,keg_exists?,update!,fetch,delete!,fetch_hash_values)T.letfor@keg_pathinstance variable ininitializeCacheStoreproperly abstract (abstract!) and remove pseudo-abstract*argsmethods that usedraise NotImplementedError. This resolves the Sorbet runtime override shape validation that occurs when subclass methods have typed signatures with fixed parameters while the parent used*args.keg.rbwherePathnamewas passed toLinkageCacheStore.newinstead ofString(surfaced by the new sig annotation)Contributes to #17297
AI/LLM Disclosure
This PR was developed with assistance from Claude (Opus 4.6) via Claude Code. All code has been reviewed and understood. I can address review comments directly.
Test plan
brew typecheck— no errorsbrew style Library/Homebrew/cache_store.rb Library/Homebrew/linkage_cache_store.rb Library/Homebrew/keg.rb— no offensesbrew tests --only=linkage_cache_store— 7 examples, 0 failuresbrew tests --only=cache_store— 11 examples, 0 failuresbrew tests --only=description_cache_store— 7 examples, 0 failuresbrew tests --only=keg— 33 examples, 0 failuresHOMEBREW_SORBET_RUNTIME=1(simulating CI environment)