-
Notifications
You must be signed in to change notification settings - Fork 743
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
Fix Ruby 2.7 keyword parameter deprecation warning #1597
Fix Ruby 2.7 keyword parameter deprecation warning #1597
Conversation
f7f2bd2
to
53d3faf
Compare
@@ -42,8 +42,8 @@ def self.disable_escape! | |||
end | |||
|
|||
# Format a token stream. Delegates to {#format}. | |||
def self.format(tokens, *a, &b) | |||
new(*a).format(tokens, &b) | |||
def self.format(tokens, *args, **kwargs, &b) |
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 what pattern is this. It does seem like opts
is actually a Hash in some cases?
html_inline.rb: def initialize(theme)
html_legacy.rb: def initialize(opts={})
html_line_table.rb: def initialize(formatter, opts={})
html_linewise.rb: def initialize(formatter, opts={})
html_pygments.rb: def initialize(inner, css_class='codehilite')
html_table.rb: def initialize(inner, opts={})
null.rb: def initialize(*)
terminal256.rb: def initialize(theme = Themes::ThankfulEyes.new)
terminal256.rb: def initialize(style)
terminal256.rb: def initialize(*) end
tex.rb: def initialize(opts={})
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.
Thanks for the heads-up!
The arguments passed to .format
should be the same ones passed to the initializer of the class - which is left completely free and is not always an options hash. Unlike lexers, formatters are solidified in code - and don't need fancy CGI-like parsing. In any case, this method should probably just blindly pass through everything - positional, keywords, and block arguments - to the constructor.
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.
@jneen Good to hear from you! Ok, I kept going back and forth because I wasn't sure what the actual intent. Thanks for the response! I hope you are well.
53d3faf
to
d81c9c6
Compare
This fixes the warning: ``` lib/rouge/formatter.rb:46: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call ``` More details: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
d81c9c6
to
b9d20a3
Compare
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.
@jneen Looks good to me. Are you happy for this to be merged?
@jneen Gentle nudge 😸. Is it possible to have this merged? 🙏 |
Seems like this has had plenty of eyes and no concerns so far. I'm merging. Thanks @stanhu |
This fixes the warning: ``` lib/rouge/formatter.rb:46: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call ``` More details: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
This fixes the warning:
More details:
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/