cask: move some files to strict Sorbet sigil.

This commit is contained in:
Mike McQuaid 2025-06-17 14:56:10 +01:00
parent 768c10c6fb
commit 35407ab556
No known key found for this signature in database
4 changed files with 41 additions and 6 deletions

View File

@ -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!

View File

@ -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

View File

@ -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
}

View File

@ -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,