Skip to content

Conversation

@koic
Copy link
Contributor

@koic koic commented May 2, 2025

This PR suppresses the following Ruby 3.4's warning. e.g.;

$ ruby -v
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24]
$ RUBYOPT=-w bundle exec rspec spec/langchain/loader_spec.rb
/Users/koic/src/github.com/patterns-ai-core/langchainrb/lib/langchain/loader.rb:94:
warning: URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.

Compatibility with Ruby 3.1 supported by Langchain.rb is preserved.

This PR suppresses the following Ruby 3.4's warning. e.g.;

```console
$ ruby -v
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24]
$ RUBYOPT=-w bundle exec rspec spec/langchain/loader_spec.rb
/Users/koic/src/github.com/patterns-ai-core/langchainrb/lib/langchain/loader.rb:94:
warning: URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.
```

Compatibility with Ruby 3.1 supported by Langchain.rb is preserved.
@koic koic force-pushed the suppress_ruby34_url_parser_warning branch from 0381dcb to f7a1241 Compare May 14, 2025 02:15
@andreibondarev andreibondarev merged commit dd29cdc into patterns-ai-core:main May 16, 2025
6 checks passed
@koic koic deleted the suppress_ruby34_url_parser_warning branch May 16, 2025 02:22
escaped_url = URI::DEFAULT_PARSER.escape(unescaped_url)

# Ensure compatibility with `URI::RFC2396_PARSER` (Ruby 3.4+) and `URI::DEFAULT_PARSER` (<= 3.3).
uri_parser = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of doing this in a few different places -- it would probably make sense to define it as a Util and obfuscate the actual class used: URI::RFC2396_PARSER or URI::DEFAULT_PARSER?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense! I opened PR #994.

koic added a commit to koic/langchainrb that referenced this pull request May 17, 2025
This refactoring moves compatibility handling for `URI::RFC2396_PARSER` (Ruby 3.4+)
and `URI::DEFAULT_PARSER` (<= 3.3) into `Langchain::Utils::UriParser`.

Follow-up to patterns-ai-core#980 (comment).
koic added a commit to koic/langchainrb that referenced this pull request May 17, 2025
This refactoring moves compatibility handling for `URI::RFC2396_PARSER` (Ruby 3.4+)
and `URI::DEFAULT_PARSER` (<= 3.3) into `Langchain::Utils::UriParser`.

Follow-up to patterns-ai-core#980 (comment).
koic added a commit to koic/langchainrb that referenced this pull request May 17, 2025
This refactoring moves compatibility handling for `URI::RFC2396_PARSER` (Ruby 3.4+)
and `URI::DEFAULT_PARSER` (<= 3.3) into `Langchain::Utils::UriParser`.

Follow-up to patterns-ai-core#980 (comment).
koic added a commit to koic/langchainrb that referenced this pull request Jun 12, 2025
This refactoring moves compatibility handling for `URI::RFC2396_PARSER` (Ruby 3.4+)
and `URI::DEFAULT_PARSER` (<= 3.3) into `Langchain::Utils::UriParser`.

Follow-up to patterns-ai-core#980 (comment).
littlechu pushed a commit to littlechu/openai_assistant_fix that referenced this pull request Jul 8, 2025
This PR suppresses the following Ruby 3.4's warning. e.g.;

```console
$ ruby -v
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24]
$ RUBYOPT=-w bundle exec rspec spec/langchain/loader_spec.rb
/Users/koic/src/github.com/patterns-ai-core/langchainrb/lib/langchain/loader.rb:94:
warning: URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.
```

Compatibility with Ruby 3.1 supported by Langchain.rb is preserved.

Co-authored-by: Andrei Bondarev <[email protected]>
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