Skip to content

PYTHON-5421 Make parse_uri() return "options" as a dict rather than _CaseInsensitiveDictionary #2413

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

Merged
merged 7 commits into from
Jul 2, 2025

Conversation

sleepyStick
Copy link
Contributor

@sleepyStick sleepyStick commented Jun 30, 2025

  • Added a function _make_options_case_sensitive that takes in uri options _CaseInsensitiveDictionary and returns it in proper case sensitive plain dict form. Any keys in the original _CaseInsensitiveDictionary that aren't in the set of properly cased option names are put into the plain dict as is.
  • unified tests convert options back to _CaseInsensitiveDictionary for key comparison reasons.
  • parse_uri now returns "options" as a plain dict:
>>> from pymongo.uri_parser import parse_uri
>>> options = parse_uri("mongodb://localhost/?retryWrites=true&retryreads=true")["options"]
>>> options
{'retryWrites': True, 'retryReads': True}
>>> type(options)
<class 'dict'>

@sleepyStick sleepyStick marked this pull request as ready for review July 2, 2025 16:18
@sleepyStick sleepyStick requested a review from a team as a code owner July 2, 2025 16:18
@sleepyStick sleepyStick requested a review from aclark4life July 2, 2025 16:18
Copy link
Contributor

@aclark4life aclark4life left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@sleepyStick sleepyStick merged commit 947fbe3 into mongodb:master Jul 2, 2025
78 of 80 checks passed
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

Please add a changelog entry and a ..versionchanged to parse_uri to describe the breaking change. Also, do we have a test that verifies options is returned as a dict and not a custom class?

@aclark4life
Copy link
Contributor

@ShaneHarvey @sleepyStick Sorry I missed that!

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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy