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

Chore(WIN-2123): Handle kwargs properly for Ruby 3 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aamirsahmad
Copy link

@aamirsahmad aamirsahmad commented Oct 31, 2024

  • Update class methods (perform, call, to_proc) to explicitly handle keyword arguments
  • Add **kwargs parameter to handle keyword arguments separately from positional args
  • Fix deprecation warnings related to keyword argument handling
  • Maintain backward compatibility while preparing for Ruby 3.0

This change addresses the Ruby 2.7 deprecation warning: "Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call"

Testing

@aamirsahmad aamirsahmad force-pushed the aamir/WIN-2123-address-deprecation-warning-active-operation branch from 369e08a to 3661bfc Compare November 1, 2024 16:35
Comment on lines +33 to +34
when :keyreq, :key
input name, type: :keyword, required: (type == :keyreq)

Choose a reason for hiding this comment

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

What is this change and why was it required?

Copy link
Author

Choose a reason for hiding this comment

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

Previously the API was method(*args), now it supports both method(*args, **kwargs) so this is to ensure positional arg is required and kwargs aren't

@@ -130,15 +130,19 @@ def inherited(subclass)
def initialize(*args)
arity = self.class.inputs.count(&:positional?)
arguments = args.shift(arity)
attributes = args.last.kind_of?(Hash) ? args.pop : {}
attributes = if args.last.is_a?(Hash)
args.pop.transform_keys(&:to_sym)

Choose a reason for hiding this comment

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

Why do we need to do symbols?

Copy link
Author

Choose a reason for hiding this comment

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

I think some test cases were failing and this fixed them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants