Skip to content

Commit

Permalink
Merge pull request #10364 from SeekingMeaning/version-strict-typecheck
Browse files Browse the repository at this point in the history
os/mac/version: update method signatures
  • Loading branch information
SeekingMeaning authored Jan 22, 2021
2 parents 2268e77 + 779f2fc commit bf448de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Library/Homebrew/os/mac/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Mac
class Version < ::Version
extend T::Sig

sig { returns(Symbol) }
attr_reader :arch

SYMBOLS = {
Expand All @@ -33,7 +34,7 @@ def self.from_symbol(sym)
new(str, arch: arch)
end

sig { params(value: T.any(String, Symbol)).returns(T::Array[String]) }
sig { params(value: T.any(String, Symbol)).returns(T.any([], [String, T.nilable(String)])) }
def self.version_arch(value)
@all_archs_regex ||= begin
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
Expand All @@ -43,7 +44,7 @@ def self.version_arch(value)
(-(?<suffix_arch>#{Regexp.union(all_archs)}))?$
/x
end
match = @all_archs_regex.match(value)
match = @all_archs_regex.match(value.to_s)
return [] unless match

version = match[:version]
Expand All @@ -65,6 +66,7 @@ def initialize(value, arch: nil)
@comparison_cache = {}
end

sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other)
@comparison_cache.fetch(other) do
if SYMBOLS.key?(other) && to_sym == other
Expand Down

0 comments on commit bf448de

Please sign in to comment.