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
Enable types in extensions, etc. #15124
Conversation
@@ -37,7 +37,7 @@ def default | |||
|
|||
sig { returns(String) } | |||
def inspect | |||
"#<#{self.class.name}: #{to_a}>" | |||
"#<#{self.class.name}: #{__getobj__}>" |
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.
This uses the explicit delegator method throughout. Since the delegated object is an array, we don't need to invoke to_a
here though.
@@ -52,11 +52,11 @@ def initialize(*args) | |||
end | |||
|
|||
def <<(other) | |||
if other.is_a?(Comparable) | |||
grep(other.class) do |req| | |||
if other.is_a?(Object) && other.is_a?(Comparable) |
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.
Need to type guard Object
here to make .class
type check below.
|
||
class Object | ||
sig { returns(T::Boolean) } | ||
def present?; end |
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.
This is necessary for the return type of PyPi::Package#valid_pypi_package?
to typecheck.
@@ -114,7 +114,7 @@ def arm_family | |||
end | |||
end | |||
|
|||
def intel_family | |||
def intel_family(_family = nil, _cpu_model = nil) |
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.
This needs to match the arity of the same method in Library/Homebrew/extend/os/linux/hardware/cpu.rb
@@ -108,7 +108,7 @@ def prepare_debug_symbols | |||
# Needed to make symlink permissions consistent on macOS and Linux for | |||
# reproducible bottles. | |||
def consistent_reproducible_symlink_permissions! | |||
find do |file| | |||
path.find do |file| |
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.
@@ -161,7 +161,7 @@ def from_url(url, livecheck_strategy: nil, url_provided: false, regex_provided: | |||
# specifies the strategy and contains a `strategy` block | |||
next if (livecheck_strategy != strategy_symbol) || !block_provided | |||
elsif strategy.const_defined?(:PRIORITY) && | |||
!strategy::PRIORITY.positive? && | |||
!strategy.const_get(:PRIORITY).positive? && |
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.
Sorbet doesn't support dynamic constant references using the prior format, but i believe this is equivalent
@name, @version = package_string.split("==") | ||
else | ||
@name = package_string | ||
end |
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.
This is a slight rearrangement to reduce the number of T.must
calls that would otherwise be necessary.
moved_data = false | ||
initdb_run = false | ||
upgraded = false | ||
server_stopped = T.let(false, T::Boolean) |
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.
I almost wonder if we want to implement our own helper for this. I find it gross how verbose and repetitive this is. Something like SORBET_FALSE
might be nicer.
Thanks again @dduugg, nice work! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Enables typing in some
extend
files and elsewhere. After this change, ~15 non-test files will remain untyped.