Avoid T.unsafe.

This commit is contained in:
Markus Reiter 2024-02-13 00:42:54 +01:00
parent d9712f4d50
commit c6788bb27e
No known key found for this signature in database
GPG Key ID: 245293B51702655B
4 changed files with 16 additions and 15 deletions

View File

@ -230,6 +230,7 @@ end
class UsesFromMacOSDependency < Dependency
attr_reader :bounds
sig { params(name: String, tags: T::Array[Symbol], bounds: T::Hash[Symbol, Symbol]).void }
def initialize(name, tags = [], bounds:)
super(name, tags)

View File

@ -3371,12 +3371,12 @@ class Formula
# On Linux this will act as {.depends_on}.
sig {
params(
dep: String,
bounds: T.any(Symbol, T::Array[Symbol]),
dep: T.any(String, T::Hash[T.any(String, Symbol), T.any(Symbol, T::Array[Symbol])]),
bounds: T::Hash[Symbol, Symbol],
).void
}
def uses_from_macos(dep = T.unsafe(nil), **bounds)
specs.each { |spec| spec.uses_from_macos(*dep, **bounds) }
def uses_from_macos(dep, bounds = {})
specs.each { |spec| spec.uses_from_macos(dep, bounds) }
end
# @!attribute [w] option

View File

@ -237,10 +237,9 @@ module Formulary
bounds.deep_transform_values!(&:to_sym)
if dep.is_a?(Hash)
dep.deep_transform_values!(&:to_sym)
uses_from_macos(**T.unsafe(dep.merge(bounds)))
uses_from_macos dep.deep_transform_values(&:to_sym).merge(bounds)
else
uses_from_macos dep, **bounds
uses_from_macos dep, bounds
end
end
end

View File

@ -188,18 +188,19 @@ class SoftwareSpec
sig {
params(
dep: String,
bounds: T.any(Symbol, T::Array[Symbol]),
dep: T.any(String, T::Hash[T.any(String, Symbol), T.any(Symbol, T::Array[Symbol])]),
bounds: T::Hash[Symbol, Symbol],
).void
}
def uses_from_macos(dep = T.unsafe(nil), **bounds)
bounds = bounds.dup
if dep
tags = []
else
def uses_from_macos(dep, bounds = {})
if dep.is_a?(Hash)
bounds = dep.dup
dep, tags = bounds.shift
dep = T.cast(dep, String)
tags = [*tags]
bounds = T.cast(bounds, T::Hash[Symbol, Symbol])
else
tags = []
end
depends_on UsesFromMacOSDependency.new(dep, tags, bounds: bounds)