dev-cmd: set typed: strict

This commit is contained in:
Mike McQuaid 2025-06-17 16:34:19 +01:00
parent 09eaf1495a
commit ca1e08c7a8
No known key found for this signature in database

View File

@ -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