Skip to content

Commit

Permalink
Merge pull request #17405 from Homebrew/fewer-casts
Browse files Browse the repository at this point in the history
Remove unnecessary use of `T.cast`
  • Loading branch information
dduugg authored May 31, 2024
2 parents fe16e9d + 179419d commit c9acd4e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ def manpagedir
sig { returns(T::Array[String]) }
def languages
[
*T.cast(explicit.fetch(:languages, []), T::Array[String]),
*T.cast(env.fetch(:languages, []), T::Array[String]),
*T.cast(default.fetch(:languages, []), T::Array[String]),
*explicit.fetch(:languages, []),
*env.fetch(:languages, []),
*default.fetch(:languages, []),
].uniq.select do |lang|
# Ensure all languages are valid.
Locale.parse(lang)
Expand Down
7 changes: 2 additions & 5 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1829,15 +1829,13 @@ def std_go_args(output: bin/name, ldflags: nil)
# Standard parameters for cabal-v2 builds.
sig { returns(T::Array[String]) }
def std_cabal_v2_args
env = T.cast(ENV, T.any(Stdenv, Superenv))

# cabal-install's dependency-resolution backtracking strategy can
# easily need more than the default 2,000 maximum number of
# "backjumps," since Hackage is a fast-moving, rolling-release
# target. The highest known needed value by a formula was 43,478
# for git-annex, so 100,000 should be enough to avoid most
# gratuitous backjumps build failures.
["--jobs=#{env.make_jobs}", "--max-backjumps=100000", "--install-method=copy", "--installdir=#{bin}"]
["--jobs=#{ENV.make_jobs}", "--max-backjumps=100000", "--install-method=copy", "--installdir=#{bin}"]
end

# Standard parameters for meson builds.
Expand Down Expand Up @@ -3156,8 +3154,7 @@ def exec_cmd(cmd, args, out, logfn)
if cmd == "python"
setup_py_in_args = %w[setup.py build.py].include?(args.first)
setuptools_shim_in_args = args.any? { |a| a.to_s.start_with? "import setuptools" }
env = T.cast(ENV, T.any(Stdenv, Superenv))
env.refurbish_args if setup_py_in_args || setuptools_shim_in_args
ENV.refurbish_args if setup_py_in_args || setuptools_shim_in_args
end

$stdout.reopen(out)
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ def ruby_source_checksum
end
end

klass = T.cast(klass, T.class_of(Formula))
mod.const_set(class_name, klass)

platform_cache[:api] ||= {}
Expand Down
3 changes: 1 addition & 2 deletions Library/Homebrew/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def keep_alive(value = nil)
when true, false
@keep_alive = { always: value }
when Hash
hash = T.cast(value, Hash)
unless (hash.keys - KEEP_ALIVE_KEYS).empty?
unless (value.keys - KEEP_ALIVE_KEYS).empty?
raise TypeError, "Service#keep_alive allows only #{KEEP_ALIVE_KEYS}"
end

Expand Down

0 comments on commit c9acd4e

Please sign in to comment.