Repository navigation
PYTHON-6026 Consolidate non-IO code in Async*ChangeStream/*ChangeStre… - #3105
Conversation
…am into shared base class
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🟢 Approval recommended
The refactor preserves existing behavior, and the multiple-inheritance dispatch correctly retains cluster-specific options.
0 open findings
What changed in this PR
Consolidates synchronous and asynchronous change-stream logic into a shared internal base while preserving API-specific I/O behavior.
Changes:
- Moves validation, resume handling, and option construction into shared classes.
- Adds shared sync/async database typings.
- Includes inherited members in generated API documentation.
| File | Description |
|---|---|
pymongo/change_stream_shared.py |
Adds shared non-I/O change-stream implementation. |
pymongo/asynchronous/change_stream.py |
Adopts shared bases for asynchronous streams. |
pymongo/synchronous/change_stream.py |
Mirrors shared-base adoption for synchronous streams. |
pymongo/typings.py |
Adds agnostic database typing support. |
doc/api/pymongo/change_stream.rst |
Documents inherited synchronous members. |
doc/api/pymongo/asynchronous/change_stream.rst |
Documents inherited asynchronous members. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
| """Does this cursor have the potential to return more data? | ||
|
|
||
| .. note:: Even if :attr:`alive` is ``True``, :meth:`next` can raise | ||
| :exc:`StopIteration` and :meth:`try_next` can return ``None``. |
There was a problem hiding this comment.
This is only accurate for async
| """The internal abstract base class for change stream cursors. | ||
|
|
||
| Should not be called directly by application developers. Use | ||
| :meth:`pymongo.collection.Collection.watch`, | ||
| :meth:`pymongo.database.Database.watch`, or | ||
| :meth:`pymongo.mongo_client.MongoClient.watch` instead. | ||
|
|
||
| .. versionadded:: 3.6 | ||
| .. seealso:: The MongoDB documentation on `changeStreams <https://mongodb.com/docs/manual/changeStreams/>`_. | ||
| """ |
There was a problem hiding this comment.
Since this is now private maybe just
"""
Shared base for the sync and async ChangeStream classes.
"""
| self._closed = False | ||
| self._timeout = self._target._timeout | ||
| self._show_expanded_events = show_expanded_events | ||
|
|
There was a problem hiding this comment.
Maybe a comment here about Any:
# Any: the async and sync _AggregationCommand classes are not related by
# inheritance, so no single return type is valid for both drivers.
There was a problem hiding this comment.
i modified your suggested comment to be more concise but otherwise added in 1934b40
…am into shared base class
PYTHON-6026
Changes in this PR
Test Plan
Checklist
Checklist for Author
Checklist for Reviewer