diff --git a/Library/Homebrew/attrable.rb b/Library/Homebrew/attrable.rb deleted file mode 100644 index 590a6f147d..0000000000 --- a/Library/Homebrew/attrable.rb +++ /dev/null @@ -1,21 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -# This module provides methods to define specialized attributes. -# Method stubs are generated by the {Tapioca::Compilers::Attrables} compiler. -# @note The compiler is fragile, and must be updated if the filename changes, if methods are added or removed, -# or if a method's arity changes. -module Attrable - extend T::Helpers - - requires_ancestor { Module } - - sig { params(attrs: Symbol).void } - def attr_predicate(*attrs) - attrs.each do |attr| - define_method attr do - instance_variable_get("@#{attr.to_s.sub(/\?$/, "")}") == true - end - end - end -end diff --git a/Library/Homebrew/cask/artifact/abstract_artifact.rb b/Library/Homebrew/cask/artifact/abstract_artifact.rb index 7a509970f9..09ed1fabe8 100644 --- a/Library/Homebrew/cask/artifact/abstract_artifact.rb +++ b/Library/Homebrew/cask/artifact/abstract_artifact.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "extend/object/deep_dup" module Cask diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index f59ff7bdd8..0a64100adc 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "cask/denylist" require "cask/download" require "digest" @@ -19,7 +18,6 @@ module Cask class Audit include SystemCommand::Mixin include ::Utils::Curl - extend Attrable sig { returns(Cask) } attr_reader :cask @@ -27,11 +25,16 @@ module Cask sig { returns(T.nilable(Download)) } attr_reader :download - attr_predicate :new_cask?, :strict?, :signing?, :online?, :token_conflicts? - + sig { + params( + cask: ::Cask::Cask, download: T::Boolean, quarantine: T::Boolean, token_conflicts: T.nilable(T::Boolean), + online: T.nilable(T::Boolean), strict: T.nilable(T::Boolean), signing: T.nilable(T::Boolean), + new_cask: T.nilable(T::Boolean), only: T::Array[String], except: T::Array[String] + ).void + } def initialize( cask, - download: nil, quarantine: nil, + download: false, quarantine: false, token_conflicts: nil, online: nil, strict: nil, signing: nil, new_cask: nil, only: [], except: [] ) @@ -42,7 +45,7 @@ module Cask token_conflicts = new_cask if token_conflicts.nil? # `online` and `signing` imply `download` - download = online || signing if download.nil? + download ||= online || signing @cask = cask @download = Download.new(cask, quarantine:) if download @@ -51,18 +54,34 @@ module Cask @signing = signing @new_cask = new_cask @token_conflicts = token_conflicts - @only = only || [] - @except = except || [] + @only = only + @except = except end + sig { returns(T::Boolean) } + def new_cask? = !!@new_cask + + sig { returns(T::Boolean) } + def online? =!!@online + + sig { returns(T::Boolean) } + def signing? = !!@signing + + sig { returns(T::Boolean) } + def strict? = !!@strict + + sig { returns(T::Boolean) } + def token_conflicts? = !!@token_conflicts + + sig { returns(::Cask::Audit) } def run! only_audits = @only except_audits = @except private_methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| name = audit_method_name.delete_prefix("audit_") - next if !only_audits.empty? && only_audits&.exclude?(name) - next if except_audits&.include?(name) + next if !only_audits.empty? && only_audits.exclude?(name) + next if except_audits.include?(name) send(audit_method_name) end diff --git a/Library/Homebrew/cask/auditor.rb b/Library/Homebrew/cask/auditor.rb index f79de72185..0af5f20860 100644 --- a/Library/Homebrew/cask/auditor.rb +++ b/Library/Homebrew/cask/auditor.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "cask/audit" @@ -6,22 +6,50 @@ require "cask/audit" module Cask # Helper class for auditing all available languages of a cask. class Auditor - def self.audit(cask, **options) - new(cask, **options).audit + # TODO: use argument forwarding (...) when Sorbet supports it in strict mode + sig { + params( + cask: ::Cask::Cask, audit_download: T::Boolean, audit_online: T.nilable(T::Boolean), + audit_strict: T.nilable(T::Boolean), audit_signing: T.nilable(T::Boolean), + audit_token_conflicts: T.nilable(T::Boolean), audit_new_cask: T.nilable(T::Boolean), quarantine: T::Boolean, + any_named_args: T::Boolean, language: T.nilable(String), only: T::Array[String], except: T::Array[String] + ).returns(T::Set[String]) + } + def self.audit( + cask, audit_download: false, audit_online: nil, audit_strict: nil, audit_signing: nil, + audit_token_conflicts: nil, audit_new_cask: nil, quarantine: false, any_named_args: false, language: nil, + only: [], except: [] + ) + new( + cask, audit_download:, audit_online:, audit_strict:, audit_signing:, audit_token_conflicts:, + audit_new_cask:, quarantine:, any_named_args:, language:, only:, except: + ).audit end - attr_reader :cask, :language + sig { returns(::Cask::Cask) } + attr_reader :cask + sig { returns(T.nilable(String)) } + attr_reader :language + + sig { + params( + cask: ::Cask::Cask, audit_download: T::Boolean, audit_online: T.nilable(T::Boolean), + audit_strict: T.nilable(T::Boolean), audit_signing: T.nilable(T::Boolean), + audit_token_conflicts: T.nilable(T::Boolean), audit_new_cask: T.nilable(T::Boolean), quarantine: T::Boolean, + any_named_args: T::Boolean, language: T.nilable(String), only: T::Array[String], except: T::Array[String] + ).void + } def initialize( cask, - audit_download: nil, + audit_download: false, audit_online: nil, audit_strict: nil, audit_signing: nil, audit_token_conflicts: nil, audit_new_cask: nil, - quarantine: nil, - any_named_args: nil, + quarantine: false, + any_named_args: false, language: nil, only: [], except: [] @@ -42,17 +70,18 @@ module Cask LANGUAGE_BLOCK_LIMIT = 10 + sig { returns(T::Set[String]) } def audit errors = Set.new - if !language && language_blocks - sample_languages = if language_blocks.length > LANGUAGE_BLOCK_LIMIT && !@audit_new_cask - sample_keys = language_blocks.keys.sample(LANGUAGE_BLOCK_LIMIT) + if !language && (blocks = language_blocks) + sample_languages = if blocks.length > LANGUAGE_BLOCK_LIMIT && !@audit_new_cask + sample_keys = T.must(blocks.keys.sample(LANGUAGE_BLOCK_LIMIT)) ohai "Auditing a sample of available languages for #{cask}: " \ "#{sample_keys.map { |lang| lang[0].to_s }.to_sentence}" - language_blocks.select { |k| sample_keys.include?(k) } + blocks.select { |k| sample_keys.include?(k) } else - language_blocks + blocks end sample_languages.each_key do |l| @@ -74,14 +103,16 @@ module Cask private + sig { params(audit: T.nilable(Audit)).returns(T::Boolean) } def output_summary?(audit = nil) - return true if @any_named_args.present? - return true if @audit_strict.present? - return false if audit.blank? + return true if @any_named_args + return true if @audit_strict + return false if audit.nil? audit.errors? end + sig { params(languages: T::Array[String]).returns(::Cask::Audit) } def audit_languages(languages) original_config = cask.config localized_config = original_config.merge(Config.new(explicit: { languages: })) @@ -92,6 +123,7 @@ module Cask cask.config = original_config end + sig { params(cask: ::Cask::Cask).returns(::Cask::Audit) } def audit_cask_instance(cask) audit = Audit.new( cask, @@ -108,6 +140,7 @@ module Cask audit.run! end + sig { returns(T.nilable(T::Hash[T::Array[String], T.proc.returns(T.untyped)])) } def language_blocks cask.instance_variable_get(:@dsl).instance_variable_get(:@language_blocks) end diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 0bbe88cc10..2a787593c4 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "bundle_version" require "cask/cask_loader" require "cask/config" @@ -15,7 +14,6 @@ module Cask # An instance of a cask. class Cask extend Forwardable - extend Attrable extend APIHashable include Metadata @@ -32,8 +30,6 @@ module Cask attr_reader :sourcefile_path, :source, :default_config, :loader attr_accessor :download, :allow_reassignment - attr_predicate :loaded_from_api? - def self.all(eval_all: false) if !eval_all && !Homebrew::EnvConfig.eval_all? raise ArgumentError, "Cask::Cask#all cannot be used without `--eval-all` or HOMEBREW_EVAL_ALL" @@ -92,6 +88,9 @@ module Cask end end + sig { returns(T::Boolean) } + def loaded_from_api? = @loaded_from_api + # An old name for the cask. sig { returns(T::Array[String]) } def old_tokens diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 5251af7e62..9946c199e9 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "locale" require "lazy_object" require "livecheck" @@ -105,19 +104,36 @@ module Cask *ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] }, ]).freeze - extend Attrable include OnSystem::MacOSAndLinux attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date, :disable_reason, :disable_replacement, :on_system_block_min_os - attr_predicate :deprecated?, :disabled?, :livecheck_defined?, :on_system_blocks_exist?, :depends_on_set_in_block? - def initialize(cask) @cask = cask + @depends_on_set_in_block = T.let(false, T::Boolean) + @deprecated = T.let(false, T::Boolean) + @disabled = T.let(false, T::Boolean) + @livecheck_defined = T.let(false, T::Boolean) + @on_system_blocks_exist = T.let(false, T::Boolean) @token = cask.token end + sig { returns(T::Boolean) } + def depends_on_set_in_block? = @depends_on_set_in_block + + sig { returns(T::Boolean) } + def deprecated? = @deprecated + + sig { returns(T::Boolean) } + def disabled? = @disabled + + sig { returns(T::Boolean) } + def livecheck_defined? = @livecheck_defined + + sig { returns(T::Boolean) } + def on_system_blocks_exist? = @on_system_blocks_exist + # Specifies the cask's name. # # NOTE: Multiple names can be specified. diff --git a/Library/Homebrew/cask/dsl/caveats.rb b/Library/Homebrew/cask/dsl/caveats.rb index cd27bf0776..9d5d38490a 100644 --- a/Library/Homebrew/cask/dsl/caveats.rb +++ b/Library/Homebrew/cask/dsl/caveats.rb @@ -1,8 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" - module Cask class DSL # Class corresponding to the `caveats` stanza. @@ -15,10 +13,6 @@ module Cask # to the output by the caller, but that feature is only for the # convenience of cask authors. class Caveats < Base - extend Attrable - - attr_predicate :discontinued? - def initialize(*args) super @built_in_caveats = {} @@ -37,6 +31,9 @@ module Cask private_class_method :caveat + sig { returns(T::Boolean) } + def discontinued? = @discontinued + sig { returns(String) } def to_s (@custom_caveats + @built_in_caveats.values).join("\n") diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index e9bbdc497d..188013086f 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "formula_installer" require "unpack_strategy" require "utils/topological_hash" @@ -17,8 +16,15 @@ require "cgi" module Cask # Installer for a {Cask}. class Installer - extend Attrable - + sig { + params( + cask: ::Cask::Cask, command: T::Class[SystemCommand], force: T::Boolean, adopt: T::Boolean, + skip_cask_deps: T::Boolean, binaries: T::Boolean, verbose: T::Boolean, zap: T::Boolean, + require_sha: T::Boolean, upgrade: T::Boolean, reinstall: T::Boolean, installed_as_dependency: T::Boolean, + installed_on_request: T::Boolean, quarantine: T::Boolean, verify_download_integrity: T::Boolean, + quiet: T::Boolean + ).void + } def initialize(cask, command: SystemCommand, force: false, adopt: false, skip_cask_deps: false, binaries: true, verbose: false, zap: false, require_sha: false, upgrade: false, reinstall: false, @@ -42,9 +48,44 @@ module Cask @quiet = quiet end - attr_predicate :binaries?, :force?, :adopt?, :skip_cask_deps?, :require_sha?, - :reinstall?, :upgrade?, :verbose?, :zap?, :installed_as_dependency?, :installed_on_request?, - :quarantine?, :quiet? + sig { returns(T::Boolean) } + def adopt? = @adopt + + sig { returns(T::Boolean) } + def binaries? = @binaries + + sig { returns(T::Boolean) } + def force? = @force + + sig { returns(T::Boolean) } + def installed_as_dependency? = @installed_as_dependency + + sig { returns(T::Boolean) } + def installed_on_request? = @installed_on_request + + sig { returns(T::Boolean) } + def quarantine? = @quarantine + + sig { returns(T::Boolean) } + def quiet? = @quiet + + sig { returns(T::Boolean) } + def reinstall? = @reinstall + + sig { returns(T::Boolean) } + def require_sha? = @require_sha + + sig { returns(T::Boolean) } + def skip_cask_deps? = @skip_cask_deps + + sig { returns(T::Boolean) } + def upgrade? = @upgrade + + sig { returns(T::Boolean) } + def verbose? = @verbose + + sig { returns(T::Boolean) } + def zap? = @zap def self.caveats(cask) odebug "Printing caveats" diff --git a/Library/Homebrew/cask/reinstall.rb b/Library/Homebrew/cask/reinstall.rb index bad643b380..cdd0124606 100644 --- a/Library/Homebrew/cask/reinstall.rb +++ b/Library/Homebrew/cask/reinstall.rb @@ -1,32 +1,32 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Cask class Reinstall + sig { + params( + casks: ::Cask::Cask, verbose: T::Boolean, force: T::Boolean, skip_cask_deps: T::Boolean, binaries: T::Boolean, + require_sha: T::Boolean, quarantine: T::Boolean, zap: T::Boolean + ).void + } def self.reinstall_casks( *casks, - verbose: nil, - force: nil, - skip_cask_deps: nil, - binaries: nil, - require_sha: nil, - quarantine: nil, - zap: nil + verbose: false, + force: false, + skip_cask_deps: false, + binaries: false, + require_sha: false, + quarantine: false, + zap: false ) require "cask/installer" quarantine = true if quarantine.nil? casks.each do |cask| - Installer.new(cask, - binaries:, - verbose:, - force:, - skip_cask_deps:, - require_sha:, - reinstall: true, - quarantine:, - zap:).install + Installer + .new(cask, binaries:, verbose:, force:, skip_cask_deps:, require_sha:, reinstall: true, quarantine:, zap:) + .install end end end diff --git a/Library/Homebrew/cask/staged.rb b/Library/Homebrew/cask/staged.rb index 43d0e8c37c..dbaa50a8f8 100644 --- a/Library/Homebrew/cask/staged.rb +++ b/Library/Homebrew/cask/staged.rb @@ -8,7 +8,7 @@ module Cask module Staged extend T::Helpers - requires_ancestor { Kernel } + requires_ancestor { ::Cask::DSL::Base } Paths = T.type_alias { T.any(String, Pathname, T::Array[T.any(String, Pathname)]) } sig { params(paths: Paths, permissions_str: String).void } diff --git a/Library/Homebrew/cask/uninstall.rb b/Library/Homebrew/cask/uninstall.rb index ebfc74ee27..38f2587e13 100644 --- a/Library/Homebrew/cask/uninstall.rb +++ b/Library/Homebrew/cask/uninstall.rb @@ -1,9 +1,10 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Cask class Uninstall - def self.uninstall_casks(*casks, binaries: nil, force: false, verbose: false) + sig { params(casks: ::Cask::Cask, binaries: T::Boolean, force: T::Boolean, verbose: T::Boolean).void } + def self.uninstall_casks(*casks, binaries: false, force: false, verbose: false) require "cask/installer" casks.each do |cask| diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 68b22eb204..9c20506a87 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -3,7 +3,6 @@ require "utils/bottles" -require "attrable" require "formula" require "cask/cask_loader" @@ -209,11 +208,8 @@ module Homebrew end end - extend Attrable - PERIODIC_CLEAN_FILE = (HOMEBREW_CACHE/".cleaned").freeze - attr_predicate :dry_run?, :scrub?, :prune? attr_reader :args, :days, :cache, :disk_cleanup_size def initialize(*args, dry_run: false, scrub: false, days: nil, cache: HOMEBREW_CACHE) @@ -227,6 +223,15 @@ module Homebrew @cleaned_up_paths = Set.new end + sig { returns(T::Boolean) } + def dry_run? = @dry_run + + sig { returns(T::Boolean) } + def prune? = @prune + + sig { returns(T::Boolean) } + def scrub? = @scrub + def self.install_formula_clean!(formula, dry_run: false) return if Homebrew::EnvConfig.no_install_cleanup? return unless formula.latest_version_installed? diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb index 5679d2ccfb..46956f696b 100644 --- a/Library/Homebrew/debrew.rb +++ b/Library/Homebrew/debrew.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "mutex_m" require "ignorable" @@ -73,9 +72,10 @@ module Debrew @debugged_exceptions = Set.new class << self - extend Attrable - attr_predicate :active? attr_reader :debugged_exceptions + + sig { returns(T::Boolean) } + def active? = @active end def self.debrew diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2f9d3f0b63..24e69cb463 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -261,8 +261,8 @@ module Homebrew audit_token_conflicts: args.token_conflicts? || nil, quarantine: true, any_named_args: !no_named_args, - only: args.only, - except: args.except, + only: args.only || [], + except: args.except || [], ).to_a end end.uniq diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1770c1344b..f8ede28ffe 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1,7 +1,6 @@ # typed: strict # frozen_string_literal: true -require "attrable" require "cache_store" require "did_you_mean" require "formula_support" @@ -79,7 +78,6 @@ class Formula include Homebrew::Livecheck::Constants extend Forwardable extend Cachable - extend Attrable extend APIHashable extend T::Helpers @@ -3288,8 +3286,6 @@ class Formula # The methods below define the formula DSL. class << self - extend Attrable - include BuildEnvironment::DSL include OnSystem::MacOSAndLinux @@ -3307,6 +3303,7 @@ class Formula @skip_clean_paths = T.let(Set.new, T.nilable(T::Set[T.any(String, Symbol)])) @link_overwrite_paths = T.let(Set.new, T.nilable(T::Set[String])) @loaded_from_api = T.let(false, T.nilable(T::Boolean)) + @on_system_blocks_exist = T.let(false, T.nilable(T::Boolean)) @network_access_allowed = T.let(SUPPORTED_NETWORK_ACCESS_PHASES.to_h do |phase| [phase, DEFAULT_NETWORK_ACCESS_ALLOWED] end, T.nilable(T::Hash[Symbol, T::Boolean])) @@ -3327,11 +3324,13 @@ class Formula def network_access_allowed = T.must(@network_access_allowed) # Whether this formula was loaded using the formulae.brew.sh API - attr_predicate :loaded_from_api? + sig { returns(T::Boolean) } + def loaded_from_api? = !!@loaded_from_api # Whether this formula contains OS/arch-specific blocks # (e.g. `on_macos`, `on_arm`, `on_monterey :or_older`, `on_system :linux, macos: :big_sur_or_newer`). - attr_predicate :on_system_blocks_exist? + sig { returns(T::Boolean) } + def on_system_blocks_exist? = !!@on_system_blocks_exist # The reason for why this software is not linked (by default) to {::HOMEBREW_PREFIX}. sig { returns(T.nilable(KegOnlyReason)) } diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 1fab9334b9..e84bea4082 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -29,7 +29,6 @@ require "utils/fork" # Installer for a formula. class FormulaInstaller include FormulaCellarChecks - extend Attrable ETC_VAR_DIRS = T.let([HOMEBREW_PREFIX/"etc", HOMEBREW_PREFIX/"var"].freeze, T::Array[Pathname]) @@ -45,12 +44,6 @@ class FormulaInstaller sig { returns(T::Boolean) } attr_accessor :link_keg - attr_predicate :installed_as_dependency?, :installed_on_request? - attr_predicate :show_summary_heading?, :show_header? - attr_predicate :force_bottle?, :ignore_deps?, :only_deps?, :interactive?, :git?, :force?, :overwrite?, :keep_tmp? - attr_predicate :debug_symbols? - attr_predicate :verbose?, :debug?, :quiet? - sig { params( formula: Formula, @@ -148,6 +141,54 @@ class FormulaInstaller @formula = T.let(T.must(previously_fetched_formula), Formula) if previously_fetched_formula end + sig { returns(T::Boolean) } + def debug? = @debug + + sig { returns(T::Boolean) } + def debug_symbols? = @debug_symbols + + sig { returns(T::Boolean) } + def force? = @force + + sig { returns(T::Boolean) } + def force_bottle? = @force_bottle + + sig { returns(T::Boolean) } + def git? = @git + + sig { returns(T::Boolean) } + def ignore_deps? = @ignore_deps + + sig { returns(T::Boolean) } + def installed_as_dependency? = @installed_as_dependency + + sig { returns(T::Boolean) } + def installed_on_request? = @installed_on_request + + sig { returns(T::Boolean) } + def interactive? = @interactive + + sig { returns(T::Boolean) } + def keep_tmp? = @keep_tmp + + sig { returns(T::Boolean) } + def only_deps? = @only_deps + + sig { returns(T::Boolean) } + def overwrite? = @overwrite + + sig { returns(T::Boolean) } + def quiet? = @quiet + + sig { returns(T::Boolean) } + def show_header? = @show_header + + sig { returns(T::Boolean) } + def show_summary_heading? = @show_summary_heading + + sig { returns(T::Boolean) } + def verbose? = @verbose + sig { returns(T::Set[Formula]) } def self.attempted @attempted ||= T.let(Set.new, T.nilable(T::Set[Formula])) diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index 868d8e0f68..82851e5ad6 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "dependable" require "dependency" require "dependencies" diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index bd5974db22..fdd77a37b7 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "resource" require "download_strategy" require "checksum" diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/audit.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/audit.rbi deleted file mode 100644 index 9f9cb7d83a..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/audit.rbi +++ /dev/null @@ -1,23 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `Cask::Audit`. -# Please instead update this file by running `bin/tapioca dsl Cask::Audit`. - - -class Cask::Audit - sig { returns(T::Boolean) } - def new_cask?; end - - sig { returns(T::Boolean) } - def online?; end - - sig { returns(T::Boolean) } - def signing?; end - - sig { returns(T::Boolean) } - def strict?; end - - sig { returns(T::Boolean) } - def token_conflicts?; end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi index 789d386ab2..2baa754fd0 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi @@ -120,9 +120,6 @@ class Cask::Cask sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) } def livecheckable?(*args, &block); end - sig { returns(T::Boolean) } - def loaded_from_api?; end - sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) } def manpage(*args, &block); end diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi deleted file mode 100644 index 93510e134b..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi +++ /dev/null @@ -1,23 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `Cask::DSL`. -# Please instead update this file by running `bin/tapioca dsl Cask::DSL`. - - -class Cask::DSL - sig { returns(T::Boolean) } - def depends_on_set_in_block?; end - - sig { returns(T::Boolean) } - def deprecated?; end - - sig { returns(T::Boolean) } - def disabled?; end - - sig { returns(T::Boolean) } - def livecheck_defined?; end - - sig { returns(T::Boolean) } - def on_system_blocks_exist?; end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl/caveats.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl/caveats.rbi index 8a9839ac27..394dbec9d5 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl/caveats.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl/caveats.rbi @@ -5,7 +5,4 @@ # Please instead update this file by running `bin/tapioca dsl Cask::DSL::Caveats`. -class Cask::DSL::Caveats - sig { returns(T::Boolean) } - def discontinued?; end -end +class Cask::DSL::Caveats; end diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/installer.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/installer.rbi deleted file mode 100644 index 6fafb97179..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/installer.rbi +++ /dev/null @@ -1,47 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `Cask::Installer`. -# Please instead update this file by running `bin/tapioca dsl Cask::Installer`. - - -class Cask::Installer - sig { returns(T::Boolean) } - def adopt?; end - - sig { returns(T::Boolean) } - def binaries?; end - - sig { returns(T::Boolean) } - def force?; end - - sig { returns(T::Boolean) } - def installed_as_dependency?; end - - sig { returns(T::Boolean) } - def installed_on_request?; end - - sig { returns(T::Boolean) } - def quarantine?; end - - sig { returns(T::Boolean) } - def quiet?; end - - sig { returns(T::Boolean) } - def reinstall?; end - - sig { returns(T::Boolean) } - def require_sha?; end - - sig { returns(T::Boolean) } - def skip_cask_deps?; end - - sig { returns(T::Boolean) } - def upgrade?; end - - sig { returns(T::Boolean) } - def verbose?; end - - sig { returns(T::Boolean) } - def zap?; end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/debrew.rbi b/Library/Homebrew/sorbet/rbi/dsl/debrew.rbi deleted file mode 100644 index 89b6cf7412..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/debrew.rbi +++ /dev/null @@ -1,13 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `Debrew`. -# Please instead update this file by running `bin/tapioca dsl Debrew`. - - -module Debrew - class << self - sig { returns(T::Boolean) } - def active?; end - end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/formula.rbi b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi index c21f24179a..8e7c2d0290 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/formula.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi @@ -140,12 +140,4 @@ class Formula sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) } def version(*args, &block); end - - class << self - sig { returns(T::Boolean) } - def loaded_from_api?; end - - sig { returns(T::Boolean) } - def on_system_blocks_exist?; end - end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/formula_installer.rbi b/Library/Homebrew/sorbet/rbi/dsl/formula_installer.rbi deleted file mode 100644 index e6cdede310..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/formula_installer.rbi +++ /dev/null @@ -1,56 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `FormulaInstaller`. -# Please instead update this file by running `bin/tapioca dsl FormulaInstaller`. - - -class FormulaInstaller - sig { returns(T::Boolean) } - def debug?; end - - sig { returns(T::Boolean) } - def debug_symbols?; end - - sig { returns(T::Boolean) } - def force?; end - - sig { returns(T::Boolean) } - def force_bottle?; end - - sig { returns(T::Boolean) } - def git?; end - - sig { returns(T::Boolean) } - def ignore_deps?; end - - sig { returns(T::Boolean) } - def installed_as_dependency?; end - - sig { returns(T::Boolean) } - def installed_on_request?; end - - sig { returns(T::Boolean) } - def interactive?; end - - sig { returns(T::Boolean) } - def keep_tmp?; end - - sig { returns(T::Boolean) } - def only_deps?; end - - sig { returns(T::Boolean) } - def overwrite?; end - - sig { returns(T::Boolean) } - def quiet?; end - - sig { returns(T::Boolean) } - def show_header?; end - - sig { returns(T::Boolean) } - def show_summary_heading?; end - - sig { returns(T::Boolean) } - def verbose?; end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cleanup.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cleanup.rbi deleted file mode 100644 index 852b2b5cc7..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cleanup.rbi +++ /dev/null @@ -1,17 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `Homebrew::Cleanup`. -# Please instead update this file by running `bin/tapioca dsl Homebrew::Cleanup`. - - -class Homebrew::Cleanup - sig { returns(T::Boolean) } - def dry_run?; end - - sig { returns(T::Boolean) } - def prune?; end - - sig { returns(T::Boolean) } - def scrub?; end -end diff --git a/Library/Homebrew/sorbet/rbi/dsl/system_command.rbi b/Library/Homebrew/sorbet/rbi/dsl/system_command.rbi deleted file mode 100644 index e2e8a6a2aa..0000000000 --- a/Library/Homebrew/sorbet/rbi/dsl/system_command.rbi +++ /dev/null @@ -1,20 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for dynamic methods in `SystemCommand`. -# Please instead update this file by running `bin/tapioca dsl SystemCommand`. - - -class SystemCommand - sig { returns(T::Boolean) } - def must_succeed?; end - - sig { returns(T::Boolean) } - def reset_uid?; end - - sig { returns(T::Boolean) } - def sudo?; end - - sig { returns(T::Boolean) } - def sudo_as_root?; end -end diff --git a/Library/Homebrew/sorbet/tapioca/compilers/attrables.rb b/Library/Homebrew/sorbet/tapioca/compilers/attrables.rb deleted file mode 100644 index d4400d198c..0000000000 --- a/Library/Homebrew/sorbet/tapioca/compilers/attrables.rb +++ /dev/null @@ -1,42 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -require_relative "../../../global" -require "sorbet/tapioca/utils" -require "debrew" - -module Tapioca - module Compilers - class Attrables < Tapioca::Dsl::Compiler - ATTRABLE_FILENAME = "attrable.rb" - ConstantType = type_member { { fixed: Module } } - - sig { override.returns(T::Enumerable[Module]) } - def self.gather_constants = Homebrew::Tapioca::Utils.named_objects_with_module(Attrable) - - sig { override.void } - def decorate - root.create_path(constant) do |klass| - Homebrew::Tapioca::Utils.methods_from_file(constant, ATTRABLE_FILENAME) - .each { |method| compile_attrable_method(klass, method) } - Homebrew::Tapioca::Utils.methods_from_file(constant, ATTRABLE_FILENAME, class_methods: true) - .each { |method| compile_attrable_method(klass, method, class_method: true) } - end - end - - private - - sig { params(klass: RBI::Scope, method: T.any(Method, UnboundMethod), class_method: T::Boolean).void } - def compile_attrable_method(klass, method, class_method: false) - raise "Unsupported arity for method #{method.name} - did `Attrable` change?" unless method.arity.zero? - - # attr_predicate - klass.create_method( - method.name.to_s, - return_type: "T::Boolean", - class_method:, - ) - end - end - end -end diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index 94601fb4da..737eea4322 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -1,7 +1,6 @@ # typed: true # rubocop:todo Sorbet/StrictSigil # frozen_string_literal: true -require "attrable" require "plist" require "shellwords" require "uri" @@ -34,7 +33,6 @@ class SystemCommand end include Context - extend Attrable def self.run(executable, **options) new(executable, **options).run! @@ -154,7 +152,17 @@ class SystemCommand attr_reader :executable, :args, :input, :chdir, :env - attr_predicate :sudo?, :sudo_as_root?, :must_succeed?, :reset_uid? + sig { returns(T::Boolean) } + def must_succeed? = @must_succeed + + sig { returns(T::Boolean) } + def reset_uid? = @reset_uid + + sig { returns(T::Boolean) } + def sudo? = @sudo + + sig { returns(T::Boolean) } + def sudo_as_root? = @sudo_as_root sig { returns(T::Boolean) } def debug?