Skip to content

Commit

Permalink
Make FromContentLoader.try_new typesafe
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Aug 12, 2024
1 parent d40e170 commit 96743b0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/cask/cask_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ def cask(header_token, **options, &block)

# Loads a cask from a string.
class FromContentLoader < AbstractContentLoader
sig {
params(ref: T.any(Pathname, String, URI::Generic), warn: T::Boolean)
.returns(T.nilable(T.attached_class))
}
def self.try_new(ref, warn: false)
return false unless ref.respond_to?(:to_str)

content = T.unsafe(ref).to_str
content = ref.to_str

# Cache compiled regex
@regex ||= begin
Expand Down

0 comments on commit 96743b0

Please sign in to comment.