Minor type safety improvements
This commit is contained in:
parent
2374e988d4
commit
fb2fdc5249
@ -56,10 +56,8 @@ module Cask
|
||||
.returns(T.nilable(T.attached_class))
|
||||
}
|
||||
def self.try_new(ref, warn: false)
|
||||
case ref
|
||||
when Cask, URI::Generic
|
||||
# do nothing
|
||||
else
|
||||
return if ref.is_a?(Cask)
|
||||
|
||||
content = ref.to_str
|
||||
|
||||
# Cache compiled regex
|
||||
@ -74,7 +72,6 @@ module Cask
|
||||
|
||||
new(content)
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(content: String, tap: Tap).void }
|
||||
def initialize(content, tap: T.unsafe(nil))
|
||||
|
@ -155,7 +155,7 @@ module Cask
|
||||
# @api public
|
||||
def method_missing(method, *args, &block)
|
||||
if @dsl.respond_to?(method)
|
||||
T.unsafe(@dsl).public_send(method, *args, &block)
|
||||
@dsl.public_send(method, *args, &block)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ module Homebrew
|
||||
formula_or_cask.homepage
|
||||
end
|
||||
|
||||
exec_browser(*T.unsafe(homepages))
|
||||
exec_browser(*homepages)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -50,9 +50,9 @@ module Homebrew
|
||||
|
||||
parallel = true
|
||||
|
||||
files = if args.only
|
||||
# FIXME: This is safe once args are namespaced by command
|
||||
test_name, line = T.unsafe(args.only).split(":", 2)
|
||||
only = args.only
|
||||
files = if only
|
||||
test_name, line = only.split(":", 2)
|
||||
|
||||
if line.nil?
|
||||
Dir.glob("test/{#{test_name},#{test_name}/**/*}_spec.rb")
|
||||
@ -67,7 +67,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
if files.blank?
|
||||
raise UsageError, "The `--only` argument requires a valid file or folder name!" if args.only
|
||||
raise UsageError, "The `--only` argument requires a valid file or folder name!" if only
|
||||
|
||||
if args.changed?
|
||||
opoo "No tests are directly associated with the changed files!"
|
||||
|
@ -3124,7 +3124,7 @@ class Formula
|
||||
removed = ENV.remove_cc_etc
|
||||
|
||||
begin
|
||||
T.unsafe(self).system("xcodebuild", *args)
|
||||
self.system("xcodebuild", *args)
|
||||
ensure
|
||||
ENV.update(removed)
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ module Homebrew
|
||||
attr_reader :column
|
||||
|
||||
sig { params(line: Integer, column: T.nilable(Integer)).void }
|
||||
def initialize(line, column = T.unsafe(nil))
|
||||
def initialize(line, column = nil)
|
||||
@line = line
|
||||
@column = column
|
||||
end
|
||||
|
@ -731,12 +731,10 @@ class Version
|
||||
def to_s = version.to_s
|
||||
|
||||
sig { params(options: T.untyped).returns(String) }
|
||||
def to_json(*options)
|
||||
T.unsafe(version).to_json(*options)
|
||||
end
|
||||
def to_json(*options) = version.to_json(*options)
|
||||
|
||||
sig { params(method: T.any(Symbol, String), include_all: T::Boolean).returns(T::Boolean) }
|
||||
def respond_to?(method, include_all = T.unsafe(nil))
|
||||
def respond_to?(method, include_all = false) # rubocop:disable Style/OptionalBooleanParameter (`Object` override)
|
||||
return !null? if ["to_str", :to_str].include?(method)
|
||||
|
||||
super
|
||||
|
Loading…
x
Reference in New Issue
Block a user