Skip to content

PYTHON-6022 Consolidate all non-IO code in AsyncCursor/Cursor into _A… - #3033

Open
NoahStapp wants to merge 6 commits into
mongodb:mainfrom
NoahStapp:PYTHON-6022
Open

NoahStapp wants to merge 6 commits into
mongodb:mainfrom
NoahStapp:PYTHON-6022

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

…gnosticCursor

PYTHON-6022

Changes in this PR

See ticket.

Test Plan

Existing tests.

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 Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.24759% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pymongo/cursor_shared.py 92.92% 13 Missing and 8 partials ⚠️

📢 Thoughts on this report? Let us know!

@NoahStapp
NoahStapp marked this pull request as ready for review September 16, 2026 18:12
@NoahStapp
NoahStapp requested a review from a team as a code owner September 16, 2026 18:12
@NoahStapp
NoahStapp requested review from blink1073 and sleepyStick and a lite review from Copilot and removed request for blink1073 September 16, 2026 18:12

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.

🔵 Needs a closer look

The refactor spans shared, synchronous, and asynchronous cursor behavior and warrants final human review.

Pull request overview

Consolidates shared non-I/O cursor behavior into _AgnosticCursor, reducing duplication between synchronous and asynchronous implementations.

Changes:

  • Centralizes cursor configuration, cloning, validation, and utility methods.
  • Updates synchronous and asynchronous cursors to use shared behavior.
  • Centralizes session handling in the agnostic base.
File summaries
File Description
pymongo/synchronous/cursor.py Uses shared cursor logic.
pymongo/synchronous/cursor_base.py Delegates session handling to the shared base.
pymongo/cursor_shared.py Adds the shared cursor implementation.
pymongo/asynchronous/cursor.py Uses shared cursor logic.
pymongo/asynchronous/cursor_base.py Delegates session handling to the shared base.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

Comment thread pymongo/cursor_shared.py
async for doc in collection.find():
print(doc)


@blink1073 blink1073 Sep 16, 2026

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.

Nit, this extra line should be removed

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