Fix type error in Readall
This commit is contained in:
parent
4d14be89e9
commit
c738d5c007
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "simulate_system"
|
require "simulate_system"
|
||||||
@ -6,15 +6,15 @@ require "simulate_system"
|
|||||||
module OnSystem
|
module OnSystem
|
||||||
ARCH_OPTIONS = [:intel, :arm].freeze
|
ARCH_OPTIONS = [:intel, :arm].freeze
|
||||||
BASE_OS_OPTIONS = [:macos, :linux].freeze
|
BASE_OS_OPTIONS = [:macos, :linux].freeze
|
||||||
ALL_OS_OPTIONS = [*MacOSVersion::SYMBOLS.keys, :linux].freeze
|
ALL_OS_OPTIONS = T.let([*MacOSVersion::SYMBOLS.keys, :linux].freeze, T::Array[Symbol])
|
||||||
ALL_OS_ARCH_COMBINATIONS = ALL_OS_OPTIONS.product(ARCH_OPTIONS).freeze
|
ALL_OS_ARCH_COMBINATIONS = T.let(ALL_OS_OPTIONS.product(ARCH_OPTIONS).freeze, T::Array[[Symbol, Symbol]])
|
||||||
|
|
||||||
VALID_OS_ARCH_TAGS = ALL_OS_ARCH_COMBINATIONS.filter_map do |os, arch|
|
VALID_OS_ARCH_TAGS = T.let(ALL_OS_ARCH_COMBINATIONS.filter_map do |os, arch|
|
||||||
tag = Utils::Bottles::Tag.new(system: os, arch:)
|
tag = Utils::Bottles::Tag.new(system: os, arch:)
|
||||||
next unless tag.valid_combination?
|
next unless tag.valid_combination?
|
||||||
|
|
||||||
tag
|
tag
|
||||||
end.freeze
|
end.freeze, T::Array[Utils::Bottles::Tag])
|
||||||
|
|
||||||
sig { params(arch: Symbol).returns(T::Boolean) }
|
sig { params(arch: Symbol).returns(T::Boolean) }
|
||||||
def self.arch_condition_met?(arch)
|
def self.arch_condition_met?(arch)
|
||||||
@ -55,11 +55,11 @@ module OnSystem
|
|||||||
method_name.to_s.sub(/^on_/, "").to_sym
|
method_name.to_s.sub(/^on_/, "").to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: T::Class[T.anything]).void }
|
||||||
def self.setup_arch_methods(base)
|
def self.setup_arch_methods(base)
|
||||||
ARCH_OPTIONS.each do |arch|
|
ARCH_OPTIONS.each do |arch|
|
||||||
base.define_method(:"on_#{arch}") do |&block|
|
base.define_method(:"on_#{arch}") do |&block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
base.define_method(:on_arch_conditional) do |arm: nil, intel: nil|
|
base.define_method(:on_arch_conditional) do |arm: nil, intel: nil|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
if OnSystem.arch_condition_met? :arm
|
if OnSystem.arch_condition_met? :arm
|
||||||
arm
|
arm
|
||||||
@ -82,11 +82,11 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: T::Class[T.anything]).void }
|
||||||
def self.setup_base_os_methods(base)
|
def self.setup_base_os_methods(base)
|
||||||
BASE_OS_OPTIONS.each do |base_os|
|
BASE_OS_OPTIONS.each do |base_os|
|
||||||
base.define_method(:"on_#{base_os}") do |&block|
|
base.define_method(:"on_#{base_os}") do |&block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
base.define_method(:on_system) do |linux, macos:, &block|
|
base.define_method(:on_system) do |linux, macos:, &block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
raise ArgumentError, "The first argument to `on_system` must be `:linux`" if linux != :linux
|
raise ArgumentError, "The first argument to `on_system` must be `:linux`" if linux != :linux
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
base.define_method(:on_system_conditional) do |macos: nil, linux: nil|
|
base.define_method(:on_system_conditional) do |macos: nil, linux: nil|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
if OnSystem.os_condition_met?(:macos) && macos.present?
|
if OnSystem.os_condition_met?(:macos) && macos.present?
|
||||||
macos
|
macos
|
||||||
@ -128,21 +128,24 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: T::Class[T.anything]).void }
|
||||||
def self.setup_macos_methods(base)
|
def self.setup_macos_methods(base)
|
||||||
MacOSVersion::SYMBOLS.each_key do |os_name|
|
MacOSVersion::SYMBOLS.each_key do |os_name|
|
||||||
base.define_method(:"on_#{os_name}") do |or_condition = nil, &block|
|
base.define_method(:"on_#{os_name}") do |or_condition = nil, &block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = T.let(true, T.nilable(TrueClass))
|
||||||
|
|
||||||
os_condition = OnSystem.condition_from_method_name T.must(__method__)
|
os_condition = OnSystem.condition_from_method_name T.must(__method__)
|
||||||
return unless OnSystem.os_condition_met? os_condition, or_condition
|
return unless OnSystem.os_condition_met? os_condition, or_condition
|
||||||
|
|
||||||
@on_system_block_min_os = if or_condition == :or_older
|
@on_system_block_min_os = T.let(
|
||||||
@called_in_on_system_block ? @on_system_block_min_os : MacOSVersion.new(HOMEBREW_MACOS_OLDEST_ALLOWED)
|
if or_condition == :or_older
|
||||||
else
|
@called_in_on_system_block ? @on_system_block_min_os : MacOSVersion.new(HOMEBREW_MACOS_OLDEST_ALLOWED)
|
||||||
MacOSVersion.from_symbol(os_condition)
|
else
|
||||||
end
|
MacOSVersion.from_symbol(os_condition)
|
||||||
@called_in_on_system_block = true
|
end,
|
||||||
|
T.nilable(MacOSVersion),
|
||||||
|
)
|
||||||
|
@called_in_on_system_block = T.let(true, T.nilable(T::Boolean))
|
||||||
result = block.call
|
result = block.call
|
||||||
@called_in_on_system_block = false
|
@called_in_on_system_block = false
|
||||||
|
|
||||||
@ -151,13 +154,13 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(_base: Class).void }
|
sig { params(_base: T::Class[T.anything]).void }
|
||||||
def self.included(_base)
|
def self.included(_base)
|
||||||
raise "Do not include `OnSystem` directly. Instead, include `OnSystem::MacOSAndLinux` or `OnSystem::MacOSOnly`"
|
raise "Do not include `OnSystem` directly. Instead, include `OnSystem::MacOSAndLinux` or `OnSystem::MacOSOnly`"
|
||||||
end
|
end
|
||||||
|
|
||||||
module MacOSAndLinux
|
module MacOSAndLinux
|
||||||
sig { params(base: Class).void }
|
sig { params(base: T::Class[T.anything]).void }
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
OnSystem.setup_arch_methods(base)
|
OnSystem.setup_arch_methods(base)
|
||||||
OnSystem.setup_base_os_methods(base)
|
OnSystem.setup_base_os_methods(base)
|
||||||
@ -166,7 +169,7 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
module MacOSOnly
|
module MacOSOnly
|
||||||
sig { params(base: Class).void }
|
sig { params(base: T::Class[T.anything]).void }
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
OnSystem.setup_arch_methods(base)
|
OnSystem.setup_arch_methods(base)
|
||||||
OnSystem.setup_macos_methods(base)
|
OnSystem.setup_macos_methods(base)
|
||||||
|
@ -90,7 +90,7 @@ module Readall
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
tap: Tap, aliases: T::Boolean, no_simulate: T::Boolean, os_arch_combinations: T::Array[T::Array[String]],
|
tap: Tap, aliases: T::Boolean, no_simulate: T::Boolean, os_arch_combinations: T::Array[[Symbol, Symbol]],
|
||||||
).returns(T::Boolean)
|
).returns(T::Boolean)
|
||||||
}
|
}
|
||||||
def self.valid_tap?(tap, aliases: false, no_simulate: false,
|
def self.valid_tap?(tap, aliases: false, no_simulate: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user