Skip to content

Commit 064dfaf

Browse files
committed
fix: correct return type annotation for find_one_and_update to include None
1 parent 44a58f1 commit 064dfaf

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PyMongo 4.16 brings a number of changes including:
1717
- Removed support for Eventlet.
1818
Eventlet is actively being sunset by its maintainers and has compatibility issues with PyMongo's dnspython dependency.
1919
- Use Zstandard support from the standard library for Python 3.14+, and use ``backports.zstd`` for older versions.
20+
- Fixed return type annotation for :meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one_and_update` and :meth:`~pymongo.synchronous.collection.Collection.find_one_and_update` to include ``None``.
2021

2122
Changes in Version 4.15.4 (2025/10/21)
2223
--------------------------------------

doc/contributors.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ The following is a list of people who have contributed to
107107
- Jeffrey A. Clark (aclark4life)
108108
- Steven Silvester (blink1073)
109109
- Noah Stapp (NoahStapp)
110+
- Cal Jacobson (cj81499)

pymongo/asynchronous/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3510,7 +3510,7 @@ async def find_one_and_update(
35103510
let: Optional[Mapping[str, Any]] = None,
35113511
comment: Optional[Any] = None,
35123512
**kwargs: Any,
3513-
) -> _DocumentType:
3513+
) -> Optional[_DocumentType]:
35143514
"""Finds a single document and updates it, returning either the
35153515
original or the updated document.
35163516

pymongo/synchronous/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3503,7 +3503,7 @@ def find_one_and_update(
35033503
let: Optional[Mapping[str, Any]] = None,
35043504
comment: Optional[Any] = None,
35053505
**kwargs: Any,
3506-
) -> _DocumentType:
3506+
) -> Optional[_DocumentType]:
35073507
"""Finds a single document and updates it, returning either the
35083508
original or the updated document.
35093509

0 commit comments

Comments
 (0)