From a41f15ede7730bad6ae40d6921b37408b1b86f31 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sun, 11 Aug 2024 16:19:51 -0700 Subject: [PATCH] Make FromContentLoader.try_new typesafe --- Library/Homebrew/cask/cask_loader.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/cask_loader.rb b/Library/Homebrew/cask/cask_loader.rb index d45d55113f..93f4a67f16 100644 --- a/Library/Homebrew/cask/cask_loader.rb +++ b/Library/Homebrew/cask/cask_loader.rb @@ -51,10 +51,14 @@ module Cask # 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) + return if ref.is_a?(URI::Generic) - content = T.unsafe(ref).to_str + content = ref.to_str # Cache compiled regex @regex ||= begin