mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Enable types in extensions, etc.
This commit is contained in:
parent
931327df1f
commit
6397229f68
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
@ -60,10 +60,10 @@ module Homebrew
|
||||
|
||||
odie "No #{name} #{pg_version_data}.* version installed!" unless old_bin
|
||||
|
||||
server_stopped = false
|
||||
moved_data = false
|
||||
initdb_run = false
|
||||
upgraded = false
|
||||
server_stopped = T.let(false, T::Boolean)
|
||||
moved_data = T.let(false, T::Boolean)
|
||||
initdb_run = T.let(false, T::Boolean)
|
||||
upgraded = T.let(false, T::Boolean)
|
||||
|
||||
begin
|
||||
# Following instructions from:
|
||||
@ -88,7 +88,7 @@ module Homebrew
|
||||
system "#{old_bin}/pg_ctl", "-w", "-D", datadir, "start"
|
||||
end
|
||||
|
||||
initdb_args = []
|
||||
initdb_args = T.let([], T::Array[String])
|
||||
locale_settings = %w[
|
||||
lc_collate
|
||||
lc_ctype
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "delegate"
|
||||
@ -16,19 +16,19 @@ class Dependencies < SimpleDelegator
|
||||
alias eql? ==
|
||||
|
||||
def optional
|
||||
select(&:optional?)
|
||||
__getobj__.select(&:optional?)
|
||||
end
|
||||
|
||||
def recommended
|
||||
select(&:recommended?)
|
||||
__getobj__.select(&:recommended?)
|
||||
end
|
||||
|
||||
def build
|
||||
select(&:build?)
|
||||
__getobj__.select(&:build?)
|
||||
end
|
||||
|
||||
def required
|
||||
select(&:required?)
|
||||
__getobj__.select(&:required?)
|
||||
end
|
||||
|
||||
def default
|
||||
@ -37,7 +37,7 @@ class Dependencies < SimpleDelegator
|
||||
|
||||
sig { returns(String) }
|
||||
def inspect
|
||||
"#<#{self.class.name}: #{to_a}>"
|
||||
"#<#{self.class.name}: #{__getobj__}>"
|
||||
end
|
||||
end
|
||||
|
||||
@ -52,11 +52,11 @@ class Requirements < SimpleDelegator
|
||||
end
|
||||
|
||||
def <<(other)
|
||||
if other.is_a?(Comparable)
|
||||
grep(other.class) do |req|
|
||||
if other.is_a?(Object) && other.is_a?(Comparable)
|
||||
__getobj__.grep(other.class) do |req|
|
||||
return self if req > other
|
||||
|
||||
delete(req)
|
||||
__getobj__.delete(req)
|
||||
end
|
||||
end
|
||||
super
|
||||
@ -65,6 +65,6 @@ class Requirements < SimpleDelegator
|
||||
|
||||
sig { returns(String) }
|
||||
def inspect
|
||||
"#<#{self.class.name}: {#{to_a.join(", ")}}>"
|
||||
"#<#{self.class.name}: {#{__getobj__.to_a.join(", ")}}>"
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
class Dependencies < SimpleDelegator
|
||||
include Kernel
|
||||
# This is a workaround to enable `alias eql? ==`
|
||||
# @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238
|
||||
sig { params(arg0: BasicObject).returns(T::Boolean) }
|
||||
def ==(arg0); end
|
||||
end
|
||||
|
||||
class Requirements < SimpleDelegator
|
||||
|
6
Library/Homebrew/extend/object.rbi
Normal file
6
Library/Homebrew/extend/object.rbi
Normal file
@ -0,0 +1,6 @@
|
||||
# typed: strict
|
||||
|
||||
class Object
|
||||
sig { returns(T::Boolean) }
|
||||
def present?; end
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "macho"
|
||||
@ -114,7 +114,7 @@ module Hardware
|
||||
end
|
||||
end
|
||||
|
||||
def intel_family
|
||||
def intel_family(_family = nil, _cpu_model = nil)
|
||||
case sysctl_int("hw.cpufamily")
|
||||
when 0x73d67300 # Yonah: Core Solo/Duo
|
||||
:core
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Keg
|
||||
@ -108,7 +108,7 @@ class Keg
|
||||
# Needed to make symlink permissions consistent on macOS and Linux for
|
||||
# reproducible bottles.
|
||||
def consistent_reproducible_symlink_permissions!
|
||||
find do |file|
|
||||
path.find do |file|
|
||||
File.lchmod 0777, file if file.symlink?
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Predicable
|
||||
|
5
Library/Homebrew/extend/predicable.rbi
Normal file
5
Library/Homebrew/extend/predicable.rbi
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
|
||||
module Predicable
|
||||
requires_ancestor { Class }
|
||||
end
|
@ -1,16 +1,17 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module TimeRemaining
|
||||
refine Time do
|
||||
def remaining
|
||||
T.bind(self, Time)
|
||||
[0, self - Time.now].max
|
||||
end
|
||||
|
||||
def remaining!
|
||||
r = remaining
|
||||
|
||||
raise Timeout::Error if r <= 0
|
||||
Kernel.raise Timeout::Error if r <= 0
|
||||
|
||||
r
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
@ -161,7 +161,7 @@ module Homebrew
|
||||
# specifies the strategy and contains a `strategy` block
|
||||
next if (livecheck_strategy != strategy_symbol) || !block_provided
|
||||
elsif strategy.const_defined?(:PRIORITY) &&
|
||||
!strategy::PRIORITY.positive? &&
|
||||
!strategy.const_get(:PRIORITY).positive? &&
|
||||
livecheck_strategy != strategy_symbol
|
||||
# Ignore strategies with a priority of 0 or lower, unless the
|
||||
# strategy is specified in the `livecheck` block
|
||||
@ -174,7 +174,7 @@ module Homebrew
|
||||
# Sort usable strategies in descending order by priority, using the
|
||||
# DEFAULT_PRIORITY when a strategy doesn't contain a PRIORITY constant
|
||||
usable_strategies.sort_by do |strategy|
|
||||
(strategy.const_defined?(:PRIORITY) ? -strategy::PRIORITY : -DEFAULT_PRIORITY)
|
||||
(strategy.const_defined?(:PRIORITY) ? -strategy.const_get(:PRIORITY) : -DEFAULT_PRIORITY)
|
||||
end
|
||||
end
|
||||
|
||||
@ -216,7 +216,7 @@ module Homebrew
|
||||
# @return [Hash]
|
||||
sig { params(url: String, homebrew_curl: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
||||
def self.page_content(url, homebrew_curl: false)
|
||||
stderr = nil
|
||||
stderr = T.let(nil, T.nilable(String))
|
||||
[:default, :browser].each do |user_agent|
|
||||
stdout, stderr, status = curl_with_workarounds(
|
||||
*PAGE_CONTENT_CURL_ARGS, url,
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Helper functions for updating PyPI resources.
|
||||
@ -7,8 +7,6 @@
|
||||
module PyPI
|
||||
extend T::Sig
|
||||
|
||||
module_function
|
||||
|
||||
PYTHONHOSTED_URL_PREFIX = "https://files.pythonhosted.org/packages/"
|
||||
private_constant :PYTHONHOSTED_URL_PREFIX
|
||||
|
||||
@ -35,13 +33,16 @@ module PyPI
|
||||
return
|
||||
end
|
||||
|
||||
@name = package_string
|
||||
@name, @version = @name.split("==") if @name.include? "=="
|
||||
if package_string.include? "=="
|
||||
@name, @version = package_string.split("==")
|
||||
else
|
||||
@name = package_string
|
||||
end
|
||||
|
||||
return unless (match = @name.match(/^(.*?)\[(.+)\]$/))
|
||||
return unless (match = T.must(@name).match(/^(.*?)\[(.+)\]$/))
|
||||
|
||||
@name = match[1]
|
||||
@extras = match[2].split ","
|
||||
@extras = T.must(match[2]).split ","
|
||||
end
|
||||
|
||||
# Get name, URL, SHA-256 checksum, and latest version for a given PyPI package.
|
||||
@ -87,7 +88,7 @@ module PyPI
|
||||
|
||||
sig { params(other: Package).returns(T::Boolean) }
|
||||
def same_package?(other)
|
||||
@name.tr("_", "-").casecmp(other.name.tr("_", "-")).zero?
|
||||
T.must(@name.tr("_", "-").casecmp(other.name.tr("_", "-"))).zero?
|
||||
end
|
||||
|
||||
# Compare only names so we can use .include? and .uniq on a Package array
|
||||
@ -109,7 +110,7 @@ module PyPI
|
||||
end
|
||||
|
||||
sig { params(url: String, version: T.any(String, Version)).returns(T.nilable(String)) }
|
||||
def update_pypi_url(url, version)
|
||||
def self.update_pypi_url(url, version)
|
||||
package = Package.new url, is_url: true
|
||||
|
||||
return unless package.valid_pypi_package?
|
||||
@ -133,8 +134,9 @@ module PyPI
|
||||
ignore_non_pypi_packages: T.nilable(T::Boolean),
|
||||
).returns(T.nilable(T::Boolean))
|
||||
}
|
||||
def update_python_resources!(formula, version: nil, package_name: nil, extra_packages: nil, exclude_packages: nil,
|
||||
print_only: false, silent: false, ignore_non_pypi_packages: false)
|
||||
def self.update_python_resources!(formula, version: nil, package_name: nil, extra_packages: nil,
|
||||
exclude_packages: nil, print_only: false, silent: false,
|
||||
ignore_non_pypi_packages: false)
|
||||
|
||||
auto_update_list = formula.tap&.pypi_formula_mappings
|
||||
if auto_update_list.present? && auto_update_list.key?(formula.full_name) &&
|
||||
@ -282,7 +284,7 @@ module PyPI
|
||||
true
|
||||
end
|
||||
|
||||
def json_to_packages(json_tree, main_package, exclude_packages)
|
||||
def self.json_to_packages(json_tree, main_package, exclude_packages)
|
||||
return [] if json_tree.blank?
|
||||
|
||||
json_tree.flat_map do |package_json|
|
||||
|
Loading…
x
Reference in New Issue
Block a user