checksum: enable strict typing

This commit is contained in:
Caleb Xu 2024-04-25 17:00:02 -04:00
parent f381b2cdf7
commit 58b50badef
No known key found for this signature in database
GPG Key ID: 47E6040D07B8407D

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