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

Filter gem RBIs by version during annotations command #1585

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

egiurleo
Copy link
Contributor

@egiurleo egiurleo commented Jul 27, 2023

Motivation

This PR aims to solve the problem of versioning RBIs. Up until now, there is no default way to write RBI for different versions of the same gem. This can lead to confusing issues for Sorbet users where RBIs don't match the version of a gem they're using, and they have to spend time figuring out whether their gem is out of date, whether the RBI is wrong, or if it's even both! Having a way to specify RBI for multiple versions of the same gem would allow people to adopt and use Sorbet without having to go through this hassle.

Implementation

The actual RBI filtering behavior is implemented in the RBI repo. This uses the FilterVersions rewriter during the annotations command to remove parts of the annotation RBI that aren't relevant to a certain gem version.

Tests

I have added a test for this functionality.

@egiurleo egiurleo force-pushed the emily/rbi-versioning branch 3 times, most recently from 0635c79 to b21d9bd Compare January 31, 2024 21:52
@egiurleo egiurleo changed the title [WIP] Filter gem RBIs by version during annotations command Proof of concept: Filter gem RBIs by version during annotations command Jan 31, 2024
@egiurleo egiurleo marked this pull request as ready for review February 2, 2024 21:46
@egiurleo egiurleo requested a review from a team as a code owner February 2, 2024 21:46
@egiurleo egiurleo requested review from andyw8 and Morriar and removed request for a team, andyw8 and Morriar February 2, 2024 21:46
@egiurleo egiurleo marked this pull request as draft February 2, 2024 21:48
@egiurleo egiurleo added the enhancement New feature or request label Feb 21, 2024
@egiurleo egiurleo force-pushed the emily/rbi-versioning branch 2 times, most recently from d8ed7fe to 0ccc549 Compare February 22, 2024 17:38
@egiurleo egiurleo marked this pull request as ready for review February 22, 2024 18:19
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

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

I have a few inline comments, but additionally:

Is this still a "Proof of concept"? I think once we merge this, it will ship in the next release, right?

lib/tapioca/commands/annotations.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/annotations.rb Outdated Show resolved Hide resolved
@egiurleo egiurleo changed the title Proof of concept: Filter gem RBIs by version during annotations command Filter gem RBIs by version during annotations command Jun 26, 2024
@@ -12,6 +12,7 @@ class AnnotationsTest < SpecWithProject

after do
@project.remove!("sorbet/rbi/annotations")
@project.write!("Gemfile", @project.tapioca_gemfile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary to prevent leaking Gemfile changes between tests

The `GemInfo` class is a wrapper around a gem name and verison.
This will make it easier to pass a gem version around, allowing us to filter
RBI annotations by version.
@egiurleo egiurleo merged commit 9f82d57 into main Jun 26, 2024
30 checks passed
@egiurleo egiurleo deleted the emily/rbi-versioning branch June 26, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants