Merge pull request #17151 from alebcay/checksum-strict-typing

checksum: enable strict typing
This commit is contained in:
Kevin 2024-04-25 20:08:43 -07:00 committed by GitHub
commit f5cde8ad0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
# typed: true # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
# A formula's checksum. # A formula's checksum.
@ -7,14 +7,17 @@
class Checksum class Checksum
extend Forwardable extend Forwardable
sig { returns(String) }
attr_reader :hexdigest attr_reader :hexdigest
sig { params(hexdigest: String).void }
def initialize(hexdigest) def initialize(hexdigest)
@hexdigest = hexdigest.downcase @hexdigest = T.let(hexdigest.downcase, String)
end end
delegate [:empty?, :to_s, :length, :[]] => :@hexdigest delegate [:empty?, :to_s, :length, :[]] => :@hexdigest
sig { params(other: T.any(String, Checksum, Symbol)).returns(T::Boolean) }
def ==(other) def ==(other)
case other case other
when String when String