version: fix type signature

Fixes type error:
Parameter 'val': Expected type T.any(String, Version), got type PkgVersion
This commit is contained in:
Jonathan Chang 2021-01-21 16:11:37 +11:00
parent 4b5b1f61a3
commit 1e04cce19b

View File

@ -1,6 +1,7 @@
# typed: true # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "pkg_version"
require "version/null" require "version/null"
# A formula's version. # A formula's version.
@ -509,7 +510,7 @@ class Version
end end
private_class_method :_parse private_class_method :_parse
sig { params(val: T.any(String, Version), detected_from_url: T::Boolean).void } sig { params(val: T.any(PkgVersion, String, Version), detected_from_url: T::Boolean).void }
def initialize(val, detected_from_url: false) def initialize(val, detected_from_url: false)
raise TypeError, "Version value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str) raise TypeError, "Version value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str)