Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ Bug fixes
from it. It now raises :class:`~bson.errors.InvalidId`, and
:meth:`~bson.objectid.ObjectId.is_valid` returns ``False`` for such a string
(`PYTHON-5873`_).
- Fixed the type annotation of the ``let`` argument of
:class:`~pymongo.cursor.Cursor` and
:class:`~pymongo.asynchronous.cursor.AsyncCursor`. It is now
``Optional[Mapping[str, Any]]`` instead of ``Optional[bool]``, matching what
the argument accepts at runtime (`PYTHON-6145`_).

.. _PYTHON-6172: https://jira.mongodb.org/browse/PYTHON-6172
.. _PYTHON-6149: https://jira.mongodb.org/browse/PYTHON-6149
.. _PYTHON-5873: https://jira.mongodb.org/browse/PYTHON-5873
.. _PYTHON-6145: https://jira.mongodb.org/browse/PYTHON-6145

Changes in Version 4.19.0 (2026/10/14)
--------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pymongo/cursor_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def __init__(
comment: Optional[Any] = None,
session: Optional[_AgnosticClientSession] = None,
allow_disk_use: Optional[bool] = None,
let: Optional[bool] = None,
let: Optional[Mapping[str, Any]] = None,
) -> None:
"""Create a new cursor.
Used by a collection's ``find()`` method to iterate over MongoDB query results.
Expand Down
5 changes: 5 additions & 0 deletions test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ImplicitMovie(TypedDict):
from pymongo.operations import DeleteOne, InsertOne, ReplaceOne
from pymongo.read_preferences import ReadPreference
from pymongo.synchronous.collection import Collection
from pymongo.synchronous.cursor import Cursor
from test import IntegrationTest, PyMongoTestCase, client_context

TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "mypy_fails")
Expand Down Expand Up @@ -137,6 +138,10 @@ def to_list(iterable: Iterable[dict[str, Any]]) -> list[dict[str, Any]]:
docs = to_list(cursor)
self.assertTrue(docs)

@only_type_check
def test_cursor_let(self) -> None:
Cursor(self.coll, let={"threshold": 1})

def test_distinct(self) -> None:
self.coll.delete_many({})
self.coll.insert_many(
Expand Down
Loading