From 0e064fdc3ae1cf605656fc45a0cc5451ee0f6582 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sat, 16 Aug 2025 12:54:42 -0700 Subject: [PATCH] Type remaining Kernel log extensions --- Library/Homebrew/download_strategy.rb | 10 +++++----- Library/Homebrew/extend/kernel.rb | 2 ++ Library/Homebrew/formula_versions.rb | 1 + Library/Homebrew/messages.rb | 6 +++--- Library/Homebrew/utils/repology.rb | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 37bef20cf0..dcb4b7834a 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -148,6 +148,11 @@ class AbstractDownloadStrategy cached_location.basename end + sig { override.params(title: T.any(String, Exception), sput: T.anything).void } + def ohai(title, *sput) + super unless quiet? + end + private sig { params(args: T.anything).void } @@ -155,11 +160,6 @@ class AbstractDownloadStrategy super unless quiet? end - sig { params(args: T.anything).void } - def ohai(*args) - super unless quiet? - end - sig { params(args: String, options: T.untyped).returns(SystemCommand::Result) } def silent_command(*args, **options) system_command(*args, print_stderr: false, env:, **options) diff --git a/Library/Homebrew/extend/kernel.rb b/Library/Homebrew/extend/kernel.rb index 4500f1eb5e..6ff0c68274 100644 --- a/Library/Homebrew/extend/kernel.rb +++ b/Library/Homebrew/extend/kernel.rb @@ -44,11 +44,13 @@ module Kernel Formatter.headline(title, color: :blue) end + sig { params(title: T.any(String, Exception), sput: T.anything).void } def ohai(title, *sput) puts ohai_title(title.to_s) puts sput end + sig { params(title: T.any(String, Exception), sput: T.anything, always_display: T::Boolean).void } def odebug(title, *sput, always_display: false) debug = if respond_to?(:debug) T.unsafe(self).debug? diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 62a650fd0b..eb687c68b4 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -60,6 +60,7 @@ class FormulaVersions # We rescue these so that we can skip bad versions and # continue walking the history odebug "#{e} in #{name} at revision #{revision}", Utils::Backtrace.clean(e) + nil rescue FormulaUnavailableError nil ensure diff --git a/Library/Homebrew/messages.rb b/Library/Homebrew/messages.rb index 830ce46fac..3ed0a2831a 100644 --- a/Library/Homebrew/messages.rb +++ b/Library/Homebrew/messages.rb @@ -4,7 +4,7 @@ # A {Messages} object collects messages that may need to be displayed together # at the end of a multi-step `brew` command run. class Messages - sig { returns(T::Array[T::Hash[Symbol, Symbol]]) } + sig { returns(T::Array[{ package: String, caveats: T.any(String, Caveats) }]) } attr_reader :caveats sig { returns(Integer) } @@ -15,7 +15,7 @@ class Messages sig { void } def initialize - @caveats = T.let([], T::Array[T::Hash[Symbol, Symbol]]) + @caveats = T.let([], T::Array[{ package: String, caveats: T.any(String, Caveats) }]) @completions_and_elisp = T.let(Set.new, T::Set[String]) @package_count = T.let(0, Integer) @install_times = T.let([], T::Array[T::Hash[String, Float]]) @@ -53,7 +53,7 @@ class Messages return if @package_count == 1 && !force oh1 "Caveats" if @completions_and_elisp.empty? - @caveats.each { |c| ohai c[:package], c[:caveats] } + @caveats.each { |c| ohai c.fetch(:package), c.fetch(:caveats) } end sig { void } diff --git a/Library/Homebrew/utils/repology.rb b/Library/Homebrew/utils/repology.rb index 54bbcb1a6f..a008be62a3 100644 --- a/Library/Homebrew/utils/repology.rb +++ b/Library/Homebrew/utils/repology.rb @@ -24,7 +24,7 @@ module Repology if Homebrew::EnvConfig.developer? $stderr.puts result&.stderr else - odebug result&.stderr + odebug result&.stderr.to_s end raise