From d323f2407913a03ce5cc3378c2dd0703e6a71622 Mon Sep 17 00:00:00 2001 From: Patrick Linnane Date: Wed, 14 Oct 2026 12:44:54 -0700 Subject: [PATCH] Accept dependency tag arrays in API metadata - `FormulaStruct` dependency entries only allowed a single tag symbol, so `{ "foo" => [:test, :no_linkage] }` failed `T::Props` validation under `HOMEBREW_SORBET_RUNTIME` (`brew test`, `test-bot`, `tests`). - Widen the type so readers accept combined tags before the metadata writer starts emitting them. Signed-off-by: Patrick Linnane --- Library/Homebrew/api/formula_struct.rb | 4 ++-- Library/Homebrew/test/api/formula_struct_spec.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/api/formula_struct.rb b/Library/Homebrew/api/formula_struct.rb index 44b7be5f89110..44b86ec046a8f 100644 --- a/Library/Homebrew/api/formula_struct.rb +++ b/Library/Homebrew/api/formula_struct.rb @@ -47,8 +47,8 @@ def self.from_hash(formula_hash) T.any( # Formula name: "foo" String, - # Formula name and dependency type: { "foo" => :build } - T::Hash[String, Symbol], + # Formula name and dependency types: { "foo" => :build } or { "foo" => [:test, :no_linkage] } + T::Hash[String, T.any(Symbol, T::Array[Symbol])], ), # Requirements T.any( diff --git a/Library/Homebrew/test/api/formula_struct_spec.rb b/Library/Homebrew/test/api/formula_struct_spec.rb index 679367d8e0999..cb93a716dc18f 100644 --- a/Library/Homebrew/test/api/formula_struct_spec.rb +++ b/Library/Homebrew/test/api/formula_struct_spec.rb @@ -284,6 +284,21 @@ def build_formula_struct(checksums) expect(restored).to eq(original) end + it "preserves tagged dependencies after serialize then deserialize" do + original = described_class.new( + desc: "tagged dependencies", + homepage: "https://example.com", + license: "MIT", + ruby_source_checksum: "abc123", + stable_version: "1.0.0", + stable_dependencies: ["dep1", { "dep2" => :no_linkage }, { "dep3" => [:test, :no_linkage] }], + ) + + restored = described_class.deserialize(original.serialize) + + expect(restored.stable_dependencies).to eq(original.stable_dependencies) + end + it "serializes post-install steps", :needs_macos do original = described_class.new( desc: "install steps test",