-
Notifications
You must be signed in to change notification settings - Fork 122
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
Avoid a deprecation warning on Ruby 3.4 with the uri gem #2026
Conversation
See the added comment for a detailed explanation
I openend a PR to tapioca, which needs the same change: Shopify/tapioca#2026
# On earlier versions of the uri gem, the RFC2396_PARSER constant doesn't exist, so it needs some special | ||
# handling to select a parser that doesn't emit deprecations. While it was backported to Ruby 3.1, users may | ||
# have the uri gem in their own bundle and thus not use a compatible version. | ||
PARSER = T.let(const_defined?(:RFC2396_PARSER) ? RFC2396_PARSER : DEFAULT_PARSER, RFC2396_Parser) |
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.
Thank you for the PR. Looks like uri v0.10.0 that defined RFC2396_PARSER
was released in 2020. Do you think it'll be problematic in practice to only use RFC2396_PARSER.escape
?
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.
The constant has only been introduced very recently: https://github.com/ruby/uri/releases/tag/v0.13.1
Do you think it'll be problematic in practice to only use RFC2396_PARSER.escape
No. It's what is being used for ages in gems already and there is no alternative. To be honest, I have no idea why these emit a deprecation in the first place. The rack folks deem this ok: rack/rack#2242 and rack/rack#2248
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.
If the constant is new I think it's good to hold off on using it exclusively as you mentioned in the description.
# On earlier versions of the uri gem, the RFC2396_PARSER constant doesn't exist, so it needs some special | ||
# handling to select a parser that doesn't emit deprecations. While it was backported to Ruby 3.1, users may | ||
# have the uri gem in their own bundle and thus not use a compatible version. | ||
PARSER = T.let(const_defined?(:RFC2396_PARSER) ? RFC2396_PARSER : DEFAULT_PARSER, RFC2396_Parser) |
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.
If the constant is new I think it's good to hold off on using it exclusively as you mentioned in the description.
I openend a PR to tapioca, which needs the same change: Shopify/tapioca#2026
I openend a PR to tapioca, which needs the same change: Shopify/tapioca#2026
Motivation
Avoid a deprecation warning on ruby 3.4 with the uri gem.
Implementation
uri
for Ruby 3.4 switched the default parser from RFC2396 to RFC3986. The new parser emits a deprecationwarning on a few methods and delegates them to RFC2396, namely
extract
/make_regexp
/escape
/unescape
.On earlier versions of the uri gem, the RFC2396_PARSER constant doesn't exist, so it needs some special
handling to select a parser that doesn't emit deprecations. While it was backported to Ruby 3.1, users may
have the uri gem in their own bundle and thus not use a compatible version.
Additional info:
Tests
Not needed. You can verify this yourself by doing the following:
gem "uri", github: "ruby/uri"
to the gemfileRUBYOPT="-w" bundle exec rake test TEST=spec/tapioca/gem/pipeline_spec.rb TESTOPTS="--name=/location/"