Skip to content

Make the remaining bundle files typed: true #20128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/PATH.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def insert(index, *paths)
self
end

sig { params(block: T.proc.params(arg0: String).returns(T::Boolean)).returns(T.self_type) }
sig { params(block: T.proc.params(arg0: String).returns(BasicObject)).returns(T.self_type) }
def select(&block)
self.class.new(@paths.select(&block))
end

sig { params(block: T.proc.params(arg0: String).returns(T::Boolean)).returns(T.self_type) }
sig { params(block: T.proc.params(arg0: String).returns(BasicObject)).returns(T.self_type) }
def reject(&block)
self.class.new(@paths.reject(&block))
end
Expand Down
20 changes: 15 additions & 5 deletions Library/Homebrew/bundle/commands/exec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: false # rubocop:todo Sorbet/TrueSigil
# typed: true
# frozen_string_literal: true

require "English"
Expand All @@ -13,6 +13,16 @@ module Commands
module Exec
PATH_LIKE_ENV_REGEX = /.+#{File::PATH_SEPARATOR}/

sig {
params(
args: String,
global: T::Boolean,
file: T.nilable(String),
subcommand: String,
services: T::Boolean,
check: T::Boolean,
).void
}
def self.run(*args, global: false, file: nil, subcommand: "", services: false, check: false)
if check
require "bundle/commands/check"
Expand All @@ -25,9 +35,9 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false, c

# Setup Homebrew's ENV extensions
ENV.activate_extensions!
raise UsageError, "No command to execute was specified!" if args.blank?

command = args.first
raise UsageError, "No command to execute was specified!" if command.blank?

require "bundle/brewfile"
@dsl = Brewfile.read(global:, file:)
Expand Down Expand Up @@ -181,7 +191,7 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false, c
if services
require "bundle/brew_services"

exit_code = 0
exit_code = T.let(0, Integer)
run_services(@dsl.entries) do
Kernel.system(*args)
if (system_exit_code = $CHILD_STATUS&.exitstatus)
Expand All @@ -199,7 +209,7 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false, c
entries: T::Array[Homebrew::Bundle::Dsl::Entry],
_block: T.proc.params(
entry: Homebrew::Bundle::Dsl::Entry,
info: T::Hash[String, T.anything],
info: T::Hash[String, T.untyped],
service_file: Pathname,
conflicting_services: T::Array[T::Hash[String, T.anything]],
).void,
Expand Down Expand Up @@ -279,7 +289,7 @@ def self.run(*args, global: false, file: nil, subcommand: "", services: false, c
map_service_info(entries) do |entry, info, service_file, conflicting_services|
# Don't restart if already running this version
loaded_file = Pathname.new(info["loaded_file"].to_s)
next if info["running"] && loaded_file&.file? && loaded_file&.realpath == service_file.realpath
next if info["running"] && loaded_file.file? && loaded_file.realpath == service_file.realpath

if info["running"] && !Bundle::BrewServices.stop(info["name"], keep: true)
opoo "Failed to stop #{info["name"]} service"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/--env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.command_name = "--env"
sig { override.void }
def run
ENV.activate_extensions!
T.cast(ENV, Superenv).deps = args.named.to_formulae if superenv?(nil)
ENV.deps = args.named.to_formulae if superenv?(nil)
ENV.setup_build_environment

shell = if args.plain?
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/dependencies.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Dependencies < SimpleDelegator
sig { returns(T::Enumerator[Dependency]) }
def each(&blk); end

sig { params(blk: T.proc.params(arg0: Dependency).returns(T::Boolean)).returns(T::Array[Dependency]) }
sig { returns(T::Enumerator[Dependency]) }
sig { override.params(blk: T.proc.params(arg0: Dependency).returns(T.anything)).returns(T::Array[Dependency]) }
sig { override.returns(T::Enumerator[Dependency]) }
def select(&blk); end
end

Expand All @@ -26,7 +26,7 @@ class Requirements < SimpleDelegator
sig { returns(T::Enumerator[Requirement]) }
def each(&blk); end

sig { params(blk: T.proc.params(arg0: Requirement).returns(T::Boolean)).returns(T::Array[Requirement]) }
sig { returns(T::Enumerator[Requirement]) }
sig { override.params(blk: T.proc.params(arg0: Requirement).returns(T.anything)).returns(T::Array[Requirement]) }
sig { override.returns(T::Enumerator[Requirement]) }
def select(&blk); end
end
12 changes: 7 additions & 5 deletions Library/Homebrew/dev-cmd/sh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
in an Xcode-only configuration since it adds tools like `make` to your `$PATH`
which build systems would not find otherwise.
EOS
flag "--env=",
description: "Use the standard `$PATH` instead of superenv's when `std` is passed."
flag "-c=", "--cmd=",
description: "Execute commands in a non-interactive shell."
flag "--env=",
description: "Use the standard `$PATH` instead of superenv's when `std` is passed."
flag "-c=", "--cmd=",
description: "Execute commands in a non-interactive shell."

named_args :file, max: 1
end
Expand All @@ -29,7 +29,9 @@
ENV.activate_extensions!(env: args.env)

if superenv?(args.env)
T.cast(ENV, Superenv).deps = Formula.installed.select { |f| f.keg_only? && f.opt_prefix.directory? }
ENV.deps = Formula.installed.select do |f|
f.keg_only? && f.opt_prefix.directory?

Check warning on line 33 in Library/Homebrew/dev-cmd/sh.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/sh.rb#L33

Added line #L33 was not covered by tests
end
end
ENV.setup_build_environment
if superenv?(args.env)
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/ENV.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class Sorbet
module Static
class ENVClass
include EnvActivation
# NOTE: This is a bit misleading, as at most only one of these can be true
# See: EnvActivation#activate_extensions!
include Stdenv
include Superenv
end
end
end
Expand Down