From 9bd85f30d8fce630fb5a8a3f593b30484a32be69 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Fri, 27 Sep 2024 12:30:49 -0400 Subject: [PATCH] warnings: `typed: strict` --- Library/Homebrew/warnings.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/warnings.rb b/Library/Homebrew/warnings.rb index 955d8caa7c707..454b488d8be46 100644 --- a/Library/Homebrew/warnings.rb +++ b/Library/Homebrew/warnings.rb @@ -1,19 +1,20 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "warning" # Helper module for handling warnings. module Warnings - COMMON_WARNINGS = { + COMMON_WARNINGS = T.let({ parser_syntax: [ %r{warning: parser/current is loading parser/ruby\d+, which recognizes}, /warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./, %r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.}, ], - }.freeze + }.freeze, T::Hash[Symbol, T::Array[Regexp]]) - def self.ignore(*warnings) + sig { params(warnings: T.any(Symbol, Regexp), _block: T.nilable(T.proc.void)).void } + def self.ignore(*warnings, &_block) warnings.map! do |warning| next warning if !warning.is_a?(Symbol) || !COMMON_WARNINGS.key?(warning) @@ -25,8 +26,7 @@ def self.ignore(*warnings) end return unless block_given? - result = yield + yield Warning.clear - result end end