Skip to content

Commit 585ff58

Browse files
authored
Merge pull request #21135 from Homebrew/sorbet-equals
Update type signature for `==`
2 parents 123bf79 + bc7d8b7 commit 585ff58

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

Library/Homebrew/bump_version_parser.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ def blank?
5151
@general.blank? && @arm.blank? && @intel.blank?
5252
end
5353

54-
sig { params(other: T.untyped).returns(T::Boolean) }
54+
sig { params(other: T.anything).returns(T::Boolean) }
5555
def ==(other)
56-
return false unless other.is_a?(BumpVersionParser)
57-
58-
(general == other.general) && (arm == other.arm) && (intel == other.intel)
56+
case other
57+
when BumpVersionParser
58+
(general == other.general) && (arm == other.arm) && (intel == other.intel)
59+
else
60+
false
61+
end
5962
end
6063
end
6164
end

Library/Homebrew/checksum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def inspect
2020

2121
delegate [:empty?, :to_s, :length, :[]] => :@hexdigest
2222

23-
sig { params(other: T.any(String, Checksum, Symbol)).returns(T::Boolean) }
23+
sig { params(other: T.anything).returns(T::Boolean) }
2424
def ==(other)
2525
case other
2626
when String

Library/Homebrew/utils/pypi.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,14 @@ def same_package?(other)
129129
end
130130

131131
# Compare only names so we can use .include? and .uniq on a Package array
132-
sig { params(other: Package).returns(T::Boolean) }
132+
sig { params(other: T.anything).returns(T::Boolean) }
133133
def ==(other)
134-
same_package?(other)
134+
case other
135+
when Package
136+
same_package?(other)
137+
else
138+
false
139+
end
135140
end
136141
alias eql? ==
137142

Library/Homebrew/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def <=>(other)
633633
0
634634
end
635635

636-
sig { override.params(other: T.untyped).returns(T::Boolean) }
636+
sig { override.params(other: T.anything).returns(T::Boolean) }
637637
def ==(other)
638638
# Makes sure that the same instance of Version::NULL
639639
# will never equal itself; normally Comparable#==

0 commit comments

Comments
 (0)