From ca1e08c7a8e5b1ca010cae508a5d541a9200845e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jun 2025 16:34:19 +0100 Subject: [PATCH] dev-cmd: set `typed: strict` --- Library/Homebrew/dev-cmd/extract.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 6063f9314f..bef3247be9 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:disable Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "abstract_command" @@ -172,7 +172,8 @@ module Homebrew with_monkey_patch { Formulary.from_contents(name, file, contents, ignore_errors: true) } end - def with_monkey_patch + sig { params(_block: T.proc.void).returns(T.untyped) } + def with_monkey_patch(&_block) # Since `method_defined?` is not a supported type guard, the use of `alias_method` below is not typesafe: BottleSpecification.class_eval do T.unsafe(self).alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) @@ -210,28 +211,28 @@ module Homebrew BottleSpecification.class_eval do if method_defined?(:old_method_missing) T.unsafe(self).alias_method :method_missing, :old_method_missing - undef :old_method_missing + T.unsafe(self).undef :old_method_missing end end Module.class_eval do if method_defined?(:old_method_missing) T.unsafe(self).alias_method :method_missing, :old_method_missing - undef :old_method_missing + T.unsafe(self).undef :old_method_missing end end Resource.class_eval do if method_defined?(:old_method_missing) T.unsafe(self).alias_method :method_missing, :old_method_missing - undef :old_method_missing + T.unsafe(self).undef :old_method_missing end end DependencyCollector.class_eval do if method_defined?(:old_parse_symbol_spec) T.unsafe(self).alias_method :parse_symbol_spec, :old_parse_symbol_spec - undef :old_parse_symbol_spec + T.unsafe(self).undef :old_parse_symbol_spec end end end