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

Strict type go_modules #10109

Merged
merged 3 commits into from
Jul 3, 2024
Merged

Strict type go_modules #10109

merged 3 commits into from
Jul 3, 2024

Conversation

JamieMagee
Copy link
Contributor

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 regressions

How will you know you've accomplished your goal?

Tests pass

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@JamieMagee JamieMagee added L: go:modules Golang modules sorbet 🍦 Relates to Sorbet types labels Jun 29, 2024
@JamieMagee JamieMagee requested a review from a team as a code owner June 29, 2024 04:51
@JamieMagee JamieMagee force-pushed the jamiemagee/strict-type-go-modules branch from c692602 to aa5b821 Compare June 29, 2024 04:56
Copy link
Member

@jeffwidman jeffwidman left a 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"...

go_modules/lib/dependabot/go_modules/path_converter.rb Outdated Show resolved Hide resolved
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)
Copy link
Member

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?

Copy link
Contributor Author

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 found BasicObject for argument version7002

and

Method is_a? does not exist on BasicObject (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.

@JamieMagee JamieMagee force-pushed the jamiemagee/strict-type-go-modules branch from 5094a2b to a930d2d Compare July 3, 2024 03:57
@JamieMagee JamieMagee force-pushed the jamiemagee/strict-type-go-modules branch from a930d2d to f9f127b Compare July 3, 2024 15:50
@amazimbe amazimbe merged commit 17fe8bf into main Jul 3, 2024
82 checks passed
@amazimbe amazimbe deleted the jamiemagee/strict-type-go-modules branch July 3, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: go:modules Golang modules sorbet 🍦 Relates to Sorbet types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants