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

Modernize multi-sig generation in DSL compilers #1961

Merged
merged 4 commits into from
Jul 18, 2024

Conversation

paracycle
Copy link
Member

Labelling this as breaking-change since we are removing some methods that used to be publicly exported to DSL compilers.

Motivation

Since Shopify/rbi#284 landed, we have access to a cleaner way to define methods with multiple signatures, but we'd been relying on an older way of doing it via a create_method_with_sigs helper method. This PR cleans this situation up.

Implementation

  1. Updated the implementation of create_method to not define any signatures if a block is passed and the parameters and return_type have not been passed. This allows the block to define all the parameters and different return types explicitly.
  2. Updated all usages of create_method_with_sigs to use the new create_method based mechanism to do multiple signature definitions.
  3. Remove create_method_with_sigs and create_sig methods from the RBI extension methods.

Tests

All existing tests should pass.

@paracycle paracycle added the breaking-change Non-backward compatible change label Jul 17, 2024
@paracycle paracycle requested a review from a team as a code owner July 17, 2024 22:01
@paracycle paracycle requested review from egiurleo and KaanOzkan July 17, 2024 22:01
@paracycle paracycle force-pushed the uk-modernize-multi-sig-generation branch from 93d0c6f to 509864e Compare July 17, 2024 22:21
Copy link
Contributor

@KaanOzkan KaanOzkan left a comment

Choose a reason for hiding this comment

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

I think we also need to bump the rbi version requirement to include the change, v0.1.10

EDIT: We also have #1960 which is bumping it btw

sigs = []

if !block || !parameters.empty? || return_type
# If there is no block, and the params and return type have not been supplied, then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# If there is no block, and the params and return type have not been supplied, then
# If there is no block, and the params and return type have been supplied, then

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should document that multi-sigs will need to supply a block that adds sigs? It might be tough to figure out by looking at this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tbh, we haven't been documenting any of these methods and people have been using the patterns they see being used elsewhere in these files.

So, I don't know how to even start documenting this method and how it works.

RBI::BlockParam.new("block"),
],
)
common_relation_methods_module.create_method(method_name.to_s) do |method|
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change from count to method_name.to_s intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it was, and I actually wanted to do it for other methods as well, but Copilot made many of the changes for me, so I lost steam.

The reason why I want to use method_name.to_s is because it is better for future extension. If there is another method that behaves exactly as count (let's say they add an alias for count), then it will be enough to add that to the where clause, since the method name is dynamic like this.

@paracycle paracycle force-pushed the uk-modernize-multi-sig-generation branch from 509864e to 4ef2b0f Compare July 18, 2024 19:44
@paracycle paracycle enabled auto-merge July 18, 2024 19:45
@paracycle paracycle merged commit c1e7a4d into main Jul 18, 2024
29 checks passed
@paracycle paracycle deleted the uk-modernize-multi-sig-generation branch July 18, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Non-backward compatible change chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants