mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Enable typing in misc files
This commit is contained in:
parent
3a02894d0b
commit
d98b7845d3
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
require "timeout"
|
require "timeout"
|
||||||
|
|
||||||
require "utils/splat"
|
|
||||||
require "utils/user"
|
require "utils/user"
|
||||||
require "cask/artifact/abstract_artifact"
|
require "cask/artifact/abstract_artifact"
|
||||||
require "cask/pkg"
|
require "cask/pkg"
|
||||||
@ -262,7 +261,7 @@ module Cask
|
|||||||
# learned the pid from AppleScript is already some degree of protection,
|
# learned the pid from AppleScript is already some degree of protection,
|
||||||
# though indirect.
|
# though indirect.
|
||||||
odebug "Unix ids are #{pids.inspect} for processes with bundle identifier #{bundle_id}"
|
odebug "Unix ids are #{pids.inspect} for processes with bundle identifier #{bundle_id}"
|
||||||
::Utils::Splat.process_kill(signal, pids)
|
Process.kill(signal, *pids)
|
||||||
sleep 3
|
sleep 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
@ -149,7 +149,8 @@ module Homebrew
|
|||||||
if want_keg_like_cask
|
if want_keg_like_cask
|
||||||
cask_version = Cask::Cask.new(name, config: config).versions.first
|
cask_version = Cask::Cask.new(name, config: config).versions.first
|
||||||
cask = Cask::Cask.new(name, config: config) do
|
cask = Cask::Cask.new(name, config: config) do
|
||||||
version cask_version if cask_version
|
# This block is dynamically evaluated in `Cask::Cask#refresh`, so sorbet cannot typecheck it.
|
||||||
|
T.unsafe(self).version cask_version if cask_version
|
||||||
end
|
end
|
||||||
return cask
|
return cask
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "env_config"
|
require "env_config"
|
||||||
@ -122,7 +122,9 @@ module Homebrew
|
|||||||
@args = Homebrew::CLI::Args.new
|
@args = Homebrew::CLI::Args.new
|
||||||
|
|
||||||
# Filter out Sorbet runtime type checking method calls.
|
# Filter out Sorbet runtime type checking method calls.
|
||||||
cmd_location = caller_locations.select { |location| location.path.exclude?("/gems/sorbet-runtime-") }.second
|
cmd_location = T.must(caller_locations).select do |location|
|
||||||
|
T.must(location.path).exclude?("/gems/sorbet-runtime-")
|
||||||
|
end.second
|
||||||
@command_name = cmd_location.label.chomp("_args").tr("_", "-")
|
@command_name = cmd_location.label.chomp("_args").tr("_", "-")
|
||||||
@is_dev_cmd = cmd_location.absolute_path.start_with?(Commands::HOMEBREW_DEV_CMD_PATH)
|
@is_dev_cmd = cmd_location.absolute_path.start_with?(Commands::HOMEBREW_DEV_CMD_PATH)
|
||||||
|
|
||||||
@ -386,7 +388,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
type: T.any(Symbol, T::Array[String], T::Array[Symbol]),
|
type: T.any(NilClass, Symbol, T::Array[String], T::Array[Symbol]),
|
||||||
number: T.nilable(Integer),
|
number: T.nilable(Integer),
|
||||||
min: T.nilable(Integer),
|
min: T.nilable(Integer),
|
||||||
max: T.nilable(Integer),
|
max: T.nilable(Integer),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Contains shorthand Homebrew utility methods like `ohai`, `opoo`, `odisabled`.
|
# Contains shorthand Homebrew utility methods like `ohai`, `opoo`, `odisabled`.
|
||||||
@ -18,7 +18,7 @@ module Kernel
|
|||||||
|
|
||||||
def ohai_title(title)
|
def ohai_title(title)
|
||||||
verbose = if respond_to?(:verbose?)
|
verbose = if respond_to?(:verbose?)
|
||||||
verbose?
|
T.unsafe(self).verbose?
|
||||||
else
|
else
|
||||||
Context.current.verbose?
|
Context.current.verbose?
|
||||||
end
|
end
|
||||||
@ -34,7 +34,7 @@ module Kernel
|
|||||||
|
|
||||||
def odebug(title, *sput, always_display: false)
|
def odebug(title, *sput, always_display: false)
|
||||||
debug = if respond_to?(:debug)
|
debug = if respond_to?(:debug)
|
||||||
debug?
|
T.unsafe(self).debug?
|
||||||
else
|
else
|
||||||
Context.current.debug?
|
Context.current.debug?
|
||||||
end
|
end
|
||||||
@ -47,7 +47,7 @@ module Kernel
|
|||||||
|
|
||||||
def oh1_title(title, truncate: :auto)
|
def oh1_title(title, truncate: :auto)
|
||||||
verbose = if respond_to?(:verbose?)
|
verbose = if respond_to?(:verbose?)
|
||||||
verbose?
|
T.unsafe(self).verbose?
|
||||||
else
|
else
|
||||||
Context.current.verbose?
|
Context.current.verbose?
|
||||||
end
|
end
|
||||||
@ -361,7 +361,7 @@ module Kernel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nostdout(&block)
|
def nostdout(&block)
|
||||||
if verbose?
|
if T.unsafe(self).verbose?
|
||||||
yield
|
yield
|
||||||
else
|
else
|
||||||
redirect_stdout(File::NULL, &block)
|
redirect_stdout(File::NULL, &block)
|
||||||
@ -436,7 +436,11 @@ module Kernel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_author!(author)
|
def parse_author!(author)
|
||||||
/^(?<name>[^<]+?)[ \t]*<(?<email>[^>]+?)>$/ =~ author
|
match_data = /^(?<name>[^<]+?)[ \t]*<(?<email>[^>]+?)>$/.match(author)
|
||||||
|
if match_data
|
||||||
|
name = match_data[:name]
|
||||||
|
email = match_data[:email]
|
||||||
|
end
|
||||||
raise UsageError, "Unable to parse name and email." if name.blank? && email.blank?
|
raise UsageError, "Unable to parse name and email." if name.blank? && email.blank?
|
||||||
|
|
||||||
{ name: name, email: email }
|
{ name: name, email: email }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "time"
|
require "time"
|
||||||
@ -24,6 +24,7 @@ require "extend/kernel"
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend Context
|
extend Context
|
||||||
|
extend T::Sig
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Style/GlobalVars
|
# rubocop:disable Style/GlobalVars
|
||||||
|
sig { params(the_module: Module, pattern: Regexp).void }
|
||||||
def inject_dump_stats!(the_module, pattern)
|
def inject_dump_stats!(the_module, pattern)
|
||||||
@injected_dump_stat_modules ||= {}
|
@injected_dump_stat_modules ||= {}
|
||||||
@injected_dump_stat_modules[the_module] ||= []
|
@injected_dump_stat_modules[the_module] ||= []
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
# typed: false
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Utils
|
|
||||||
# Wrappers for Ruby core methods that accept splat arguments. This file is `typed: false` by design, but allows
|
|
||||||
# other files to enable typing while making use of the wrapped methods.
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
module Splat
|
|
||||||
extend T::Sig
|
|
||||||
|
|
||||||
# Wrapper around `Process.kill` that accepts an array of pids.
|
|
||||||
# @see https://ruby-doc.org/3.2.1/Process.html#method-c-kill Process.kill
|
|
||||||
# @see https://github.com/sorbet/sorbet/blob/eaebdcd/rbi/core/process.rbi#L793-L800 Sorbet RBI for `Process.kill`
|
|
||||||
sig { params(signal: T.any(Integer, Symbol, String), pids: T::Array[Integer]).returns(Integer) }
|
|
||||||
def self.process_kill(signal, pids)
|
|
||||||
Process.kill(signal, *pids)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user