-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Strict type go_modules
#10109
Strict type go_modules
#10109
Conversation
c692602
to
aa5b821
Compare
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 skimmed this, and it looks fine to me... I didn't take the time to doublecheck every annotation.
Left a question that I trust you probably got it right, and my question is more "help me understand Sorbet in this context"...
def <=>(other) | ||
result = super(other) | ||
return if result.nil? | ||
return result unless result.zero? | ||
|
||
other = self.class.new(other) unless other.is_a?(Version) | ||
other = self.class.new(other.to_s) unless other.is_a?(Version) |
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.
Was this a bug discovered through the typing exercise?
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.
So the <=>
method comes from kernel.rbi
and is defined as
sig do
params(
other: BasicObject,
)
.returns(T.nilable(Integer))
end
def <=>(other); end
Unfortunately, overriding that directly results in 2 errors:
Expected
T.nilable(T.any(String, Integer, Gem::Version))
but foundBasicObject
for argumentversion
7002
and
Method
is_a?
does not exist onBasicObject
(fix available)7003
I think I could force it to use VersionParameter
to fix both these, but I am not 100% sure if I can do that. This felt like a compromise.
5094a2b
to
a930d2d
Compare
a930d2d
to
f9f127b
Compare
What are you trying to accomplish?
Complete strict sorbet typing
go_modules
Anything you want to highlight for special attention from reviewers?
Also enabled
Sorbet/StrictSigil
to prevent regressionsHow will you know you've accomplished your goal?
Tests pass
Checklist