Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens Sorbet typing around Homebrew Bundle’s service integration by moving bundle/brew_services.rb to typed: strict and adjusting call sites accordingly.
Changes:
- Switch
Library/Homebrew/bundle/brew_services.rbto# typed: strictand add Sorbetsigs / typed ivars. - Add typed memoization for cached service state and old-name lookup.
- Adjust
bundle execservice conflict handling to use a typed local variable for the service name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Library/Homebrew/bundle/commands/exec.rb | Adds a Sorbet cast to satisfy typing when stopping conflicting services. |
| Library/Homebrew/bundle/brew_services.rb | Moves to typed: strict and introduces method signatures and typed instance variables. |
Comments suppressed due to low confidence (1)
Library/Homebrew/bundle/brew_services.rb:114
- In a
typed: strictfile,installed_and_up_to_date?is overridingHomebrew::Bundle::PackageType#installed_and_up_to_date?, but the new sig usesT.untypedand doesn’t declareoverride. Consider tightening this to match the parent signature (e.g.,override.params(package: Object, no_upgrade: T::Boolean).returns(T::Boolean)) to keep strict-mode type safety consistent with other Bundle package types.
sig { params(formula: T.untyped, no_upgrade: T::Boolean).returns(T::Boolean) }
def installed_and_up_to_date?(formula, no_upgrade: false)
_ = no_upgrade
return true unless formula_needs_to_start?(entry_to_formula(formula))
return true if self.class.started?(formula.name)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5666dbc to
17b257f
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good so far, some notes. May be worth tightening up Homebrew::Bundle::Brew if that's where all the Objects have crept in.
| conflicting_services.each do |conflict| | ||
| if Bundle::Brew::Services.stop(conflict["name"], keep: true) | ||
| services_to_restart << conflict["name"] if conflict["registered"] | ||
| name = T.cast(conflict["name"], String) |
There was a problem hiding this comment.
| name = T.cast(conflict["name"], String) | |
| name = conflict["name"].to_s |
| sig { override.params(formula: Object, no_upgrade: T::Boolean).returns(T::Boolean) } | ||
| def installed_and_up_to_date?(formula, no_upgrade: false) | ||
| _ = no_upgrade | ||
| formula = T.cast(formula, Homebrew::Bundle::Dsl::Entry) |
There was a problem hiding this comment.
This cast is weird.
| sig { override.params(formula: Object, no_upgrade: T::Boolean).returns(T::Boolean) } | |
| def installed_and_up_to_date?(formula, no_upgrade: false) | |
| _ = no_upgrade | |
| formula = T.cast(formula, Homebrew::Bundle::Dsl::Entry) | |
| sig { override.params(formula: Homebrew::Bundle::Dsl::Entry, no_upgrade: T::Boolean).returns(T::Boolean) } | |
| def installed_and_up_to_date?(formula, no_upgrade: false) | |
| _ = no_upgrade |
| old_name | ||
| end | ||
|
|
||
| sig { override.params(entries: T::Array[Object]).returns(T::Array[Object]) } |
There was a problem hiding this comment.
Can something more specific than Object be used here?
| @started_services = T.let(nil, T.nilable(T::Array[String])) | ||
| end | ||
|
|
||
| sig { params(name: String, keep: T::Boolean, verbose: T::Boolean).returns(T.nilable(T::Boolean)) } |
There was a problem hiding this comment.
Avoiding T.nilable(T::Boolean) would be good, nicer to return false or true and make a T::Boolean. Same with all others below.
| end | ||
| end | ||
|
|
||
| sig { override.params(name: Object, no_upgrade: T::Boolean).returns(String) } |
brew lgtm(style, typechecking and tests) with your changes locally?Just tightening this file up after #21828