-
Notifications
You must be signed in to change notification settings - Fork 235
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
Decrease number of deprecation warnings in Ruby 2.7 #496
base: master
Are you sure you want to change the base?
Conversation
@@ -9,7 +9,7 @@ def self.included(base) | |||
|
|||
module ClassMethods | |||
def build(*args) | |||
build!(self, *args).new(*args) # Declarative::Builder#build!. | |||
build!(self, *args, **{}).new(*args) # Declarative::Builder#build!. |
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.
Not sure if this is an appropriate fix, but it seems to work!
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.
Are you guys using Cells' builder features, and if yes, what do your builders look like?
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.
No we are not using them. I just found this by running the tests with ruby 2.7 and the tests still pass for ruby 3 so I think this may work.
constant = name.is_a?(Class) ? name : class_from_cell_name(name) | ||
constant.(*args, **kws, &block) | ||
constant.(*args, &block) |
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.
What warning does removing **kws
resolve for you?
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.
This is the warning we got:
/home/richard/.rvm/gems/ruby-2.7.5/bundler/gems/cells-88796e3a29cb/lib/cell/view_model.rb:67: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/richard/.rvm/gems/ruby-2.7.5/bundler/gems/cells-88796e3a29cb/lib/cell/view_model.rb:31: warning: The called method `cell' is defined here
I was wondering why it wasn't failing with ruby 3 and figured out that those keyword arguments are not used because the instance method cell helper was passing the option as a positional argument anyways (so the kws hash would always be empty in ruby 3).
Overally, I'm very happy you address this as I've been trying to make Cells ready for Ruby 3.0. 🌞 I see a problem, however, in our old signatures: we were allowing all kinds of argument chains such, and maybe a first step would be to define expected arguments. For example, the Are you happy to discuss this approach? |
That sounds like a way better approach than what I was going for! I just wanted to quickly fix those warnings 😅 Having defined expected arguments is definitely better than what we have right now. How do you want to approach this refactoring? I feel like it might lead to breaking other cells-related gems (I'm thinking trailblazer/cells-rails for example). Also it might break some user's cells invocation when they pass the options as a positional right now (however this would be an easy fix for them). |
Komm mal hier her https://trailblazer.zulipchat.com @richardboehme 🍻 |
We experienced some deprecation warnings after upgrading one of our apps to Ruby 2.7.5. This patch removes all deprecation warnings occurring when running the tests of the cells gem.