Turn up the types
This commit is contained in:
parent
2cfea600d4
commit
d01cda2815
@ -1,9 +1,9 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "macos_version"
|
require "macos_version"
|
||||||
|
|
||||||
FORMULA_COMPONENT_PRECEDENCE_LIST = [
|
FORMULA_COMPONENT_PRECEDENCE_LIST = T.let([
|
||||||
[{ name: :include, type: :method_call }],
|
[{ name: :include, type: :method_call }],
|
||||||
[{ name: :desc, type: :method_call }],
|
[{ name: :desc, type: :method_call }],
|
||||||
[{ name: :homepage, type: :method_call }],
|
[{ name: :homepage, type: :method_call }],
|
||||||
@ -49,4 +49,4 @@ FORMULA_COMPONENT_PRECEDENCE_LIST = [
|
|||||||
[{ name: :caveats, type: :method_definition }],
|
[{ name: :caveats, type: :method_definition }],
|
||||||
[{ name: :plist_options, type: :method_call }, { name: :plist, type: :method_definition }],
|
[{ name: :plist_options, type: :method_call }, { name: :plist, type: :method_definition }],
|
||||||
[{ name: :test, type: :block_call }],
|
[{ name: :test, type: :block_call }],
|
||||||
].freeze
|
].freeze, T::Array[[{ name: Symbol, type: Symbol }]])
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
@ -8,7 +8,7 @@ module Cask
|
|||||||
module Cache
|
module Cache
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def self.path
|
def self.path
|
||||||
@path ||= HOMEBREW_CACHE/"Cask"
|
@path ||= T.let(HOMEBREW_CACHE/"Cask", T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "fetch"
|
require "fetch"
|
||||||
@ -59,7 +59,7 @@ module Homebrew
|
|||||||
formulae_or_casks.each do |formula_or_cask|
|
formulae_or_casks.each do |formula_or_cask|
|
||||||
case formula_or_cask
|
case formula_or_cask
|
||||||
when Formula
|
when Formula
|
||||||
formula = T.cast(formula_or_cask, Formula)
|
formula = formula_or_cask
|
||||||
ref = formula.loaded_from_api? ? formula.full_name : formula.path
|
ref = formula.loaded_from_api? ? formula.full_name : formula.path
|
||||||
|
|
||||||
os_arch_combinations.each do |os, arch|
|
os_arch_combinations.each do |os, arch|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -19,6 +19,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def __repository
|
def __repository
|
||||||
args = __repository_args.parse
|
args = __repository_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -24,6 +24,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def analytics
|
def analytics
|
||||||
args = analytics_args.parse
|
args = analytics_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cleanup"
|
require "cleanup"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
sig { returns(CLI::Parser) }
|
||||||
|
def self.autoremove_args
|
||||||
def autoremove_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
|
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
|
||||||
@ -19,7 +18,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoremove
|
sig { void }
|
||||||
|
def self.autoremove
|
||||||
args = autoremove_args.parse
|
args = autoremove_args.parse
|
||||||
|
|
||||||
Cleanup.autoremove(dry_run: args.dry_run?)
|
Cleanup.autoremove(dry_run: args.dry_run?)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cleanup"
|
require "cleanup"
|
||||||
@ -33,6 +33,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def cleanup
|
def cleanup
|
||||||
args = cleanup_args.parse
|
args = cleanup_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -22,6 +22,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def commands
|
def commands
|
||||||
args = commands_args.parse
|
args = commands_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -25,6 +25,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def completions
|
def completions
|
||||||
args = completions_args.parse
|
args = completions_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "system_config"
|
require "system_config"
|
||||||
@ -19,6 +19,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def config
|
def config
|
||||||
config_args.parse
|
config_args.parse
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "help"
|
require "help"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
sig { returns(T.noreturn) }
|
||||||
def help
|
def help
|
||||||
Help.help
|
Help.help
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
DEFAULT_PREFIX = ENV.fetch("HOMEBREW_DEFAULT_PREFIX").freeze
|
DEFAULT_PREFIX = T.let(ENV.fetch("HOMEBREW_DEFAULT_PREFIX").freeze, String)
|
||||||
DEFAULT_REPOSITORY = ENV.fetch("HOMEBREW_DEFAULT_REPOSITORY").freeze
|
DEFAULT_REPOSITORY = T.let(ENV.fetch("HOMEBREW_DEFAULT_REPOSITORY").freeze, String)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Cachable
|
module Cachable
|
||||||
|
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
||||||
def cache
|
def cache
|
||||||
@cache ||= {}
|
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def clear_cache
|
def clear_cache
|
||||||
cache.clear
|
cache.clear
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
if OS.mac?
|
if OS.mac?
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
class << self
|
class << self
|
||||||
alias generic_git_tags git_tags
|
alias generic_git_tags git_tags
|
||||||
|
|
||||||
|
sig { returns(String) }
|
||||||
def git_tags
|
def git_tags
|
||||||
tags = generic_git_tags
|
tags = generic_git_tags
|
||||||
tags = Utils.popen_read("git tag --list | sort -rV") if tags.blank?
|
tags = Utils.popen_read("git tag --list | sort -rV") if tags.blank?
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "extend/os/linux/parser" if OS.linux?
|
require "extend/os/linux/parser" if OS.linux?
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Predicable
|
module Predicable
|
||||||
|
sig { params(attrs: Symbol).void }
|
||||||
def attr_predicate(*attrs)
|
def attr_predicate(*attrs)
|
||||||
attrs.each do |attr|
|
attrs.each do |attr|
|
||||||
define_method attr do
|
define_method attr do
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "socket"
|
require "socket"
|
||||||
@ -10,6 +10,7 @@ module Homebrew
|
|||||||
module FreePort
|
module FreePort
|
||||||
# Returns a free port.
|
# Returns a free port.
|
||||||
# @api public
|
# @api public
|
||||||
|
sig { returns(Integer) }
|
||||||
def free_port
|
def free_port
|
||||||
server = TCPServer.new 0
|
server = TCPServer.new 0
|
||||||
_, port, = server.addr
|
_, port, = server.addr
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
|||||||
@ -1,17 +1,20 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Match taps' formulae, e.g. `someuser/sometap/someformula`
|
# Match taps' formulae, e.g. `someuser/sometap/someformula`
|
||||||
HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze
|
HOMEBREW_TAP_FORMULA_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze, Regexp)
|
||||||
# Match taps' casks, e.g. `someuser/sometap/somecask`
|
# Match taps' casks, e.g. `someuser/sometap/somecask`
|
||||||
HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-_]+)$}.freeze
|
HOMEBREW_TAP_CASK_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([a-z0-9\-_]+)$}.freeze, Regexp)
|
||||||
# Match main cask taps' casks, e.g. `homebrew/cask/somecask` or `somecask`
|
# Match main cask taps' casks, e.g. `homebrew/cask/somecask` or `somecask`
|
||||||
HOMEBREW_MAIN_TAP_CASK_REGEX = %r{^([Hh]omebrew/(?:homebrew-)?cask/)?[a-z0-9\-_]+$}.freeze
|
HOMEBREW_MAIN_TAP_CASK_REGEX = T.let(%r{^([Hh]omebrew/(?:homebrew-)?cask/)?[a-z0-9\-_]+$}.freeze, Regexp)
|
||||||
# Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap`
|
# Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap`
|
||||||
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze
|
HOMEBREW_TAP_DIR_REGEX = T.let(
|
||||||
|
%r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze, Regexp
|
||||||
|
)
|
||||||
# Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula`
|
# Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula`
|
||||||
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze
|
HOMEBREW_TAP_PATH_REGEX = T.let(Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze, Regexp)
|
||||||
# Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask`
|
# Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask`
|
||||||
HOMEBREW_CASK_TAP_CASK_REGEX =
|
HOMEBREW_CASK_TAP_CASK_REGEX =
|
||||||
%r{^(?:([Cc]askroom)/(cask|versions)|([Hh]omebrew)/(?:homebrew-)?(cask|cask-[\w-]+))/([\w+-.]+)$}.freeze
|
T.let(%r{^(?:([Cc]askroom)/(cask|versions)|([Hh]omebrew)/(?:homebrew-)?(cask|cask-[\w-]+))/([\w+-.]+)$}.freeze,
|
||||||
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = /^(home|linux)brew-/.freeze
|
Regexp)
|
||||||
|
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = T.let(/^(home|linux)brew-/.freeze, Regexp)
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
# For testing's sake always assume the default prefix
|
# For testing's sake always assume the default prefix
|
||||||
DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze
|
DEFAULT_PREFIX = T.let(HOMEBREW_PREFIX.to_s.freeze, String)
|
||||||
DEFAULT_REPOSITORY = HOMEBREW_REPOSITORY.to_s.freeze
|
DEFAULT_REPOSITORY = T.let(HOMEBREW_REPOSITORY.to_s.freeze, String)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/repology"
|
require "utils/repology"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "../standalone"
|
require_relative "../standalone"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user