From af6e1194d2fac206f65d45015916d1e5fccf55b5 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 11 Jul 2024 21:34:26 -0400 Subject: [PATCH] unpack_strategy/dmg: Convert to Sorbet `typed: strict` - I missed this, whoops. --- Library/Homebrew/unpack_strategy/dmg.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index b63bd439f5..2c302146b0 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true require "tempfile" @@ -14,7 +14,7 @@ module UnpackStrategy module Bom extend SystemCommand::Mixin - DMG_METADATA = Set.new(%w[ + DMG_METADATA = T.let(Set.new(%w[ .background .com.apple.timemachine.donotpresent .com.apple.timemachine.supported @@ -26,12 +26,13 @@ module UnpackStrategy .TemporaryItems .Trashes .VolumeIcon.icns - ]).freeze + ]).freeze, T::Set[String]) private_constant :DMG_METADATA class Error < RuntimeError; end class EmptyError < Error + sig { params(path: Pathname).void } def initialize(path) super "BOM for path '#{path}' is empty." end @@ -81,6 +82,7 @@ module UnpackStrategy class Mount include UnpackStrategy + sig { params(verbose: T::Boolean).void } def eject(verbose: false) tries = 3 begin @@ -176,6 +178,7 @@ module UnpackStrategy [".dmg"] end + sig { override.params(path: Pathname).returns(T::Boolean) } def self.can_extract?(path) stdout, _, status = system_command("hdiutil", args: ["imageinfo", "-format", path], print_stderr: false) status.success? && !stdout.empty? @@ -194,7 +197,8 @@ module UnpackStrategy end end - def mount(verbose: false) + sig { params(verbose: T::Boolean, _block: T.proc.params(arg0: T::Array[Mount]).void).void } + def mount(verbose: false, &_block) Dir.mktmpdir("homebrew-dmg", HOMEBREW_TEMP) do |mount_dir| mount_dir = Pathname(mount_dir)