-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Bump more files to Sorbet typed: strict
#18354
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||
# typed: true # rubocop:todo Sorbet/StrictSigil | ||||||||||
# typed: strict | ||||||||||
# frozen_string_literal: true | ||||||||||
|
||||||||||
require "utils/shell" | ||||||||||
|
@@ -191,6 +191,7 @@ def check_elisp_root(share, name) | |||||||||
EOS | ||||||||||
end | ||||||||||
|
||||||||||
sig { params(lib: Pathname, deps: T::Array[Formula]).returns(T.nilable(String)) } | ||||||||||
def check_python_packages(lib, deps) | ||||||||||
return unless lib.directory? | ||||||||||
|
||||||||||
|
@@ -250,6 +251,7 @@ def check_shim_references(prefix) | |||||||||
EOS | ||||||||||
end | ||||||||||
|
||||||||||
sig { params(prefix: Pathname, plist: Pathname).returns(T.nilable(String)) } | ||||||||||
def check_plist(prefix, plist) | ||||||||||
return unless prefix.directory? | ||||||||||
|
||||||||||
|
@@ -412,7 +414,7 @@ def check_binary_arches(formula) | |||||||||
|
||||||||||
sig { void } | ||||||||||
def audit_installed | ||||||||||
@new_formula ||= false | ||||||||||
@new_formula ||= T.let(false, T.nilable(T::Boolean)) | ||||||||||
|
||||||||||
problem_if_output(check_manpages) | ||||||||||
problem_if_output(check_infopages) | ||||||||||
|
@@ -442,8 +444,9 @@ def relative_glob(dir, pattern) | |||||||||
File.directory?(dir) ? Dir.chdir(dir) { Dir[pattern] } : [] | ||||||||||
end | ||||||||||
|
||||||||||
sig { params(file: T.any(Pathname, String), objdump: String).returns(T::Boolean) } | ||||||||||
def cpuid_instruction?(file, objdump = "objdump") | ||||||||||
@instruction_column_index ||= {} | ||||||||||
Comment on lines
+447
to
448
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||
@instruction_column_index ||= T.let({}, T.nilable(T::Hash[String, T.untyped])) | ||||||||||
@instruction_column_index[objdump] ||= begin | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think? |
||||||||||
objdump_version = Utils.popen_read(objdump, "--version") | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
# typed: true # rubocop:todo Sorbet/StrictSigil | ||||||
# typed: strict | ||||||
# frozen_string_literal: true | ||||||
|
||||||
require "cli/parser" | ||||||
|
@@ -7,6 +7,14 @@ | |||||
module Homebrew | ||||||
# Helper module for printing help output. | ||||||
module Help | ||||||
sig { | ||||||
params( | ||||||
cmd: T.nilable(String), | ||||||
empty_argv: T::Boolean, | ||||||
usage_error: T.nilable(String), | ||||||
remaining_args: T.nilable(T::Array[String]) | ||||||
).void | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
feels nicer if possible given the default parameter is |
||||||
} | ||||||
def self.help(cmd = nil, empty_argv: false, usage_error: nil, remaining_args: []) | ||||||
if cmd.nil? | ||||||
# Handle `brew` (no arguments). | ||||||
|
@@ -39,6 +47,13 @@ def self.help(cmd = nil, empty_argv: false, usage_error: nil, remaining_args: [] | |||||
exit 0 | ||||||
end | ||||||
|
||||||
sig { | ||||||
params( | ||||||
cmd: String, | ||||||
path: Pathname, | ||||||
remaining_args: T.nilable(T::Array[String]), | ||||||
).returns(String) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
feels nicer if possible given there's no default parameter |
||||||
} | ||||||
def self.command_help(cmd, path, remaining_args:) | ||||||
# Only some types of commands can have a parser. | ||||||
output = if Commands.valid_internal_cmd?(cmd) || | ||||||
|
@@ -58,25 +73,34 @@ def self.command_help(cmd, path, remaining_args:) | |||||
end | ||||||
private_class_method :command_help | ||||||
|
||||||
sig { | ||||||
params( | ||||||
path: Pathname, | ||||||
remaining_args: T.nilable(T::Array[String]) | ||||||
).returns(T.nilable(String)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
def self.parser_help(path, remaining_args:) | ||||||
# Let OptionParser generate help text for commands which have a parser. | ||||||
cmd_parser = CLI::Parser.from_cmd_path(path) | ||||||
return unless cmd_parser | ||||||
return unless remaining_args | ||||||
|
||||||
# Try parsing arguments here in order to show formula options in help output. | ||||||
cmd_parser.parse(remaining_args, ignore_invalid_options: true) | ||||||
cmd_parser.generate_help_text | ||||||
end | ||||||
private_class_method :parser_help | ||||||
|
||||||
sig { params(path: Pathname).returns(T::Array[T.nilable(String)]) } | ||||||
def self.command_help_lines(path) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
path.read | ||||||
.lines | ||||||
.grep(/^#:/) | ||||||
.map { |line| line.slice(2..-1).delete_prefix(" ") } | ||||||
.map { |line| line.slice(2..-1)&.delete_prefix(" ") } | ||||||
end | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
means it'll be |
||||||
private_class_method :command_help_lines | ||||||
|
||||||
sig { params(path: Pathname).returns(T.nilable(String)) } | ||||||
def self.comment_help(path) | ||||||
# Otherwise read #: lines from the file. | ||||||
help_lines = command_help_lines(path) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't feel strongly but this format makes more sense to me when the variable's reused below so the definition is not "hidden".