From 11a9086b894d1d2744500b2c5b2e02a16954fbe6 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 21 Jul 2023 19:48:28 -0700 Subject: [PATCH 1/2] Fix inreplace sig Implicit Pathname strings strike again --- Library/Homebrew/formula.rb | 8 ++++++++ Library/Homebrew/utils/inreplace.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index fa4e578d2d..f944db7e3a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2472,6 +2472,14 @@ class Formula # # @see Utils::Inreplace.inreplace # @api public + sig { + params( + paths: T.any(T::Array[T.untyped], String, Pathname), + before: T.nilable(T.any(Regexp, String)), + after: T.nilable(T.any(Pathname, String, Symbol)), + audit_result: T::Boolean, + ).void + } def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter super(paths, before, after, audit_result) rescue Utils::Inreplace::Error => e diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 9e3118a430..c2f627ebea 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -41,12 +41,12 @@ module Utils params( paths: T.any(T::Array[T.untyped], String, Pathname), before: T.nilable(T.any(Regexp, String)), - after: T.nilable(T.any(String, Symbol)), + after: T.nilable(T.any(Pathname, String, Symbol)), audit_result: T::Boolean, ).void } def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter - after = after.to_s if after.is_a? Symbol + after &&= after.to_s errors = {} From f55c2a4e8ec4f22125a161d3d90d5666c3d1bc8e Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 21 Jul 2023 20:09:00 -0700 Subject: [PATCH 2/2] Fix type error --- Library/Homebrew/formula.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f944db7e3a..f1123f9246 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2484,7 +2484,8 @@ class Formula super(paths, before, after, audit_result) rescue Utils::Inreplace::Error => e onoe e.to_s - raise BuildError.new(self, "inreplace", paths, {}) + args = paths.is_a?(Array) ? paths : [paths] + raise BuildError.new(self, "inreplace", args, {}) end protected