Skip to content

PYTHON-3445 Improve documentation for with_options #1074

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 5 commits into from
Oct 12, 2022

Conversation

juliusgeo
Copy link
Contributor

No description provided.

@@ -162,7 +162,11 @@ def with_options(
>>> db1.read_preference
Primary()
>>> from pymongo import ReadPreference
>>> db2 = db1.with_options(read_preference=ReadPreference.SECONDARY)
>>> db2 = db1.with_options(
read_preference=Secondary(tag_sets=[..]),
Copy link
Member

Choose a reason for hiding this comment

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

We should put actual values in here for demonstration purposes

Copy link
Member

Choose a reason for hiding this comment

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

+1 like:

         >>> from pymongo.read_preferences import Secondary
          >>> db2 = db1.with_options(read_preference=Secondary(tag_sets=[{"node":"analytics"}]))
          >>> db1.read_preference
          Primary()
          >>> db2.read_preference
          Secondary(tag_sets=[{'node': 'analytics'}], max_staleness=-1, hedge=None)

@juliusgeo juliusgeo requested a review from blink1073 October 12, 2022 19:52
read_preference=Secondary([{'node': 'analytics'}]),
write_concern=WriteConcern(w="majority"),
read_concern=ReadConcern(level="majority"),
)
Copy link
Member

Choose a reason for hiding this comment

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

This formatting does not look good in the docs. Let's just remove write_concern and read_concern so it can fit on one line: https://pymongo--1074.org.readthedocs.build/en/1074/api/pymongo/database.html#pymongo.database.Database.with_options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@juliusgeo juliusgeo requested a review from ShaneHarvey October 12, 2022 20:25
@juliusgeo juliusgeo merged commit 438539e into mongodb:master Oct 12, 2022
@@ -162,11 +162,11 @@ def with_options(
>>> db1.read_preference
Primary()
>>> from pymongo import ReadPreference
Copy link
Member

Choose a reason for hiding this comment

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

Sorry this is still missing the import for Secondary

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.

None yet

3 participants