Merge pull request #18431 from Homebrew/PATH-strict-type

PATH: `typed: strict`
This commit is contained in:
Mike McQuaid 2024-09-27 08:37:27 +01:00 committed by GitHub
commit c1c1a43143
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# typed: strict
# frozen_string_literal: true
require "forwardable"
@ -7,16 +7,18 @@ require "forwardable"
class PATH
include Enumerable
extend Forwardable
extend T::Generic
delegate each: :@paths
Elem = type_member(:out) { { fixed: String } }
Element = T.type_alias { T.nilable(T.any(Pathname, String, PATH)) }
private_constant :Element
Elements = T.type_alias { T.any(Element, T::Array[Element]) }
private_constant :Elements
sig { params(paths: Elements).void }
def initialize(*paths)
@paths = parse(paths)
@paths = T.let(parse(paths), T::Array[String])
end
sig { params(paths: Elements).returns(T.self_type) }