From 3a4243742f9971101609f2dad952874ad402b1f8 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sat, 30 Nov 2024 13:52:46 -0800 Subject: [PATCH 01/10] Remove OpenStruct from CLI::Args --- Library/.rubocop.yml | 4 - Library/Homebrew/cask/config.rb | 2 + Library/Homebrew/cli/args.rb | 77 +++++++++---------- Library/Homebrew/cli/args.rbi | 24 ------ Library/Homebrew/cli/parser.rb | 15 ++-- Library/Homebrew/cmd/search.rb | 2 +- .../Homebrew/extend/os/linux/cli/parser.rb | 4 +- .../sorbet/rbi/dsl/homebrew/cmd/tap_cmd.rbi | 2 +- .../sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi | 2 +- .../Homebrew/sorbet/tapioca/compilers/args.rb | 17 ++-- .../Homebrew/test/abstract_command_spec.rb | 2 +- Library/Homebrew/test/cask/upgrade_spec.rb | 6 +- .../sorbet/tapioca/compilers/args_spec.rb | 41 +++------- 13 files changed, 77 insertions(+), 121 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 46e926e83aee7..96c2f71e1f6b2 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -408,10 +408,6 @@ Style/NumericLiterals: Style/OpenStructUse: Exclude: - "Taps/**/*" - # TODO: This is a pre-existing violation and should be corrected - # to define methods so that call sites can be type-checked. - - "Homebrew/cli/args.rb" - - "Homebrew/cli/args.rbi" Style/OptionalBooleanParameter: AllowedMethods: diff --git a/Library/Homebrew/cask/config.rb b/Library/Homebrew/cask/config.rb index e34e4417975cd..ae8c2539fb0aa 100644 --- a/Library/Homebrew/cask/config.rb +++ b/Library/Homebrew/cask/config.rb @@ -42,6 +42,8 @@ def self.defaults sig { params(args: Homebrew::CLI::Args).returns(T.attached_class) } def self.from_args(args) + # FIXME: T.unsafe is a workaround for methods that are only defined when `cask_options` + # is invoked on the parser. (These could be captured by a DSL compiler instead.) args = T.unsafe(args) new(explicit: { appdir: args.appdir, diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index f391a8726e465..bd80f8325a3f9 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -1,26 +1,23 @@ # typed: strict # frozen_string_literal: true -require "ostruct" - module Homebrew module CLI - class Args < OpenStruct + class Args # Represents a processed option. The array elements are: # 0: short option name (e.g. "-d") # 1: long option name (e.g. "--debug") # 2: option description (e.g. "Print debugging information") # 3: whether the option is hidden OptionsType = T.type_alias { T::Array[[String, T.nilable(String), String, T::Boolean]] } + sig { returns(T::Array[String]) } - attr_reader :options_only, :flags_only + attr_reader :options_only, :flags_only, :remaining sig { void } def initialize require "cli/named_args" - super - @cli_args = T.let(nil, T.nilable(T::Array[String])) @processed_options = T.let([], OptionsType) @options_only = T.let([], T::Array[String]) @@ -30,30 +27,46 @@ def initialize # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). - self[:named] = NamedArgs.new(parent: self) - self[:remaining] = [] + @named = T.let(NamedArgs.new(parent: self), T.nilable(NamedArgs)) + @remaining = T.let([], T::Array[String]) end sig { params(remaining_args: T::Array[T.any(T::Array[String], String)]).void } - def freeze_remaining_args!(remaining_args) - self[:remaining] = remaining_args.freeze - end + def freeze_remaining_args!(remaining_args) = @remaining.replace(remaining_args).freeze sig { params(named_args: T::Array[String], cask_options: T::Boolean, without_api: T::Boolean).void } def freeze_named_args!(named_args, cask_options:, without_api:) options = {} - options[:force_bottle] = true if self[:force_bottle?] - options[:override_spec] = :head if self[:HEAD?] + options[:force_bottle] = true if force_bottle? + options[:override_spec] = :head if self.HEAD? options[:flags] = flags_only unless flags_only.empty? - self[:named] = NamedArgs.new( - *named_args.freeze, - parent: self, - cask_options:, - without_api:, - **options, + @named = T.let( + NamedArgs.new(*named_args.freeze, parent: self, cask_options:, without_api:, **options), + T.nilable(NamedArgs), ) end + sig { returns(T.nilable(String)) } + def arch = nil + + sig { returns(T::Boolean) } + def build_bottle? = false + + sig { returns(T::Boolean) } + def build_from_source? = false + + sig { returns(T::Boolean) } + def force_bottle? = false + + sig { returns(T::Boolean) } + def HEAD? = false + + sig { returns(T::Boolean) } + def include_test? = false + + sig { returns(T.nilable(String)) } + def os = nil + sig { params(processed_options: OptionsType).void } def freeze_processed_options!(processed_options) # Reset cache values reliant on processed_options @@ -69,7 +82,7 @@ def freeze_processed_options!(processed_options) sig { returns(NamedArgs) } def named require "formula" - self[:named] + T.must(@named) end sig { returns(T::Boolean) } @@ -77,7 +90,7 @@ def no_named? = named.empty? sig { returns(T::Array[String]) } def build_from_source_formulae - if build_from_source? || self[:HEAD?] || self[:build_bottle?] + if build_from_source? || self.HEAD? || build_bottle? named.to_formulae.map(&:full_name) else [] @@ -109,9 +122,9 @@ def context sig { returns(T.nilable(Symbol)) } def only_formula_or_cask - if formula? && !cask? + if invoke_if_respond_to(:formula?) && !invoke_if_respond_to(:cask?) :formula - elsif cask? && !formula? + elsif invoke_if_respond_to(:cask?) && !invoke_if_respond_to(:formula?) :cask end end @@ -174,24 +187,6 @@ def cli_args end end.freeze end - - sig { params(method_name: Symbol, _include_private: T::Boolean).returns(T::Boolean) } - def respond_to_missing?(method_name, _include_private = false) - @table.key?(method_name) - end - - sig { params(method_name: Symbol, args: T.untyped).returns(T.untyped) } - def method_missing(method_name, *args) - return_value = super - - # Once we are frozen, verify any arg method calls are already defined in the table. - # The default OpenStruct behaviour is to return nil for anything unknown. - if frozen? && args.empty? && !@table.key?(method_name) - raise NoMethodError, "CLI arg for `#{method_name}` is not declared for this command" - end - - return_value - end end end end diff --git a/Library/Homebrew/cli/args.rbi b/Library/Homebrew/cli/args.rbi index 11451fdb558e7..7c161fd39becc 100644 --- a/Library/Homebrew/cli/args.rbi +++ b/Library/Homebrew/cli/args.rbi @@ -14,30 +14,6 @@ class Homebrew::CLI::Args sig { returns(T::Boolean) } def quiet?; end - sig { returns(T::Array[String]) } - def remaining; end - sig { returns(T::Boolean) } def verbose?; end - - # FIXME: The methods below are not defined by Args, but are valid because Args inherits from OpenStruct - # We should instead be using type guards to check if the method is defined on the object before calling it - - sig { returns(T.nilable(String)) } - def arch; end - - sig { returns(T::Boolean) } - def build_from_source?; end - - sig { returns(T::Boolean) } - def cask?; end - - sig { returns(T::Boolean) } - def formula?; end - - sig { returns(T::Boolean) } - def include_test?; end - - sig { returns(T.nilable(String)) } - def os; end end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index b1a9465ee481b..9c5eba6ee6da5 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -252,7 +252,7 @@ def comma_array(name, description: nil, hidden: false) description = option_description(description, name, hidden:) process_option(name, description, type: :comma_array, hidden:) @parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, *wrap_option_desc(description)) do |list| - @args[option_to_name(name)] = list + @args.define_singleton_method(option_to_name(name)) { list } end end @@ -277,7 +277,7 @@ def flag(*names, description: nil, replacement: nil, depends_on: nil, hidden: fa # This odisabled should stick around indefinitely. odisabled "the `#{names.first}` flag", replacement unless replacement.nil? names.each do |name| - @args[option_to_name(name)] = option_value + @args.define_singleton_method(option_to_name(name)) { option_value } end end @@ -558,24 +558,27 @@ def generate_banner def set_switch(*names, value:, from:) names.each do |name| @switch_sources[option_to_name(name)] = from - @args["#{option_to_name(name)}?"] = value + @args.define_singleton_method(:"#{option_to_name(name)}?") { value } end end sig { params(args: String).void } def disable_switch(*args) args.each do |name| - @args["#{option_to_name(name)}?"] = if name.start_with?("--[no-]") + result = if name.start_with?("--[no-]") nil else false end + @args.define_singleton_method(:"#{option_to_name(name)}?") { result } end end sig { params(name: String).returns(T::Boolean) } def option_passed?(name) - !!(@args[name.to_sym] || @args[:"#{name}?"]) + [name.to_sym, :"#{name}?"].any? do |method| + @args.public_send(method) if @args.respond_to?(method) + end end sig { params(desc: String).returns(T::Array[String]) } @@ -676,7 +679,7 @@ def process_option(*args, type:, hidden: false) disable_switch(*args) else args.each do |name| - @args[option_to_name(name)] = nil + @args.define_singleton_method(option_to_name(name)) { nil } end end diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 9d0e6cf6bdc9b..7429daec5e2c0 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -108,7 +108,7 @@ def print_regex_help sig { returns(T::Boolean) } def search_package_manager - package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] } + package_manager = PACKAGE_MANAGERS.find { |name,| args.public_send(:"#{name}?") } return false if package_manager.nil? _, url = package_manager diff --git a/Library/Homebrew/extend/os/linux/cli/parser.rb b/Library/Homebrew/extend/os/linux/cli/parser.rb index e5fd59e146cb9..c4f2d7554e39a 100644 --- a/Library/Homebrew/extend/os/linux/cli/parser.rb +++ b/Library/Homebrew/extend/os/linux/cli/parser.rb @@ -11,13 +11,13 @@ module Parser sig { void } def set_default_options - args["formula?"] = true if args.respond_to?(:formula?) + args.define_singleton_method(:formula?) { true } if args.respond_to?(:formula?) end sig { void } def validate_options return unless args.respond_to?(:cask?) - return unless args.cask? + return unless T.unsafe(args).cask? # NOTE: We don't raise an error here because we don't want # to print the help page or a stack trace. diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/tap_cmd.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/tap_cmd.rbi index 2372f2207a684..63c82b860731e 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/tap_cmd.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/tap_cmd.rbi @@ -20,7 +20,7 @@ class Homebrew::Cmd::TapCmd::Args < Homebrew::CLI::Args sig { returns(T::Boolean) } def force?; end - sig { returns(T.nilable(String)) } + sig { returns(T::Boolean) } def force_auto_update?; end sig { returns(T::Boolean) } diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi index 146719a333f8b..9939567b9cab9 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi @@ -71,7 +71,7 @@ class Homebrew::DevCmd::Audit::Args < Homebrew::CLI::Args sig { returns(T.nilable(String)) } def os; end - sig { returns(T.nilable(String)) } + sig { returns(T::Boolean) } def signing?; end sig { returns(T::Boolean) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/args.rb b/Library/Homebrew/sorbet/tapioca/compilers/args.rb index b3ad828b483d2..bf3ee2e77ec1c 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/args.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/args.rb @@ -39,11 +39,8 @@ def decorate end end - sig { params(parser: Homebrew::CLI::Parser).returns(T::Hash[Symbol, T.untyped]) } - def args_table(parser) - # we exclude non-args from the table, such as :named and :remaining - parser.instance_variable_get(:@args).instance_variable_get(:@table).except(:named, :remaining) - end + sig { params(parser: Homebrew::CLI::Parser).returns(T::Array[Symbol]) } + def args_table(parser) = parser.args.methods(false) sig { params(parser: Homebrew::CLI::Parser).returns(T::Array[Symbol]) } def comma_arrays(parser) @@ -51,11 +48,11 @@ def comma_arrays(parser) .filter_map { |k, v| parser.option_to_name(k).to_sym if v == :comma_array } end - sig { params(method_name: Symbol, value: T.untyped, comma_array_methods: T::Array[Symbol]).returns(String) } - def get_return_type(method_name, value, comma_array_methods) + sig { params(method_name: Symbol, comma_array_methods: T::Array[Symbol]).returns(String) } + def get_return_type(method_name, comma_array_methods) if comma_array_methods.include?(method_name) "T.nilable(T::Array[String])" - elsif [true, false].include?(value) + elsif method_name.end_with?("?") "T::Boolean" else "T.nilable(String)" @@ -67,11 +64,11 @@ def get_return_type(method_name, value, comma_array_methods) sig { params(klass: RBI::Scope, parser: Homebrew::CLI::Parser).void } def create_args_methods(klass, parser) comma_array_methods = comma_arrays(parser) - args_table(parser).each do |method_name, value| + args_table(parser).each do |method_name| method_name_str = method_name.to_s next if GLOBAL_OPTIONS.include?(method_name_str) - return_type = get_return_type(method_name, value, comma_array_methods) + return_type = get_return_type(method_name, comma_array_methods) klass.create_method(method_name_str, return_type:) end end diff --git a/Library/Homebrew/test/abstract_command_spec.rb b/Library/Homebrew/test/abstract_command_spec.rb index c6669c842b5da..3c24bb6b83c16 100644 --- a/Library/Homebrew/test/abstract_command_spec.rb +++ b/Library/Homebrew/test/abstract_command_spec.rb @@ -22,7 +22,7 @@ def run; end end it "allows access to args" do - expect(TestCat.new(["--bar", "baz"]).args[:bar]).to eq("baz") + expect(TestCat.new(["--bar", "baz"]).args.bar).to eq("baz") end it "raises on invalid args" do diff --git a/Library/Homebrew/test/cask/upgrade_spec.rb b/Library/Homebrew/test/cask/upgrade_spec.rb index 3b5455fcc4485..d2bf61b2b9c0d 100644 --- a/Library/Homebrew/test/cask/upgrade_spec.rb +++ b/Library/Homebrew/test/cask/upgrade_spec.rb @@ -19,7 +19,11 @@ let(:renamed_app) { Cask::CaskLoader.load("renamed-app") } let(:renamed_app_old_path) { renamed_app.config.appdir.join("OldApp.app") } let(:renamed_app_new_path) { renamed_app.config.appdir.join("NewApp.app") } - let(:args) { Homebrew::CLI::Args.new } + let(:args) do + parser = Homebrew::CLI::Parser.new(Homebrew::Cmd::Brew) + parser.cask_options + parser.args + end before do installed.each do |cask| diff --git a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb index ee50a912a1950..7761721b292e5 100644 --- a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb +++ b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb @@ -18,36 +18,19 @@ describe "#args_table" do it "returns a mapping of list args to default values" do - expect(compiler.args_table(list_parser).keys).to contain_exactly( - :"1?", :built_from_source?, :cask?, :casks?, :d?, :debug?, - :formula?, :formulae?, :full_name?, :h?, :help?, - :installed_as_dependency?, :installed_on_request?, :l?, - :multiple?, :pinned?, :poured_from_bottle?, :q?, :quiet?, - :r?, :t?, :v?, :verbose?, :versions? + expect(compiler.args_table(list_parser)).to contain_exactly( + :"1?", :built_from_source?, :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, :full_name?, :h?, :help?, + :installed_as_dependency?, :installed_on_request?, :l?, :multiple?, :pinned?, :poured_from_bottle?, :q?, + :quiet?, :r?, :t?, :v?, :verbose?, :versions? ) end it "returns a mapping of update-python-resources args to default values" do - expect(compiler.args_table(update_python_resources_parser)).to eq({ - d?: false, - debug?: false, - exclude_packages: nil, - extra_packages: nil, - h?: false, - help?: false, - ignore_non_pypi_packages?: false, - install_dependencies?: false, - p?: false, - package_name: nil, - print_only?: false, - q?: false, - quiet?: false, - s?: false, - silent?: false, - v?: false, - verbose?: false, - version: nil, - }) + expect(compiler.args_table(update_python_resources_parser)).to contain_exactly( + :d?, :debug?, :exclude_packages, :extra_packages, :h?, :help?, :ignore_non_pypi_packages?, + :install_dependencies?, :p?, :package_name, :print_only?, :q?, :quiet?, :s?, :silent?, :v?, :verbose?, + :version + ) end end @@ -65,15 +48,15 @@ let(:comma_arrays) { compiler.comma_arrays(update_python_resources_parser) } it "returns the correct type for switches" do - expect(compiler.get_return_type(:silent?, false, comma_arrays)).to eq("T::Boolean") + expect(compiler.get_return_type(:silent?, comma_arrays)).to eq("T::Boolean") end it "returns the correct type for flags" do - expect(compiler.get_return_type(:package_name, nil, comma_arrays)).to eq("T.nilable(String)") + expect(compiler.get_return_type(:package_name, comma_arrays)).to eq("T.nilable(String)") end it "returns the correct type for comma_arrays" do - expect(compiler.get_return_type(:extra_packages, nil, comma_arrays)).to eq("T.nilable(T::Array[String])") + expect(compiler.get_return_type(:extra_packages, comma_arrays)).to eq("T.nilable(T::Array[String])") end end end From 3ea76b84980ecd67d89753743403dd220d4b84d8 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sun, 1 Dec 2024 10:44:53 -0800 Subject: [PATCH 02/10] Avoid re-defining #formula? --- Library/Homebrew/cli/args.rb | 10 ++++++++-- Library/Homebrew/cli/parser.rb | 8 +------- Library/Homebrew/extend/os/linux/cli/parser.rb | 8 +------- Library/Homebrew/extend/os/parser.rb | 9 +++++++++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index bd80f8325a3f9..7668207e79b7a 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -55,9 +55,15 @@ def build_bottle? = false sig { returns(T::Boolean) } def build_from_source? = false + sig { returns(T::Boolean) } + def cask? = false + sig { returns(T::Boolean) } def force_bottle? = false + # Defined in extend/os: + # def formula; end + sig { returns(T::Boolean) } def HEAD? = false @@ -122,9 +128,9 @@ def context sig { returns(T.nilable(Symbol)) } def only_formula_or_cask - if invoke_if_respond_to(:formula?) && !invoke_if_respond_to(:cask?) + if formula? && !cask? :formula - elsif invoke_if_respond_to(:cask?) && !invoke_if_respond_to(:formula?) + elsif cask? && !formula? :cask end end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 9c5eba6ee6da5..fc3860c4685bf 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -393,10 +393,7 @@ def parse(argv = ARGV.freeze, ignore_invalid_options: false) end unless ignore_invalid_options - unless @is_dev_cmd - set_default_options - validate_options - end + validate_options unless @is_dev_cmd check_constraint_violations check_named_args(named_args) end @@ -416,9 +413,6 @@ def parse(argv = ARGV.freeze, ignore_invalid_options: false) @args end - sig { void } - def set_default_options; end - sig { void } def validate_options; end diff --git a/Library/Homebrew/extend/os/linux/cli/parser.rb b/Library/Homebrew/extend/os/linux/cli/parser.rb index c4f2d7554e39a..ab9b0af05075c 100644 --- a/Library/Homebrew/extend/os/linux/cli/parser.rb +++ b/Library/Homebrew/extend/os/linux/cli/parser.rb @@ -9,15 +9,9 @@ module Parser requires_ancestor { Homebrew::CLI::Parser } - sig { void } - def set_default_options - args.define_singleton_method(:formula?) { true } if args.respond_to?(:formula?) - end - sig { void } def validate_options - return unless args.respond_to?(:cask?) - return unless T.unsafe(args).cask? + return unless args.cask? # NOTE: We don't raise an error here because we don't want # to print the help page or a stack trace. diff --git a/Library/Homebrew/extend/os/parser.rb b/Library/Homebrew/extend/os/parser.rb index fcf79902524d1..9c5095b4e227d 100644 --- a/Library/Homebrew/extend/os/parser.rb +++ b/Library/Homebrew/extend/os/parser.rb @@ -2,3 +2,12 @@ # frozen_string_literal: true require "extend/os/linux/cli/parser" if OS.linux? + +module Homebrew + module CLI + class Args + sig { returns(T::Boolean) } + def formula? = OS.linux? + end + end +end From fef1211c19e25bf4ec9fff7e88c1c835df8b210f Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 14:14:02 -0800 Subject: [PATCH 03/10] Use method result table foo --- Library/Homebrew/cli/args.rb | 18 ++++++++-------- Library/Homebrew/cli/parser.rb | 21 ++++++++++++++----- .../Homebrew/extend/os/linux/cli/parser.rb | 8 ++++++- Library/Homebrew/extend/os/parser.rb | 9 -------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 7668207e79b7a..2b1292b845a2b 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -14,6 +14,9 @@ class Args sig { returns(T::Array[String]) } attr_reader :options_only, :flags_only, :remaining + sig { returns(T::Hash[Symbol, T.untyped]) } + attr_accessor :table + sig { void } def initialize require "cli/named_args" @@ -55,15 +58,9 @@ def build_bottle? = false sig { returns(T::Boolean) } def build_from_source? = false - sig { returns(T::Boolean) } - def cask? = false - sig { returns(T::Boolean) } def force_bottle? = false - # Defined in extend/os: - # def formula; end - sig { returns(T::Boolean) } def HEAD? = false @@ -128,9 +125,11 @@ def context sig { returns(T.nilable(Symbol)) } def only_formula_or_cask - if formula? && !cask? + return if !respond_to?(:formula?) && !respond_to?(:cask?) + + if T.unsafe(self).formula? && !T.unsafe(self).cask? :formula - elsif cask? && !formula? + elsif T.unsafe(self).cask? && !T.unsafe(self).formula? :cask end end @@ -191,7 +190,8 @@ def cli_args elsif @table[flag].instance_of? Array "#{option}=#{@table[flag].join(",")}" end - end.freeze + end + @cli_args.freeze end end end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index fc3860c4685bf..caba7610176a9 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -252,7 +252,7 @@ def comma_array(name, description: nil, hidden: false) description = option_description(description, name, hidden:) process_option(name, description, type: :comma_array, hidden:) @parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, *wrap_option_desc(description)) do |list| - @args.define_singleton_method(option_to_name(name)) { list } + set_args_method(option_to_name(name).to_sym, list) end end @@ -277,7 +277,7 @@ def flag(*names, description: nil, replacement: nil, depends_on: nil, hidden: fa # This odisabled should stick around indefinitely. odisabled "the `#{names.first}` flag", replacement unless replacement.nil? names.each do |name| - @args.define_singleton_method(option_to_name(name)) { option_value } + set_args_method(option_to_name(name).to_sym, option_value) end end @@ -286,6 +286,17 @@ def flag(*names, description: nil, replacement: nil, depends_on: nil, hidden: fa end end + sig { params(name: Symbol, value: T.untyped).void } + def set_args_method(name, value) + @args.table[name] = value + return if @args.respond_to?(name) + + @args.define_singleton_method(name) do + T.bind(self, Args) + table.fetch(name) + end + end + sig { params(options: String).returns(T::Array[T::Array[String]]) } def conflicts(*options) @conflicts << options.map { |option| option_to_name(option) } @@ -552,7 +563,7 @@ def generate_banner def set_switch(*names, value:, from:) names.each do |name| @switch_sources[option_to_name(name)] = from - @args.define_singleton_method(:"#{option_to_name(name)}?") { value } + set_args_method(:"#{option_to_name(name)}?", value) end end @@ -564,7 +575,7 @@ def disable_switch(*args) else false end - @args.define_singleton_method(:"#{option_to_name(name)}?") { result } + set_args_method(:"#{option_to_name(name)}?", result) end end @@ -673,7 +684,7 @@ def process_option(*args, type:, hidden: false) disable_switch(*args) else args.each do |name| - @args.define_singleton_method(option_to_name(name)) { nil } + set_args_method(option_to_name(name).to_sym, nil) end end diff --git a/Library/Homebrew/extend/os/linux/cli/parser.rb b/Library/Homebrew/extend/os/linux/cli/parser.rb index ab9b0af05075c..fbdedd567e28d 100644 --- a/Library/Homebrew/extend/os/linux/cli/parser.rb +++ b/Library/Homebrew/extend/os/linux/cli/parser.rb @@ -9,9 +9,15 @@ module Parser requires_ancestor { Homebrew::CLI::Parser } + sig { void } + def set_default_options + args.table[:formula?] = true if args.respond_to?(:formula?) + end + sig { void } def validate_options - return unless args.cask? + return unless args.respond_to?(:cask?) + return unless T.unsafe(self).args.cask? # NOTE: We don't raise an error here because we don't want # to print the help page or a stack trace. diff --git a/Library/Homebrew/extend/os/parser.rb b/Library/Homebrew/extend/os/parser.rb index 9c5095b4e227d..fcf79902524d1 100644 --- a/Library/Homebrew/extend/os/parser.rb +++ b/Library/Homebrew/extend/os/parser.rb @@ -2,12 +2,3 @@ # frozen_string_literal: true require "extend/os/linux/cli/parser" if OS.linux? - -module Homebrew - module CLI - class Args - sig { returns(T::Boolean) } - def formula? = OS.linux? - end - end -end From 1a83801587b7fc21b3b0f61f0946aa892e867583 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 14:26:18 -0800 Subject: [PATCH 04/10] Add special case for #tap --- Library/Homebrew/cli/args.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 2b1292b845a2b..5ea0f3e8e2f9e 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -70,6 +70,13 @@ def include_test? = false sig { returns(T.nilable(String)) } def os = nil + sig { params(_blk: T.untyped).returns(T.untyped) } + def tap(&_blk) + return super if block_given? # Object#tap + + @table[:tap] + end + sig { params(processed_options: OptionsType).void } def freeze_processed_options!(processed_options) # Reset cache values reliant on processed_options From 2902eec39098048a6487ee4d20ea980bd65c58ba Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 17:55:23 -0800 Subject: [PATCH 05/10] Use table lookups --- Library/Homebrew/cli/args.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 5ea0f3e8e2f9e..82be6cd74002f 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -50,25 +50,25 @@ def freeze_named_args!(named_args, cask_options:, without_api:) end sig { returns(T.nilable(String)) } - def arch = nil + def arch = table[:arch] sig { returns(T::Boolean) } - def build_bottle? = false + def build_bottle? = table[:build_bottle?] || false sig { returns(T::Boolean) } - def build_from_source? = false + def build_from_source? = table[:build_from_source?] || false sig { returns(T::Boolean) } - def force_bottle? = false + def force_bottle? = table[:force_bottle?] || false sig { returns(T::Boolean) } - def HEAD? = false + def HEAD? = table[:HEAD?] || false sig { returns(T::Boolean) } - def include_test? = false + def include_test? = table[:include_test?] || false sig { returns(T.nilable(String)) } - def os = nil + def os = table[:os] sig { params(_blk: T.untyped).returns(T.untyped) } def tap(&_blk) From 6d19b84ef1ff416c9b645d779edd0616ae64ad96 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 18:09:56 -0800 Subject: [PATCH 06/10] Fix args validation --- Library/Homebrew/cli/parser.rb | 8 +++++++- Library/Homebrew/extend/os/linux/cli/parser.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index caba7610176a9..daae55e9b54c2 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -404,7 +404,10 @@ def parse(argv = ARGV.freeze, ignore_invalid_options: false) end unless ignore_invalid_options - validate_options unless @is_dev_cmd + unless @is_dev_cmd + set_default_options + validate_options + end check_constraint_violations check_named_args(named_args) end @@ -424,6 +427,9 @@ def parse(argv = ARGV.freeze, ignore_invalid_options: false) @args end + sig { void } + def set_default_options; end + sig { void } def validate_options; end diff --git a/Library/Homebrew/extend/os/linux/cli/parser.rb b/Library/Homebrew/extend/os/linux/cli/parser.rb index fbdedd567e28d..b8de7c5aa1700 100644 --- a/Library/Homebrew/extend/os/linux/cli/parser.rb +++ b/Library/Homebrew/extend/os/linux/cli/parser.rb @@ -11,7 +11,7 @@ module Parser sig { void } def set_default_options - args.table[:formula?] = true if args.respond_to?(:formula?) + args.table[:formula?] = true end sig { void } From 659f993dabb1285ca5116d5344e34bffb23fc1b0 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 20:08:02 -0800 Subject: [PATCH 07/10] Avoid exposing table --- Library/Homebrew/cli/args.rb | 52 +++++++++++-------- Library/Homebrew/cli/parser.rb | 6 +-- .../Homebrew/extend/os/linux/cli/parser.rb | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 82be6cd74002f..e17712a1c4a41 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -14,9 +14,6 @@ class Args sig { returns(T::Array[String]) } attr_reader :options_only, :flags_only, :remaining - sig { returns(T::Hash[Symbol, T.untyped]) } - attr_accessor :table - sig { void } def initialize require "cli/named_args" @@ -26,7 +23,13 @@ def initialize @options_only = T.let([], T::Array[String]) @flags_only = T.let([], T::Array[String]) @cask_options = T.let(false, T::Boolean) - @table = T.let({}, T::Hash[Symbol, T.untyped]) + @table = T.let({ + build_bottle?: false, + build_from_source?: false, + force_bottle?: false, + HEAD?: false, + include_test?: false, + }, T::Hash[Symbol, T.untyped]) # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). @@ -39,38 +42,47 @@ def freeze_remaining_args!(remaining_args) = @remaining.replace(remaining_args). sig { params(named_args: T::Array[String], cask_options: T::Boolean, without_api: T::Boolean).void } def freeze_named_args!(named_args, cask_options:, without_api:) - options = {} - options[:force_bottle] = true if force_bottle? - options[:override_spec] = :head if self.HEAD? - options[:flags] = flags_only unless flags_only.empty? @named = T.let( - NamedArgs.new(*named_args.freeze, parent: self, cask_options:, without_api:, **options), + NamedArgs.new( + *named_args.freeze, + cask_options:, + flags: flags_only, + force_bottle: force_bottle?, + override_spec: self.HEAD? ? :head : nil, + parent: self, + without_api:, + ), T.nilable(NamedArgs), ) end sig { returns(T.nilable(String)) } - def arch = table[:arch] + def arch = @table[:arch] sig { returns(T::Boolean) } - def build_bottle? = table[:build_bottle?] || false + def build_bottle? = @table.fetch(:build_bottle?) sig { returns(T::Boolean) } - def build_from_source? = table[:build_from_source?] || false + def build_from_source? = @table.fetch(:build_from_source?) sig { returns(T::Boolean) } - def force_bottle? = table[:force_bottle?] || false + def force_bottle? = @table.fetch(:force_bottle?) sig { returns(T::Boolean) } - def HEAD? = table[:HEAD?] || false + def HEAD? = @table.fetch(:HEAD?) sig { returns(T::Boolean) } - def include_test? = table[:include_test?] || false + def include_test? = @table.fetch(:include_test?) sig { returns(T.nilable(String)) } - def os = table[:os] + def os = @table[:os] + + sig { params(name: Symbol, value: T.untyped).void } + def set_arg(name, value) + @table[name] = value + end - sig { params(_blk: T.untyped).returns(T.untyped) } + sig { params(_blk: T.nilable(T.proc.params(x: T.untyped).void)).returns(T.untyped) } def tap(&_blk) return super if block_given? # Object#tap @@ -132,11 +144,9 @@ def context sig { returns(T.nilable(Symbol)) } def only_formula_or_cask - return if !respond_to?(:formula?) && !respond_to?(:cask?) - - if T.unsafe(self).formula? && !T.unsafe(self).cask? + if @table[:formula?] && !@table[:cask?] :formula - elsif T.unsafe(self).cask? && !T.unsafe(self).formula? + elsif @table[:cask?] && !@table[:formula?] :cask end end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index daae55e9b54c2..d74ad34cbec6d 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -288,12 +288,12 @@ def flag(*names, description: nil, replacement: nil, depends_on: nil, hidden: fa sig { params(name: Symbol, value: T.untyped).void } def set_args_method(name, value) - @args.table[name] = value + @args.set_arg(name, value) return if @args.respond_to?(name) @args.define_singleton_method(name) do - T.bind(self, Args) - table.fetch(name) + # We cannot reference the ivar directly due to https://github.com/sorbet/sorbet/issues/8106 + instance_variable_get(:@table).fetch(name) end end diff --git a/Library/Homebrew/extend/os/linux/cli/parser.rb b/Library/Homebrew/extend/os/linux/cli/parser.rb index b8de7c5aa1700..feb4eb2aabffe 100644 --- a/Library/Homebrew/extend/os/linux/cli/parser.rb +++ b/Library/Homebrew/extend/os/linux/cli/parser.rb @@ -11,7 +11,7 @@ module Parser sig { void } def set_default_options - args.table[:formula?] = true + args.set_arg(:formula?, true) end sig { void } From aa7da18d88f3807cf736df550d8cbd4a18a423aa Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 20:15:48 -0800 Subject: [PATCH 08/10] Access table internally --- Library/Homebrew/cli/args.rb | 41 ++++++------------------------------ 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index e17712a1c4a41..09d4d091d7a18 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -23,13 +23,7 @@ def initialize @options_only = T.let([], T::Array[String]) @flags_only = T.let([], T::Array[String]) @cask_options = T.let(false, T::Boolean) - @table = T.let({ - build_bottle?: false, - build_from_source?: false, - force_bottle?: false, - HEAD?: false, - include_test?: false, - }, T::Hash[Symbol, T.untyped]) + @table = T.let({}, T::Hash[Symbol, T.untyped]) # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). @@ -47,8 +41,8 @@ def freeze_named_args!(named_args, cask_options:, without_api:) *named_args.freeze, cask_options:, flags: flags_only, - force_bottle: force_bottle?, - override_spec: self.HEAD? ? :head : nil, + force_bottle: @table[:force_bottle?] || false, + override_spec: @table[:HEAD?] ? :head : nil, parent: self, without_api:, ), @@ -56,27 +50,6 @@ def freeze_named_args!(named_args, cask_options:, without_api:) ) end - sig { returns(T.nilable(String)) } - def arch = @table[:arch] - - sig { returns(T::Boolean) } - def build_bottle? = @table.fetch(:build_bottle?) - - sig { returns(T::Boolean) } - def build_from_source? = @table.fetch(:build_from_source?) - - sig { returns(T::Boolean) } - def force_bottle? = @table.fetch(:force_bottle?) - - sig { returns(T::Boolean) } - def HEAD? = @table.fetch(:HEAD?) - - sig { returns(T::Boolean) } - def include_test? = @table.fetch(:include_test?) - - sig { returns(T.nilable(String)) } - def os = @table[:os] - sig { params(name: Symbol, value: T.untyped).void } def set_arg(name, value) @table[name] = value @@ -112,7 +85,7 @@ def no_named? = named.empty? sig { returns(T::Array[String]) } def build_from_source_formulae - if build_from_source? || self.HEAD? || build_bottle? + if @table[:build_from_source?] || @table[:HEAD?] || @table[:build_bottle?] named.to_formulae.map(&:full_name) else [] @@ -121,7 +94,7 @@ def build_from_source_formulae sig { returns(T::Array[String]) } def include_test_formulae - if include_test? + if @table[:include_test?] named.to_formulae.map(&:full_name) else [] @@ -155,7 +128,7 @@ def only_formula_or_cask def os_arch_combinations skip_invalid_combinations = false - oses = case (os_sym = os&.to_sym) + oses = case (os_sym = @table[:os]&.to_sym) when nil [SimulateSystem.current_os] when :all @@ -166,7 +139,7 @@ def os_arch_combinations [os_sym] end - arches = case (arch_sym = arch&.to_sym) + arches = case (arch_sym = @table[:arch]&.to_sym) when nil [SimulateSystem.current_arch] when :all From 73046d68ff0591ccbc6f9291f0db30073aad5f64 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 20:19:04 -0800 Subject: [PATCH 09/10] Make cli_args idiomatic --- Library/Homebrew/cli/args.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 09d4d091d7a18..18e9c0c223947 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -180,8 +180,7 @@ def cli_args elsif @table[flag].instance_of? Array "#{option}=#{@table[flag].join(",")}" end - end - @cli_args.freeze + end.freeze end end end From ce9216e66cb2f5799ac712dd6eb63abb26de96e2 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 6 Dec 2024 20:28:41 -0800 Subject: [PATCH 10/10] Fix use of tap --- Library/Homebrew/cli/args.rb | 2 +- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/dev-cmd/bump.rb | 2 +- Library/Homebrew/dev-cmd/livecheck.rb | 2 +- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi | 3 --- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi | 3 --- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi | 3 --- .../sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi | 3 --- .../Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi | 3 --- .../Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_automerge.rbi | 3 --- .../Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi | 3 --- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_pull.rbi | 3 --- 12 files changed, 4 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 18e9c0c223947..f3358bfc10881 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -55,7 +55,7 @@ def set_arg(name, value) @table[name] = value end - sig { params(_blk: T.nilable(T.proc.params(x: T.untyped).void)).returns(T.untyped) } + sig { override.params(_blk: T.nilable(T.proc.params(x: T.untyped).void)).returns(T.untyped) } def tap(&_blk) return super if block_given? # Object#tap diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 21682ae9ed7cc..03d9599e6cbb3 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -125,7 +125,7 @@ def run audit_formulae, audit_casks = Homebrew.with_no_api_env do # audit requires full Ruby source if args.tap - Tap.fetch(T.must(args.tap)).then do |tap| + Tap.fetch(args.tap).then do |tap| [ tap.formula_files.map { |path| Formulary.factory(path) }, tap.cask_files.map { |path| Cask::CaskLoader.load(path) }, diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index 4b2be96bc9c53..f635e5b22985a 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -86,7 +86,7 @@ def run Formulary.factory(qualified_name) end elsif args.tap - tap = Tap.fetch(T.must(args.tap)) + tap = Tap.fetch(args.tap) raise UsageError, "`--tap` requires `--auto` for official taps." if tap.official? formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) } diff --git a/Library/Homebrew/dev-cmd/livecheck.rb b/Library/Homebrew/dev-cmd/livecheck.rb index b2ffcbdb16205..b811ad4fe614f 100644 --- a/Library/Homebrew/dev-cmd/livecheck.rb +++ b/Library/Homebrew/dev-cmd/livecheck.rb @@ -60,7 +60,7 @@ def run formulae_and_casks_to_check = Homebrew.with_no_api_env do if args.tap - tap = Tap.fetch(T.must(args.tap)) + tap = Tap.fetch(args.tap) formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) } casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) } formulae + casks diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi index 9939567b9cab9..2665fe78c2c38 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/audit.rbi @@ -80,9 +80,6 @@ class Homebrew::DevCmd::Audit::Args < Homebrew::CLI::Args sig { returns(T::Boolean) } def strict?; end - sig { returns(T.nilable(String)) } - def tap; end - sig { returns(T::Boolean) } def token_conflicts?; end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi index a44d6ec9556a6..1e750628c45e3 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi @@ -49,7 +49,4 @@ class Homebrew::DevCmd::Bump::Args < Homebrew::CLI::Args sig { returns(T.nilable(String)) } def start_with; end - - sig { returns(T.nilable(String)) } - def tap; end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi index bbfe7510c9c8f..3d94822e23083 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi @@ -64,7 +64,4 @@ class Homebrew::DevCmd::Create::Args < Homebrew::CLI::Args sig { returns(T.nilable(String)) } def set_version; end - - sig { returns(T.nilable(String)) } - def tap; end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi index 1b71f8cc0fd8b..3f45ac1ca51ab 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi @@ -26,9 +26,6 @@ class Homebrew::DevCmd::DispatchBuildBottle::Args < Homebrew::CLI::Args sig { returns(T.nilable(T::Array[String])) } def macos; end - sig { returns(T.nilable(String)) } - def tap; end - sig { returns(T.nilable(String)) } def timeout; end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi index 747ea49b71de2..0729c85370925 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi @@ -46,7 +46,4 @@ class Homebrew::DevCmd::LivecheckCmd::Args < Homebrew::CLI::Args sig { returns(T::Boolean) } def resources?; end - - sig { returns(T.nilable(String)) } - def tap; end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_automerge.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_automerge.rbi index d2b63c6ab001d..f16fc3dbeeda6 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_automerge.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_automerge.rbi @@ -20,9 +20,6 @@ class Homebrew::DevCmd::PrAutomerge::Args < Homebrew::CLI::Args sig { returns(T::Boolean) } def publish?; end - sig { returns(T.nilable(String)) } - def tap; end - sig { returns(T.nilable(String)) } def with_label; end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi index c1eff16f78afc..820496cff5573 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_publish.rbi @@ -23,9 +23,6 @@ class Homebrew::DevCmd::PrPublish::Args < Homebrew::CLI::Args sig { returns(T.nilable(String)) } def message; end - sig { returns(T.nilable(String)) } - def tap; end - sig { returns(T.nilable(String)) } def workflow; end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_pull.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_pull.rbi index 8a8ac7add7222..ec30c08923d9f 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_pull.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/pr_pull.rbi @@ -65,9 +65,6 @@ class Homebrew::DevCmd::PrPull::Args < Homebrew::CLI::Args sig { returns(T.nilable(String)) } def root_url_using; end - sig { returns(T.nilable(String)) } - def tap; end - sig { returns(T::Boolean) } def warn_on_upload_failure?; end