Replace custom stubs with sorbet-runtime-stub.

This commit is contained in:
Markus Reiter 2020-10-09 12:11:23 +02:00
parent 772a45e758
commit d36df37099
9 changed files with 25 additions and 90 deletions

View File

@ -1,8 +1,6 @@
# typed: strict # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
require "utils/sorbet"
# Class corresponding to the `url` stanza. # Class corresponding to the `url` stanza.
# #
# @api private # @api private

View File

@ -58,6 +58,7 @@ module Homebrew
ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat? ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat?
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic? ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic?
ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online? ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online?
ENV["HOMEBREW_SORBET_RUNTIME"] = "1"
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp

View File

@ -251,6 +251,10 @@ module Homebrew
"of macOS. This is useful in development on new macOS versions.", "of macOS. This is useful in development on new macOS versions.",
boolean: true, boolean: true,
}, },
HOMEBREW_SORBET_RUNTIME: {
description: "Enable runtime typechecking using Sorbet.",
boolean: true,
},
HOMEBREW_SVN: { HOMEBREW_SVN: {
description: "Use this as the `svn`(1) binary.", description: "Use this as the `svn`(1) binary.",
default_text: "A Homebrew-built Subversion (if installed), or the system-provided binary.", default_text: "A Homebrew-built Subversion (if installed), or the system-provided binary.",

View File

@ -31,6 +31,8 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular "it", "they" inflect.irregular "it", "they"
end end
require "utils/sorbet"
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"]
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_BREW_DEFAULT_GIT_REMOTE"] HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_BREW_DEFAULT_GIT_REMOTE"]
HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"] HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"]

View File

@ -12,7 +12,6 @@ require "utils/link"
require "utils/livecheck_formula" require "utils/livecheck_formula"
require "utils/popen" require "utils/popen"
require "utils/repology" require "utils/repology"
require "utils/sorbet"
require "utils/svn" require "utils/svn"
require "utils/tty" require "utils/tty"
require "tap_constants" require "tap_constants"

View File

@ -1,8 +1,17 @@
# typed: strict # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
if ENV["HOMEBREW_TESTS_COVERAGE"] if ENV["HOMEBREW_SORBET_RUNTIME"]
require "utils/gems"
Homebrew.install_bundler_gems!
require "sorbet-runtime" require "sorbet-runtime"
else else
require "utils/sorbet/stubs" begin
gem "sorbet-runtime"
raise "Loaded `sorbet-runtime` instead of `sorbet-runtime-stub`."
rescue Gem::LoadError
nil
end
require "sorbet-runtime-stub"
end end

View File

@ -1,85 +0,0 @@
# typed: false
# frozen_string_literal: true
# Stubs for `sorbet-runtime`, all taken from `sorbet/t` except for `T::Sig.sig`.
#
# @private
module T
# rubocop:disable Style/Documentation
module Sig
module WithoutRuntime
def self.sig(arg = nil, &blk); end
end
module_function
def sig(arg = nil, &blk); end
end
def self.any(type_a, type_b, *types); end
def self.nilable(type); end
def self.untyped; end
def self.noreturn; end
def self.all(type_a, type_b, *types); end
def self.enum(values); end
def self.proc; end
def self.self_type; end
def self.class_of(klass); end
def self.type_alias(type = nil, &blk); end
def self.type_parameter(name); end
def self.cast(value, _type, checked: true)
value
end
def self.let(value, _type, checked: true)
value
end
def self.assert_type!(value, _type, checked: true)
value
end
def self.unsafe(value)
value
end
def self.must(arg, _msg = nil)
arg
end
def self.reveal_type(value)
value
end
module Array
def self.[](type); end
end
module Hash
def self.[](keys, values); end
end
module Enumerable
def self.[](type); end
end
module Range
def self.[](type); end
end
module Set
def self.[](type); end
end
# rubocop:enable Style/Documentation
end

View File

@ -1770,6 +1770,9 @@ For example, you might add something like the following to your ~/.profile, ~/.b
* `HOMEBREW_SKIP_OR_LATER_BOTTLES`: * `HOMEBREW_SKIP_OR_LATER_BOTTLES`:
If set with `HOMEBREW_DEVELOPER`, do not use bottles from older versions of macOS. This is useful in development on new macOS versions. If set with `HOMEBREW_DEVELOPER`, do not use bottles from older versions of macOS. This is useful in development on new macOS versions.
* `HOMEBREW_SORBET_RUNTIME`:
Enable runtime typechecking using Sorbet.
* `HOMEBREW_SVN`: * `HOMEBREW_SVN`:
Use this as the `svn`(1) binary. Use this as the `svn`(1) binary.

View File

@ -2446,6 +2446,10 @@ If set, use Pry for the \fBbrew irb\fR command\.
If set with \fBHOMEBREW_DEVELOPER\fR, do not use bottles from older versions of macOS\. This is useful in development on new macOS versions\. If set with \fBHOMEBREW_DEVELOPER\fR, do not use bottles from older versions of macOS\. This is useful in development on new macOS versions\.
. .
.TP .TP
\fBHOMEBREW_SORBET_RUNTIME\fR
Enable runtime typechecking using Sorbet\.
.
.TP
\fBHOMEBREW_SVN\fR \fBHOMEBREW_SVN\fR
Use this as the \fBsvn\fR(1) binary\. Use this as the \fBsvn\fR(1) binary\.
. .