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

activemodel: signature updates #739

Merged

Conversation

hjwylde
Copy link
Contributor

@hjwylde hjwylde commented Dec 6, 2024

Split from #735 to be smaller. Type signature updates for invalid signatures in activemodel, one is due to the block being marked as required, but it should be optional. The other (delete) is updated to match the method declaration (see https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-delete).

Copy link

github-actions bot commented Dec 6, 2024

@hjwylde Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

activemodel

You changed RBS files for an existing gem.
You need to get approval from the reviewers of this gem.

@hibariya, @ksss, @tk0miya, please review this pull request.
If this change is acceptable, please make a review comment including APPROVE from here.
Screen Shot 2024-03-19 at 14 13 36

After that, the PR author or the reviewers can merge this PR.
Just comment /merge to merge this PR.

# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
def delete: (untyped key, ?untyped type, **untyped) -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

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

The type and options arguments were added in v6.1.

refs: rails/rails#32313

Therefore this change should be applied above 6.1 and above.
Please move this method to activermodel-6.0.rbs from activemodel-generated.rbs. After that, please add a new version of #delete to activemodel/7.0/activemodel-7.0.rbs and activemodel/7.1/activemodel-7.1.rbs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, out of curiosity, how does this work with 6.1 then? Will 6.1 use the types from 6.0, and is this acceptable for now, or should a directory for 6.1 be added?

Copy link
Contributor

Choose a reason for hiding this comment

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

6.x users will use the types for 6.0. So it's better to add a new type to the 6.1 directory. But Rails-6.1 is now outdated and not supported. Personally, it's not too late to add it after somebody wants it.

Copy link
Contributor Author

@hjwylde hjwylde Dec 13, 2024

Choose a reason for hiding this comment

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

Thanks for the check! I've fixed this up in the 6.0 file for now, I don't have an issue with this either, and if someone does need it then it can be added to 6.1 as you say.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +382 to +372
# Add a new type to the registry, allowing it to be gotten through ActiveModel::Type#lookup
def self.register: (untyped type_name, ?untyped? klass, **untyped options) ?{ () -> untyped } -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

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

@hjwylde hjwylde force-pushed the hjwylde/activemodel-signature-updates branch from a5a4451 to 03df0ff Compare December 13, 2024 01:47
Copy link
Contributor

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

APPROVE

Copy link

Thanks for your review, @tk0miya!

@hjwylde, @tk0miya This PR is ready to be merged.
Just comment /merge to merge this PR.

@hjwylde
Copy link
Contributor Author

hjwylde commented Dec 13, 2024

/merge

@github-actions github-actions bot merged commit 400a2ec into ruby:main Dec 13, 2024
6 checks passed
@hjwylde hjwylde deleted the hjwylde/activemodel-signature-updates branch December 13, 2024 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants