Skip to content
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 some utils/ files to Sorbet typed: strict #19094

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented Jan 14, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

@issyl0 issyl0 marked this pull request as ready for review January 14, 2025 23:45
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go whenever you are! All comments are non-blocking, we can always clean this up post merge.

Comment on lines +171 to 172
!!(config_true?(:analyticsmessage) &&
config_true?(:caskanalyticsmessage) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!!(config_true?(:analyticsmessage) &&
config_true?(:caskanalyticsmessage) &&
return false unless config_true?(:analyticsmessage)
return false unless config_true?(:caskanalyticsmessage)
influx_message_displayed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or something? I presume the issue here is that config_true? can be nil? If so: may make sense to fix that up.

config_true?(:caskanalyticsmessage) &&
influx_message_displayed?
influx_message_displayed?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
influx_message_displayed?)

@@ -97,8 +97,8 @@ def pypi_info(new_version: nil)
sig { returns(String) }
def to_s
if valid_pypi_package?
out = name
out += "[#{extras.join(",")}]" if extras.present?
out = T.must(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing a T.must here feels like it might be nice to enforce in def name and def initialize that it's a String type instead?

out = name
out += "[#{extras.join(",")}]" if extras.present?
out = T.must(name)
out += "[#{extras&.join(",")}]" if extras.present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
out += "[#{extras&.join(",")}]" if extras.present?
if (pypi_extras = extras.presence)
out += "[#{pypi_extras.join(",")}]"
end

@@ -327,12 +328,12 @@ def self.update_python_resources!(formula, version: nil, package_name: nil, extr
# Resolve the dependency tree of all input packages
show_info = !print_only && !silent
ohai "Retrieving PyPI dependencies for \"#{input_packages.join(" ")}\"..." if show_info
found_packages = pip_report(input_packages, python_name:, print_stderr: verbose && show_info)
found_packages = pip_report(input_packages, python_name:, print_stderr: !(verbose && show_info).nil?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
found_packages = pip_report(input_packages, python_name:, print_stderr: !(verbose && show_info).nil?)
print_stderr = !(verbose && show_info).nil?
found_packages = pip_report(input_packages, python_name:, print_stderr:)

# Resolve the dependency tree of excluded packages to prune the above
exclude_packages.delete_if { |package| found_packages.exclude? package }
ohai "Retrieving PyPI dependencies for excluded \"#{exclude_packages.join(" ")}\"..." if show_info
exclude_packages = pip_report(exclude_packages, python_name:, print_stderr: verbose && show_info)
exclude_packages += [Package.new(main_package.name)] unless main_package.nil?
exclude_packages = pip_report(exclude_packages, python_name:, print_stderr: !(verbose && show_info).nil?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exclude_packages = pip_report(exclude_packages, python_name:, print_stderr: !(verbose && show_info).nil?)
print_stderr = !(verbose && show_info).nil?
exclude_packages = pip_report(exclude_packages, python_name:, print_stderr:)

exclude_packages = pip_report(exclude_packages, python_name:, print_stderr: verbose && show_info)
exclude_packages += [Package.new(main_package.name)] unless main_package.nil?
exclude_packages = pip_report(exclude_packages, python_name:, print_stderr: !(verbose && show_info).nil?)
exclude_packages += [Package.new(T.must(main_package.name))] unless main_package.nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exclude_packages += [Package.new(T.must(main_package.name))] unless main_package.nil?
if (main_package_name = main_package&.name)
exclude_packages += [Package.new(main_package_name)]
end

tcsh: "~/.tcshrc",
zsh: "~/.zshrc",
}.freeze,
T::Hash[T.nilable(Symbol), String],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T::Hash[T.nilable(Symbol), String],
T::Hash[Symbol, String],

feels more appropriate?

Comment on lines +47 to +52
T::Hash[T.any(Symbol, String), T.untyped],
T::Array[String],
),
).returns(
[
T::Array[T.any(String, Symbol)], T::Array[String]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this could use either String or Symbol consistently as the Hash keys/first Array values? Maybe outside the scope of this PR.

@@ -152,7 +162,7 @@ def color?
return false if Homebrew::EnvConfig.no_color?
return true if Homebrew::EnvConfig.color?

@stream.tty?
!!@stream&.tty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to avoid the added need for & here if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants