From f2f4f1c06d84a84e268230b9d5a0b2bb072d2778 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 4 Jul 2024 10:35:00 +0100 Subject: [PATCH 1/2] sorbet: Tighten up `dev-cmd` types - Change `returns(NilClass)` to `void`. - Get rid of some of the `T.untyped`. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/bump.rb | 4 ++-- Library/Homebrew/dev-cmd/unbottled.rb | 10 ++++++---- Library/Homebrew/dev-cmd/update-sponsors.rb | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 74dea4cf15aa5..c45a3c7382ffc 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -495,7 +495,7 @@ def check_new_version(formula, tap_remote_repo, version: nil, url: nil, tag: nil check_closed_pull_requests(formula, tap_remote_repo, version:) end - sig { params(formula: Formula, new_version: String).returns(NilClass) } + sig { params(formula: Formula, new_version: String).void } def check_throttle(formula, new_version) tap = formula.tap return if tap.nil? diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index 640845368a7ed..cdbd6c3228f41 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -314,7 +314,7 @@ def retrieve_pull_requests(formula_or_cask, name, state:, version: nil) sig { params( formula_or_cask: T.any(Formula, Cask::Cask), - repositories: T::Array[T.untyped], + repositories: T::Array[String], name: String, ).returns(VersionBumpInfo) } @@ -425,7 +425,7 @@ def retrieve_versions_by_arch(formula_or_cask:, repositories:, name:) params( formula_or_cask: T.any(Formula, Cask::Cask), name: String, - repositories: T::Array[T.untyped], + repositories: T::Array[String], ambiguous_cask: T::Boolean, ).void } diff --git a/Library/Homebrew/dev-cmd/unbottled.rb b/Library/Homebrew/dev-cmd/unbottled.rb index 7a73caf4a1b81..c77c9929ecfe3 100644 --- a/Library/Homebrew/dev-cmd/unbottled.rb +++ b/Library/Homebrew/dev-cmd/unbottled.rb @@ -164,7 +164,9 @@ def formulae_all_installs_from_args(all) T.let(formula_installs, T.nilable(T::Hash[Symbol, Integer]))] end - sig { params(all_formulae: T.untyped).returns([T::Hash[String, T.untyped], T::Hash[String, T.untyped]]) } + sig { + params(all_formulae: T::Array[Formula]).returns([T::Hash[String, T.untyped], T::Hash[String, T.untyped]]) + } def deps_uses_from_formulae(all_formulae) ohai "Populating dependency tree..." @@ -186,7 +188,7 @@ def deps_uses_from_formulae(all_formulae) [deps_hash, uses_hash] end - sig { params(formulae: T::Array[Formula]).returns(NilClass) } + sig { params(formulae: T::Array[Formula]).void } def output_total(formulae) return unless @bottle_tag @@ -205,7 +207,7 @@ def output_total(formulae) sig { params(formulae: T::Array[Formula], deps_hash: T::Hash[T.any(Symbol, String), T.untyped], noun: T.nilable(String), hash: T::Hash[T.any(Symbol, String), T.untyped], - any_named_args: T::Boolean).returns(NilClass) + any_named_args: T::Boolean).void } def output_unbottled(formulae, deps_hash, noun, hash, any_named_args) return unless @bottle_tag @@ -279,7 +281,7 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args) puts "No unbottled dependencies found!" end - sig { returns(NilClass) } + sig { void } def output_lost_bottles ohai ":#{@bottle_tag} lost bottles" diff --git a/Library/Homebrew/dev-cmd/update-sponsors.rb b/Library/Homebrew/dev-cmd/update-sponsors.rb index 26a2202418ec8..5b0c2b02f047f 100644 --- a/Library/Homebrew/dev-cmd/update-sponsors.rb +++ b/Library/Homebrew/dev-cmd/update-sponsors.rb @@ -26,7 +26,7 @@ def run named_sponsors = [] logo_sponsors = [] # FIXME: This T.let should be unnecessary https://github.com/sorbet/sorbet/issues/6894 - largest_monthly_amount = T.let(0, T.untyped) + largest_monthly_amount = T.let(0, Integer) GitHub.sponsorships("Homebrew").each do |s| largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max @@ -62,17 +62,17 @@ def run private - sig { params(sponsor: T::Hash[Symbol, T.untyped]).returns(T.nilable(String)) } + sig { params(sponsor: T::Hash[Symbol, String]).returns(T.nilable(String)) } def sponsor_name(sponsor) sponsor[:name] || sponsor[:login] end - sig { params(sponsor: T::Hash[Symbol, T.untyped]).returns(String) } + sig { params(sponsor: T::Hash[Symbol, String]).returns(String) } def sponsor_logo(sponsor) "https://github.com/#{sponsor[:login]}.png?size=64" end - sig { params(sponsor: T::Hash[Symbol, T.untyped]).returns(String) } + sig { params(sponsor: T::Hash[Symbol, String]).returns(String) } def sponsor_url(sponsor) "https://github.com/#{sponsor[:login]}" end From f6e093a076e64713e0383cb60aaac15a5186f4ad Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 4 Jul 2024 13:45:42 +0100 Subject: [PATCH 2/2] Remove unnecessary comment - `T.let` is necessary in this case in strict mode. Co-authored-by: Mike McQuaid --- Library/Homebrew/dev-cmd/update-sponsors.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/update-sponsors.rb b/Library/Homebrew/dev-cmd/update-sponsors.rb index 5b0c2b02f047f..7d87756910e74 100644 --- a/Library/Homebrew/dev-cmd/update-sponsors.rb +++ b/Library/Homebrew/dev-cmd/update-sponsors.rb @@ -25,7 +25,6 @@ class UpdateSponsors < AbstractCommand def run named_sponsors = [] logo_sponsors = [] - # FIXME: This T.let should be unnecessary https://github.com/sorbet/sorbet/issues/6894 largest_monthly_amount = T.let(0, Integer) GitHub.sponsorships("Homebrew").each do |s|