From 00d6ce63ca4805294635bd2d7652f78895dbabb4 Mon Sep 17 00:00:00 2001 From: John Costa Date: Wed, 18 Feb 2026 22:32:05 -0800 Subject: [PATCH] linkage_cache_store: `typed: strict` Add Sorbet `sig` annotations to all methods and `T.let` for instance variables to enable `typed: strict` in `linkage_cache_store.rb`. Contributes to #17297 Co-Authored-By: Claude Opus 4.6 --- Library/Homebrew/linkage_cache_store.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/linkage_cache_store.rb b/Library/Homebrew/linkage_cache_store.rb index 18d607b31e..00ccc6ef78 100644 --- a/Library/Homebrew/linkage_cache_store.rb +++ b/Library/Homebrew/linkage_cache_store.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "cache_store" @@ -11,14 +11,16 @@ class LinkageCacheStore < CacheStore # @param keg_path [String] # @param database [CacheStoreDatabase] # @return [nil] + sig { params(keg_path: String, database: CacheStoreDatabase).void } def initialize(keg_path, database) - @keg_path = keg_path + @keg_path = T.let(keg_path, String) super(database) end # Returns `true` if the database has any value for the current `keg_path`. # # @return [Boolean] + sig { returns(T::Boolean) } def keg_exists? !database.get(@keg_path).nil? end @@ -28,6 +30,7 @@ class LinkageCacheStore < CacheStore # # @param hash_values [Hash] hash containing KVPs of { :type => Hash } # @return [nil] + sig { params(hash_values: T::Hash[Symbol, T.untyped]).void } def update!(hash_values) hash_values.each_key do |type| next if HASH_LINKAGE_TYPES.include?(type) @@ -43,6 +46,7 @@ class LinkageCacheStore < CacheStore # @param type [Symbol] the type to fetch from the {LinkageCacheStore} # @raise [TypeError] error if the type is not in `HASH_LINKAGE_TYPES` # @return [Hash] + sig { params(type: Symbol).returns(T.untyped) } def fetch(type) unless HASH_LINKAGE_TYPES.include?(type) raise TypeError, <<~EOS @@ -58,6 +62,7 @@ class LinkageCacheStore < CacheStore # Delete the keg from the {LinkageCacheStore}. # # @return [nil] + sig { void } def delete! database.delete(@keg_path) end @@ -69,6 +74,7 @@ class LinkageCacheStore < CacheStore # @param type [Symbol] # @return [Hash] + sig { params(type: Symbol).returns(T.untyped) } def fetch_hash_values(type) keg_cache = database.get(@keg_path) return {} unless keg_cache