diff --git a/Library/Homebrew/api/cask.rb b/Library/Homebrew/api/cask.rb index 5de578f0ed..df336931a9 100644 --- a/Library/Homebrew/api/cask.rb +++ b/Library/Homebrew/api/cask.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "cachable" @@ -21,7 +21,7 @@ module Homebrew private_class_method :cache - sig { params(token: String).returns(Hash) } + sig { params(token: String).returns(T::Hash[String, T.untyped]) } def self.fetch(token) Homebrew::API.fetch "cask/#{token}.json" end @@ -47,6 +47,7 @@ module Homebrew .load(config: cask.config) end + sig { returns(Pathname) } def self.cached_json_file_path HOMEBREW_CACHE_API/api_filename end @@ -70,7 +71,7 @@ module Homebrew end private_class_method :download_and_cache_data! - sig { returns(T::Hash[String, Hash]) } + sig { returns(T::Hash[String, T::Hash[String, T.untyped]]) } def self.all_casks unless cache.key?("casks") json_updated = download_and_cache_data! diff --git a/Library/Homebrew/cask/artifact_set.rb b/Library/Homebrew/cask/artifact_set.rb index 517debcd25..8f1da460b4 100644 --- a/Library/Homebrew/cask/artifact_set.rb +++ b/Library/Homebrew/cask/artifact_set.rb @@ -1,9 +1,14 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Cask # Sorted set containing all cask artifacts. class ArtifactSet < ::Set + extend T::Generic + + Elem = type_member(:out) { { fixed: Artifact::AbstractArtifact } } + + sig { params(block: T.nilable(T.proc.params(arg0: Elem).returns(T.untyped))).void } def each(&block) return enum_for(T.must(__method__)) { size } unless block @@ -11,6 +16,7 @@ module Cask self end + sig { returns(T::Array[Artifact::AbstractArtifact]) } def to_a super.sort end diff --git a/Library/Homebrew/cask/cask_loader.rb b/Library/Homebrew/cask/cask_loader.rb index 24befa53a3..4dd39bfc0f 100644 --- a/Library/Homebrew/cask/cask_loader.rb +++ b/Library/Homebrew/cask/cask_loader.rb @@ -295,7 +295,7 @@ module Cask sig { returns(Pathname) } attr_reader :path - sig { returns(T.nilable(T::Hash[T.any(String, Symbol), T.anything])) } + sig { returns(T.nilable(T::Hash[String, T.untyped])) } attr_reader :from_json sig { @@ -320,7 +320,7 @@ module Cask sig { params( token: String, - from_json: T.nilable(T::Hash[T.any(String, Symbol), T.anything]), + from_json: T.nilable(T::Hash[String, T.untyped]), path: T.nilable(Pathname), ).void } diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index 9cc482012a..7819d4089a 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -304,6 +304,20 @@ on_request: true) next if artifact.is_a?(Artifact::Binary) && !binaries? + artifact = T.cast( + artifact, + T.any( + Artifact::AbstractFlightBlock, + Artifact::Installer, + Artifact::KeyboardLayout, + Artifact::Mdimporter, + Artifact::Moved, + Artifact::Pkg, + Artifact::Qlplugin, + Artifact::Symlinked, + ), + ) + artifact.install_phase( command: @command, verbose: verbose?, adopt: adopt?, auto_updates: @cask.auto_updates, force: force?, predecessor: @@ -549,6 +563,18 @@ on_request: true) artifacts.each do |artifact| if artifact.respond_to?(:uninstall_phase) + artifact = T.cast( + artifact, + T.any( + Artifact::AbstractFlightBlock, + Artifact::KeyboardLayout, + Artifact::Moved, + Artifact::Qlplugin, + Artifact::Symlinked, + Artifact::Uninstall, + ), + ) + odebug "Uninstalling artifact of class #{artifact.class}" artifact.uninstall_phase( command: @command, @@ -563,6 +589,8 @@ on_request: true) next unless artifact.respond_to?(:post_uninstall_phase) + artifact = T.cast(artifact, Artifact::Uninstall) + odebug "Post-uninstalling artifact of class #{artifact.class}" artifact.post_uninstall_phase( command: @command,