From 861dea9adaf0c467c36d2f6229a2c85908eebee0 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 11 Sep 2021 01:00:23 +0100 Subject: [PATCH] Bump various type strictnesses --- Library/Homebrew/api/versions.rb | 2 +- Library/Homebrew/cask/artifact/artifact.rb | 2 +- Library/Homebrew/cask/artifact/uninstall.rb | 2 +- Library/Homebrew/cask/artifact/zap.rb | 2 +- Library/Homebrew/cask/cmd.rb | 2 +- Library/Homebrew/cask/dsl/version.rb | 2 +- Library/Homebrew/cask/utils.rb | 2 +- Library/Homebrew/dev-cmd/create.rb | 2 +- Library/Homebrew/dev-cmd/man.rb | 2 +- Library/Homebrew/dev-cmd/test.rb | 2 +- Library/Homebrew/extend/module.rb | 2 +- Library/Homebrew/extend/on_os.rb | 10 +++++++--- Library/Homebrew/extend/os/linux/api/analytics.rb | 2 +- Library/Homebrew/extend/os/linux/api/bottle.rb | 2 +- Library/Homebrew/extend/os/linux/api/formula.rb | 2 +- Library/Homebrew/extend/os/linux/extend/ENV/std.rb | 2 +- Library/Homebrew/extend/os/linux/extend/ENV/super.rb | 2 +- Library/Homebrew/extend/os/linux/on_os.rb | 4 ++-- Library/Homebrew/extend/os/mac/language/java.rb | 2 +- Library/Homebrew/extend/os/mac/on_os.rb | 4 ++-- Library/Homebrew/extend/os/mac/software_spec.rb | 2 +- Library/Homebrew/fetch.rb | 2 +- Library/Homebrew/github_packages.rb | 2 +- Library/Homebrew/github_releases.rb | 2 +- Library/Homebrew/global.rb | 2 +- Library/Homebrew/installed_dependents.rb | 2 +- Library/Homebrew/language/java.rb | 9 ++++++++- Library/Homebrew/livecheck/error.rb | 2 +- Library/Homebrew/migrator.rb | 2 +- Library/Homebrew/missing_formula.rb | 2 +- Library/Homebrew/release_notes.rb | 2 +- Library/Homebrew/rubocops/deprecate_disable.rb | 2 +- Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/standalone.rb | 2 +- Library/Homebrew/startup.rb | 2 +- Library/Homebrew/startup/sorbet.rb | 2 +- 36 files changed, 51 insertions(+), 40 deletions(-) diff --git a/Library/Homebrew/api/versions.rb b/Library/Homebrew/api/versions.rb index 91e4d1e55b..0f3a9619d2 100644 --- a/Library/Homebrew/api/versions.rb +++ b/Library/Homebrew/api/versions.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/cask/artifact/artifact.rb b/Library/Homebrew/cask/artifact/artifact.rb index 5bfe30d8bd..705cc4d18a 100644 --- a/Library/Homebrew/cask/artifact/artifact.rb +++ b/Library/Homebrew/cask/artifact/artifact.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true require "cask/artifact/moved" diff --git a/Library/Homebrew/cask/artifact/uninstall.rb b/Library/Homebrew/cask/artifact/uninstall.rb index 0d924446de..a91efd2fa8 100644 --- a/Library/Homebrew/cask/artifact/uninstall.rb +++ b/Library/Homebrew/cask/artifact/uninstall.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "cask/artifact/abstract_uninstall" diff --git a/Library/Homebrew/cask/artifact/zap.rb b/Library/Homebrew/cask/artifact/zap.rb index 80485f23d6..eadc014618 100644 --- a/Library/Homebrew/cask/artifact/zap.rb +++ b/Library/Homebrew/cask/artifact/zap.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "cask/artifact/abstract_uninstall" diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index 0aba27727d..1956cc4453 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "optparse" diff --git a/Library/Homebrew/cask/dsl/version.rb b/Library/Homebrew/cask/dsl/version.rb index af78f03089..eb1ea6fe04 100644 --- a/Library/Homebrew/cask/dsl/version.rb +++ b/Library/Homebrew/cask/dsl/version.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Cask diff --git a/Library/Homebrew/cask/utils.rb b/Library/Homebrew/cask/utils.rb index 59e6f4340f..23e52b91c8 100644 --- a/Library/Homebrew/cask/utils.rb +++ b/Library/Homebrew/cask/utils.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "utils/user" diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index e83e0229a7..5fb2599601 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "formula" diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index e1a839779a..cfd57f019e 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index 629ada5ecd..a03927cd48 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "extend/ENV" diff --git a/Library/Homebrew/extend/module.rb b/Library/Homebrew/extend/module.rb index 66d0259f41..91264a1498 100644 --- a/Library/Homebrew/extend/module.rb +++ b/Library/Homebrew/extend/module.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true class Module diff --git a/Library/Homebrew/extend/on_os.rb b/Library/Homebrew/extend/on_os.rb index 5bf551fe59..aacadd608e 100644 --- a/Library/Homebrew/extend/on_os.rb +++ b/Library/Homebrew/extend/on_os.rb @@ -1,21 +1,25 @@ -# typed: true +# typed: strict # frozen_string_literal: true module OnOS + extend T::Sig + # Block only executed on macOS. No-op on Linux. #
on_macos do
   # # Do something Mac-specific
   # end
+ sig { params(block: T.proc.void).void } def on_macos(&block) - raise "No block content defined for 'on_macos' block" unless block + raise "No block content defined for 'on_macos' block" unless T.unsafe(block) end # Block only executed on Linux. No-op on macOS. #
on_linux do
   # # Do something Linux-specific
   # end
+ sig { params(block: T.proc.void).void } def on_linux(&block) - raise "No block content defined for 'on_linux' block" unless block + raise "No block content defined for 'on_linux' block" unless T.unsafe(block) end end diff --git a/Library/Homebrew/extend/os/linux/api/analytics.rb b/Library/Homebrew/extend/os/linux/api/analytics.rb index d5e513328f..f41eecab6d 100644 --- a/Library/Homebrew/extend/os/linux/api/analytics.rb +++ b/Library/Homebrew/extend/os/linux/api/analytics.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: strict # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/extend/os/linux/api/bottle.rb b/Library/Homebrew/extend/os/linux/api/bottle.rb index 9cc5499ec7..a4330800e0 100644 --- a/Library/Homebrew/extend/os/linux/api/bottle.rb +++ b/Library/Homebrew/extend/os/linux/api/bottle.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: strict # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/extend/os/linux/api/formula.rb b/Library/Homebrew/extend/os/linux/api/formula.rb index 766bb9fcde..64cf0f5998 100644 --- a/Library/Homebrew/extend/os/linux/api/formula.rb +++ b/Library/Homebrew/extend/os/linux/api/formula.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: strict # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/std.rb b/Library/Homebrew/extend/os/linux/extend/ENV/std.rb index 79dba61cb4..76d564cd59 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/std.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/std.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Stdenv diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb index 19c8de1fbf..27b0a292a4 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Superenv diff --git a/Library/Homebrew/extend/os/linux/on_os.rb b/Library/Homebrew/extend/os/linux/on_os.rb index 433d8b111b..4373a45ab2 100644 --- a/Library/Homebrew/extend/os/linux/on_os.rb +++ b/Library/Homebrew/extend/os/linux/on_os.rb @@ -1,9 +1,9 @@ -# typed: true +# typed: strict # frozen_string_literal: true module OnOS def on_linux(&block) - raise "No block content defined for 'on_linux' block" unless block + raise "No block content defined for 'on_linux' block" unless T.unsafe(block) yield end diff --git a/Library/Homebrew/extend/os/mac/language/java.rb b/Library/Homebrew/extend/os/mac/language/java.rb index d7fe99ae3a..3e8192c470 100644 --- a/Library/Homebrew/extend/os/mac/language/java.rb +++ b/Library/Homebrew/extend/os/mac/language/java.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true module Language diff --git a/Library/Homebrew/extend/os/mac/on_os.rb b/Library/Homebrew/extend/os/mac/on_os.rb index e3f71dbd10..78759c1a9d 100644 --- a/Library/Homebrew/extend/os/mac/on_os.rb +++ b/Library/Homebrew/extend/os/mac/on_os.rb @@ -1,9 +1,9 @@ -# typed: true +# typed: strict # frozen_string_literal: true module OnOS def on_macos(&block) - raise "No block content defined for 'on_macos' block" unless block + raise "No block content defined for 'on_macos' block" unless T.unsafe(block) yield end diff --git a/Library/Homebrew/extend/os/mac/software_spec.rb b/Library/Homebrew/extend/os/mac/software_spec.rb index f365951271..c5f5d6cb72 100644 --- a/Library/Homebrew/extend/os/mac/software_spec.rb +++ b/Library/Homebrew/extend/os/mac/software_spec.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true # The Library/Homebrew/extend/os/software_spec.rb conditional logic will need to be more nuanced diff --git a/Library/Homebrew/fetch.rb b/Library/Homebrew/fetch.rb index ea44555561..28244def2a 100644 --- a/Library/Homebrew/fetch.rb +++ b/Library/Homebrew/fetch.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index 73535ee1d1..d3e18baa0a 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "utils/curl" diff --git a/Library/Homebrew/github_releases.rb b/Library/Homebrew/github_releases.rb index ae97fba4cb..e59d268991 100644 --- a/Library/Homebrew/github_releases.rb +++ b/Library/Homebrew/github_releases.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "utils/github" diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 15454796e1..f6303e7bbe 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require_relative "startup" diff --git a/Library/Homebrew/installed_dependents.rb b/Library/Homebrew/installed_dependents.rb index 6ada972f93..a0dabc58b7 100644 --- a/Library/Homebrew/installed_dependents.rb +++ b/Library/Homebrew/installed_dependents.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "cask_dependent" diff --git a/Library/Homebrew/language/java.rb b/Library/Homebrew/language/java.rb index bea3b6fd92..c7ffdffd7c 100644 --- a/Library/Homebrew/language/java.rb +++ b/Library/Homebrew/language/java.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true module Language @@ -6,6 +6,9 @@ module Language # # @api public module Java + extend T::Sig + + sig { params(version: T.nilable(String)).returns(T.nilable(Formula)) } def self.find_openjdk_formula(version = nil) can_be_newer = version&.end_with?("+") version = version.to_i @@ -27,19 +30,23 @@ module Language end private_class_method :find_openjdk_formula + sig { params(version: T.nilable(String)).returns(T.nilable(Pathname)) } def self.java_home(version = nil) find_openjdk_formula(version)&.opt_libexec end + sig { params(version: T.nilable(String)).returns(String) } def self.java_home_shell(version = nil) java_home(version).to_s end private_class_method :java_home_shell + sig { params(version: T.nilable(String)).returns({ JAVA_HOME: String }) } def self.java_home_env(version = nil) { JAVA_HOME: java_home_shell(version) } end + sig { params(version: T.nilable(String)).returns({ JAVA_HOME: String }) } def self.overridable_java_home_env(version = nil) { JAVA_HOME: "${JAVA_HOME:-#{java_home_shell(version)}}" } end diff --git a/Library/Homebrew/livecheck/error.rb b/Library/Homebrew/livecheck/error.rb index a10875551b..8cbd8ff28e 100644 --- a/Library/Homebrew/livecheck/error.rb +++ b/Library/Homebrew/livecheck/error.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true module Homebrew diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index 2f47a25a04..ee60d5e242 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "lock_file" diff --git a/Library/Homebrew/missing_formula.rb b/Library/Homebrew/missing_formula.rb index 1edc0f3375..c2bfa50f6e 100644 --- a/Library/Homebrew/missing_formula.rb +++ b/Library/Homebrew/missing_formula.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "formulary" diff --git a/Library/Homebrew/release_notes.rb b/Library/Homebrew/release_notes.rb index c7d9247468..a5446fd1fd 100644 --- a/Library/Homebrew/release_notes.rb +++ b/Library/Homebrew/release_notes.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true # Helper functions for generating release notes. diff --git a/Library/Homebrew/rubocops/deprecate_disable.rb b/Library/Homebrew/rubocops/deprecate_disable.rb index 140e75e244..53c714123a 100644 --- a/Library/Homebrew/rubocops/deprecate_disable.rb +++ b/Library/Homebrew/rubocops/deprecate_disable.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "rubocops/extend/formula" diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 7312097d3a..392296ebad 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "resource" diff --git a/Library/Homebrew/standalone.rb b/Library/Homebrew/standalone.rb index cb540077a1..865191d96b 100644 --- a/Library/Homebrew/standalone.rb +++ b/Library/Homebrew/standalone.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true # This file should be the first `require` in all entrypoints outside the `brew` environment. diff --git a/Library/Homebrew/startup.rb b/Library/Homebrew/startup.rb index d08f5420cf..5ab9e3d56d 100644 --- a/Library/Homebrew/startup.rb +++ b/Library/Homebrew/startup.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true # This file should be the first `require` in all entrypoints of `brew`. diff --git a/Library/Homebrew/startup/sorbet.rb b/Library/Homebrew/startup/sorbet.rb index 6005bbe088..ea21e75807 100644 --- a/Library/Homebrew/startup/sorbet.rb +++ b/Library/Homebrew/startup/sorbet.rb @@ -1,4 +1,4 @@ -# typed: true +# typed: strict # frozen_string_literal: true if ENV["HOMEBREW_SORBET_RUNTIME"]