Skip to content

Conversation

@NoahStapp
Copy link
Contributor

@NoahStapp NoahStapp commented Jan 29, 2026

[PYTHON-1357]

Changes in this PR

  • Refactor code shared between (Async)Cursor and (Async)CommandCursor into abstracted base classes.
  • _AgnosticCursorBase is the top-level base class that is IO-agnostic and shared between both async and sync cursor implementations.
  • _AsyncCursorBase and _CursorBase are async and sync-specific base classes that contain code shared between cursor implementations in either the async or sync APIs.
  • These changes must not introduce any user-facing changes.
  • Two type hints differ between Cursor and CommandCursor: Cursor.cursor_id -> Optional[int] and Cursor.address -> Optional[tuple[str, Any]], while CommandCursor.cursor_id -> int and CommandCursor.address -> Optional[_Address]. Do we count these type hint changes as user-facing, public API changes? Note that _Address = Tuple[str, Optional[int]].
  • This is a refactor of identical or nearly identical common code only. Some existing code such as _send_message is similar between the cursor types but has enough differences to be effectively separate implementations.

Test Plan

Run against the 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?

@NoahStapp NoahStapp marked this pull request as ready for review January 29, 2026 21:48
@NoahStapp NoahStapp requested a review from a team as a code owner January 29, 2026 21:48
@NoahStapp NoahStapp requested a review from Jibola January 29, 2026 21:48
@NoahStapp NoahStapp requested a review from blink1073 January 30, 2026 14:55
@blink1073
Copy link
Member

Two type hints differ between Cursor and CommandCursor: Cursor.cursor_id -> Optional[int] and Cursor.address -> Optional[tuple[str, Any]], while CommandCursor.cursor_id -> int and CommandCursor.address -> Optional[_Address]. Do we count these type hint changes as user-facing, public API changes? Note that _Address = Tuple[str, Optional[int]].

I think the new types are fine. Existing usages will still work.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

2 participants