From 98ec6a9722158fb83c4a8ab7a873932386383380 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sat, 27 Jul 2024 21:30:10 +1000 Subject: [PATCH 1/4] unpack_strategy: update types --- Library/Homebrew/unpack_strategy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/unpack_strategy.rb b/Library/Homebrew/unpack_strategy.rb index b3581c8ad7..382e82533d 100644 --- a/Library/Homebrew/unpack_strategy.rb +++ b/Library/Homebrew/unpack_strategy.rb @@ -187,7 +187,7 @@ module UnpackStrategy end end - sig { returns(T::Array[String]) } + sig { returns(T.any(T::Array[Cask::Cask], T::Array[Formula])) } def dependencies [] end From 0a658a32901bc447441d639010840d53cf265b05 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sun, 28 Jul 2024 22:31:11 +1000 Subject: [PATCH 2/4] unpack_strategy/p7zip: update types --- Library/Homebrew/unpack_strategy/p7zip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/unpack_strategy/p7zip.rb b/Library/Homebrew/unpack_strategy/p7zip.rb index 44a8c4b986..c1e10cfb92 100644 --- a/Library/Homebrew/unpack_strategy/p7zip.rb +++ b/Library/Homebrew/unpack_strategy/p7zip.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\A7z\xBC\xAF\x27\x1C/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["p7zip"]], T.nilable(T::Array[Formula])) end From 6918160fd944f89c4c19ff63329c3a15c6e5dead Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 28 Jul 2024 10:12:18 -0400 Subject: [PATCH 3/4] UnpackStrategy: Make #dependencies non-nilable `T.nilable` was removed from the `P7Zip#dependencies` type signature in a previous commit, as `UnpackStrategy#dependencies` doesn't allow for a nilable return type. This updates the type signature for the other `#dependencies` methods to also remove `T.nilable`, as they would produce a runtime error otherwise. --- Library/Homebrew/unpack_strategy/air.rb | 2 +- Library/Homebrew/unpack_strategy/cab.rb | 2 +- Library/Homebrew/unpack_strategy/generic_unar.rb | 2 +- Library/Homebrew/unpack_strategy/lha.rb | 2 +- Library/Homebrew/unpack_strategy/lzip.rb | 2 +- Library/Homebrew/unpack_strategy/lzma.rb | 2 +- Library/Homebrew/unpack_strategy/rar.rb | 2 +- Library/Homebrew/unpack_strategy/xz.rb | 2 +- Library/Homebrew/unpack_strategy/zstd.rb | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/unpack_strategy/air.rb b/Library/Homebrew/unpack_strategy/air.rb index 6415995419..371fc29ae8 100644 --- a/Library/Homebrew/unpack_strategy/air.rb +++ b/Library/Homebrew/unpack_strategy/air.rb @@ -17,7 +17,7 @@ module UnpackStrategy path.magic_number.match?(/.{59}#{Regexp.escape(mime_type)}/) end - sig { returns(T.nilable(T::Array[Cask::Cask])) } + sig { returns(T::Array[Cask::Cask]) } def dependencies @dependencies ||= T.let([Cask::CaskLoader.load("adobe-air")], T.nilable(T::Array[Cask::Cask])) end diff --git a/Library/Homebrew/unpack_strategy/cab.rb b/Library/Homebrew/unpack_strategy/cab.rb index a4cc7993a6..c9427f86fc 100644 --- a/Library/Homebrew/unpack_strategy/cab.rb +++ b/Library/Homebrew/unpack_strategy/cab.rb @@ -24,7 +24,7 @@ module UnpackStrategy verbose: end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["cabextract"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/generic_unar.rb b/Library/Homebrew/unpack_strategy/generic_unar.rb index ecc6e2c256..d5ef55bf61 100644 --- a/Library/Homebrew/unpack_strategy/generic_unar.rb +++ b/Library/Homebrew/unpack_strategy/generic_unar.rb @@ -16,7 +16,7 @@ module UnpackStrategy false end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["unar"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/lha.rb b/Library/Homebrew/unpack_strategy/lha.rb index 0fdb49ed55..c20f7e6521 100644 --- a/Library/Homebrew/unpack_strategy/lha.rb +++ b/Library/Homebrew/unpack_strategy/lha.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\A..-(lh0|lh1|lz4|lz5|lzs|lh\\40|lhd|lh2|lh3|lh4|lh5)-/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["lha"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/lzip.rb b/Library/Homebrew/unpack_strategy/lzip.rb index 710f3684db..732897a922 100644 --- a/Library/Homebrew/unpack_strategy/lzip.rb +++ b/Library/Homebrew/unpack_strategy/lzip.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\ALZIP/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["lzip"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/lzma.rb b/Library/Homebrew/unpack_strategy/lzma.rb index d1b6710c42..a4ff75ac0b 100644 --- a/Library/Homebrew/unpack_strategy/lzma.rb +++ b/Library/Homebrew/unpack_strategy/lzma.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\A\]\000\000\200\000/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["xz"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/rar.rb b/Library/Homebrew/unpack_strategy/rar.rb index 7d8109d654..8336d99b08 100644 --- a/Library/Homebrew/unpack_strategy/rar.rb +++ b/Library/Homebrew/unpack_strategy/rar.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\ARar!/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["libarchive"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/xz.rb b/Library/Homebrew/unpack_strategy/xz.rb index 2e155c687b..55b6d289de 100644 --- a/Library/Homebrew/unpack_strategy/xz.rb +++ b/Library/Homebrew/unpack_strategy/xz.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\A\xFD7zXZ\x00/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["xz"]], T.nilable(T::Array[Formula])) end diff --git a/Library/Homebrew/unpack_strategy/zstd.rb b/Library/Homebrew/unpack_strategy/zstd.rb index 475b0ca518..38a3328f32 100644 --- a/Library/Homebrew/unpack_strategy/zstd.rb +++ b/Library/Homebrew/unpack_strategy/zstd.rb @@ -16,7 +16,7 @@ module UnpackStrategy path.magic_number.match?(/\x28\xB5\x2F\xFD/n) end - sig { returns(T.nilable(T::Array[Formula])) } + sig { returns(T::Array[Formula]) } def dependencies @dependencies ||= T.let([Formula["zstd"]], T.nilable(T::Array[Formula])) end From a196898ad31cc2743cfafa5262d1d6f9e945e5cc Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 28 Jul 2024 10:17:23 -0400 Subject: [PATCH 4/4] unpack_strategy/cab: align method order This simply moves the `Cab#dependencies` method above `#extract_to_dir`, to align it with the other strategies. --- Library/Homebrew/unpack_strategy/cab.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/unpack_strategy/cab.rb b/Library/Homebrew/unpack_strategy/cab.rb index c9427f86fc..cb3aa57ee9 100644 --- a/Library/Homebrew/unpack_strategy/cab.rb +++ b/Library/Homebrew/unpack_strategy/cab.rb @@ -16,6 +16,11 @@ module UnpackStrategy path.magic_number.match?(/\AMSCF/n) end + sig { returns(T::Array[Formula]) } + def dependencies + @dependencies ||= T.let([Formula["cabextract"]], T.nilable(T::Array[Formula])) + end + sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).void } def extract_to_dir(unpack_dir, basename:, verbose:) system_command! "cabextract", @@ -23,10 +28,5 @@ module UnpackStrategy env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV.fetch("PATH")) }, verbose: end - - sig { returns(T::Array[Formula]) } - def dependencies - @dependencies ||= T.let([Formula["cabextract"]], T.nilable(T::Array[Formula])) - end end end