Skip to content

Commit

Permalink
sorbet: Tighten up dev-cmd types
Browse files Browse the repository at this point in the history
- Change `returns(NilClass)` to `void`.
- Get rid of some of the `T.untyped`.
  • Loading branch information
issyl0 committed Jul 4, 2024
1 parent 21ba72b commit f2f4f1c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 6 additions & 4 deletions Library/Homebrew/dev-cmd/unbottled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]])

Check warning on line 168 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L168

Added line #L168 was not covered by tests
}
def deps_uses_from_formulae(all_formulae)
ohai "Populating dependency tree..."

Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/dev-cmd/update-sponsors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 29 in Library/Homebrew/dev-cmd/update-sponsors.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/update-sponsors.rb#L29

Added line #L29 was not covered by tests

GitHub.sponsorships("Homebrew").each do |s|
largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f2f4f1c

Please sign in to comment.