-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
pymongo/database.py
Outdated
@@ -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=[..]), |
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.
We should put actual values in here for demonstration purposes
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.
+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)
pymongo/database.py
Outdated
read_preference=Secondary([{'node': 'analytics'}]), | ||
write_concern=WriteConcern(w="majority"), | ||
read_concern=ReadConcern(level="majority"), | ||
) |
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.
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
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.
Done!
@@ -162,11 +162,11 @@ def with_options( | |||
>>> db1.read_preference | |||
Primary() | |||
>>> from pymongo import ReadPreference |
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.
Sorry this is still missing the import for Secondary
No description provided.