Skip to content

PYTHON-6025 Consolidate non-IO code in AsyncClientSession/ClientSessi… - #3100

Merged
sleepyStick merged 4 commits into
mongodb:mainfrom
sleepyStick:PYTHON-6025
Oct 7, 2026
Merged

sleepyStick merged 4 commits into
mongodb:mainfrom
sleepyStick:PYTHON-6025

Conversation

@sleepyStick

@sleepyStick sleepyStick commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

…on and _Transaction into shared base classes

PYTHON-6025

Changes in this PR

Test Plan

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?

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.12664% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pymongo/client_session_shared.py 99.02% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@sleepyStick
sleepyStick marked this pull request as ready for review October 6, 2026 22:50
@sleepyStick
sleepyStick requested a review from a team as a code owner October 6, 2026 22:50
@sleepyStick
sleepyStick requested review from blink1073 and a balanced review from Copilot October 6, 2026 22:50

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.

Copilot review overview

🟡 Changes recommended

Inherited public session members will be omitted from the generated API documentation unless inherited-member documentation is enabled.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Consolidates shared synchronous and asynchronous session/transaction logic into generic base classes.

Changes:

  • Adds shared session and transaction base implementations.
  • Retains I/O-specific context management and cleanup in concrete classes.
  • Improves shared connection/server typing and removes obsolete type ignores.
File Description
pymongo/​client_session_shared.py Adds shared base implementations.
pymongo/​asynchronous/​client_session.py Adopts shared bases for async sessions.
pymongo/​synchronous/​client_session.py Adopts shared bases for sync sessions.
pymongo/​typings.py Adds an agnostic server type.
pymongo/​message.py Removes unnecessary type ignores.

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

break


class _AgnosticClientSessionBase(Generic[_ClientT, _ConnectionT, _BoundSessionContextT]):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@sleepyStick did you verify this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm okay maintaining docs in the concrete classes sounds kinda annoying to maintain cuz the logic and the docs would live in two different places so i've opted for using :inherited-members: but lmk if that's the wrong choice

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah the rendered docs look good now!

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@sleepyStick
sleepyStick merged commit 106c81b into mongodb:main Oct 7, 2026
92 of 94 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