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 class UsesFromMacOSDependency < Dependency
attr_reader :bounds attr_reader :bounds
sig { params(name: String, tags: T::Array[Symbol], bounds: T::Hash[Symbol, Symbol]).void }
def initialize(name, tags = [], bounds:) def initialize(name, tags = [], bounds:)
super(name, tags) super(name, tags)

View File

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

View File

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

View File

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