Enable types in dev-cmd, etc.

This commit is contained in:
Douglas Eichelberger 2023-04-04 22:13:58 -07:00
parent 97d7a5c9b4
commit c5ffec1a11
6 changed files with 46 additions and 20 deletions

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"
@ -6,10 +6,8 @@ require "cli/parser"
module Homebrew module Homebrew
extend T::Sig extend T::Sig
module_function
sig { returns(CLI::Parser) } sig { returns(CLI::Parser) }
def typecheck_args def self.typecheck_args
Homebrew::CLI::Parser.new do Homebrew::CLI::Parser.new do
description <<~EOS description <<~EOS
Check for typechecking errors using Sorbet. Check for typechecking errors using Sorbet.
@ -44,7 +42,7 @@ module Homebrew
end end
sig { void } sig { void }
def typecheck def self.typecheck
args = typecheck_args.parse args = typecheck_args.parse
Homebrew.install_bundler_gems!(groups: ["sorbet"]) Homebrew.install_bundler_gems!(groups: ["sorbet"])
@ -95,9 +93,10 @@ module Homebrew
srb_exec += ["--ignore", args.ignore] if args.ignore.present? srb_exec += ["--ignore", args.ignore] if args.ignore.present?
if args.file.present? || args.dir.present? if args.file.present? || args.dir.present?
cd("sorbet") cd("sorbet") do
srb_exec += ["--file", "../#{args.file}"] if args.file srb_exec += ["--file", "../#{args.file}"] if args.file
srb_exec += ["--dir", "../#{args.dir}"] if args.dir srb_exec += ["--dir", "../#{args.dir}"] if args.dir
end
end end
success = system(*srb_exec) success = system(*srb_exec)
return if success return if success

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "stringio" require "stringio"
@ -8,10 +8,8 @@ require "cli/parser"
module Homebrew module Homebrew
extend T::Sig extend T::Sig
module_function
sig { returns(CLI::Parser) } sig { returns(CLI::Parser) }
def unpack_args def self.unpack_args
Homebrew::CLI::Parser.new do Homebrew::CLI::Parser.new do
description <<~EOS description <<~EOS
Unpack the source files for <formula> into subdirectories of the current Unpack the source files for <formula> into subdirectories of the current
@ -33,7 +31,7 @@ module Homebrew
end end
end end
def unpack def self.unpack
args = unpack_args.parse args = unpack_args.parse
formulae = args.named.to_formulae formulae = args.named.to_formulae
@ -69,10 +67,11 @@ module Homebrew
next unless args.git? next unless args.git?
ohai "Setting up Git repository" ohai "Setting up Git repository"
cd stage_dir cd(stage_dir) do
system "git", "init", "-q" system "git", "init", "-q"
system "git", "add", "-A" system "git", "add", "-A"
system "git", "commit", "-q", "-m", "brew-unpack" system "git", "commit", "-q", "-m", "brew-unpack"
end
end end
end end
end end

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"
@ -40,7 +40,8 @@ module Homebrew
named_sponsors = [] named_sponsors = []
logo_sponsors = [] logo_sponsors = []
largest_monthly_amount = 0 # FIXME: This T.let should be unnecessary https://github.com/sorbet/sorbet/issues/6894
largest_monthly_amount = T.let(0, T.untyped)
GitHub.sponsorships("Homebrew").each do |s| GitHub.sponsorships("Homebrew").each do |s|
largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"

View File

@ -3,6 +3,22 @@
# This file contains temporary definitions for fixes that have # This file contains temporary definitions for fixes that have
# been submitted upstream to https://github.com/sorbet/sorbet. # been submitted upstream to https://github.com/sorbet/sorbet.
module FileUtils
# @see https://github.com/sorbet/sorbet/pull/6847
sig do
params(
src: T.any(String, Pathname),
dest: T.any(String, Pathname),
preserve: T.nilable(T::Boolean),
noop: T.nilable(T::Boolean),
verbose: T.nilable(T::Boolean),
dereference_root: T::Boolean,
remove_destination: T.nilable(T::Boolean)
).returns(T::Array[String])
end
module_function def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil); end
end
module Kernel module Kernel
# @see https://github.com/sorbet/sorbet/blob/a1e8389/rbi/core/kernel.rbi#L41-L46 # @see https://github.com/sorbet/sorbet/blob/a1e8389/rbi/core/kernel.rbi#L41-L46
sig do sig do

View File

@ -418,6 +418,17 @@ module GitHub
result["organization"]["team"]["members"]["nodes"].to_h { |member| [member["login"], member["name"]] } result["organization"]["team"]["members"]["nodes"].to_h { |member| [member["login"], member["name"]] }
end end
sig {
params(user: String)
.returns(
T::Array[{
closest_tier_monthly_amount: Integer,
login: String,
monthly_amount: Integer,
name: String,
}],
)
}
def self.sponsorships(user) def self.sponsorships(user)
has_next_page = T.let(true, T::Boolean) has_next_page = T.let(true, T::Boolean)
after = "" after = ""