Skip to content

PYTHON-6012 - Consolidate TopologySettings into a single shared class - #3016

Merged
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6012
Aug 31, 2026
Merged

PYTHON-6012 - Consolidate TopologySettings into a single shared class#3016
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6012

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-6012

Changes in this PR

Refactored ToplogySettings to use a shared generic base class, leaving only Pool and Monitor type info to differ between async and sync.

Test Plan

Existing test suite.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI lite review requested due to automatic review settings August 31, 2026 14:25
@NoahStapp
NoahStapp requested a review from a team as a code owner August 31, 2026 14:25
@NoahStapp
NoahStapp requested a review from aclark4life August 31, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the driver’s TopologySettings implementation to reduce duplication between synchronous and asynchronous clients by extracting shared behavior into a new shared base class, and updates affected tests to import TOPOLOGY_TYPE from its canonical module.

Changes:

  • Introduce pymongo/settings_shared.py with _BaseTopologySettings containing the shared TopologySettings logic.
  • Update sync/async TopologySettings to inherit from the shared base and delegate initialization.
  • Update sync/async client tests to import TOPOLOGY_TYPE from pymongo.topology_description instead of the settings modules.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/test_client.py Update import source for TOPOLOGY_TYPE to match refactor.
test/asynchronous/test_client.py Update import source for TOPOLOGY_TYPE to match refactor.
pymongo/synchronous/settings.py Convert TopologySettings to a thin subclass of the shared base.
pymongo/asynchronous/settings.py Convert TopologySettings to a thin subclass of the shared base.
pymongo/settings_shared.py New shared base class factoring out common TopologySettings behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pymongo/settings_shared.py

@aclark4life aclark4life left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.09091% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pymongo/settings_shared.py 98.95% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@NoahStapp
NoahStapp merged commit 4c6531e into mongodb:main Aug 31, 2026
90 checks passed
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