Skip to content
Merged
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
16 changes: 16 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ PyMongo 4.16 brings a number of changes including:
- Removed support for Eventlet.
Eventlet is actively being sunset by its maintainers and has compatibility issues with PyMongo's dnspython dependency.

Changes in Version 4.15.4 (2025/10/21)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this also bundling the release alongside?

Copy link
Contributor Author

@NoahStapp NoahStapp Oct 22, 2025

Choose a reason for hiding this comment

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

What do you mean? We'll update the release date when the release is ready to go out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow-up here @Jibola

Copy link
Contributor

Choose a reason for hiding this comment

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

I assumed it would have XXXX/XX/XX, since it hasn't been released yet. This isn't a blocking issue since it'll get updated when its going out.

--------------------------------------

Version 4.15.4 is a bug fix release.

- Relaxed the callback type of :meth:`~pymongo.asynchronous.client_session.AsyncClientSession.with_transaction` to allow the broader Awaitable type rather than only Coroutine objects.
- Added the missing Python 3.14 trove classifier to the package metadata.

Issues Resolved
...............

See the `PyMongo 4.15.4 release notes in JIRA`_ for the list of resolved issues
in this release.

.. _PyMongo 4.15.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=47237

Changes in Version 4.15.3 (2025/10/07)
--------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions pymongo/asynchronous/client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
TYPE_CHECKING,
Any,
AsyncContextManager,
Awaitable,
Callable,
Coroutine,
Mapping,
MutableMapping,
NoReturn,
Expand Down Expand Up @@ -604,7 +604,7 @@ def _inherit_option(self, name: str, val: _T) -> _T:

async def with_transaction(
self,
callback: Callable[[AsyncClientSession], Coroutine[Any, Any, _T]],
callback: Callable[[AsyncClientSession], Awaitable[_T]],
read_concern: Optional[ReadConcern] = None,
write_concern: Optional[WriteConcern] = None,
read_preference: Optional[_ServerMode] = None,
Expand Down
12 changes: 12 additions & 0 deletions test/asynchronous/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Execute Transactions Spec tests."""
from __future__ import annotations

import asyncio
import sys
from io import BytesIO
from test.asynchronous.utils_spec_runner import AsyncSpecRunner
Expand Down Expand Up @@ -468,6 +469,17 @@ async def callback2(session):
async with self.client.start_session() as s:
self.assertEqual(await s.with_transaction(callback2), "Foo")

@async_client_context.require_transactions
@async_client_context.require_async
async def test_callback_awaitable_no_coroutine(self):
def callback(_):
future = asyncio.Future()
future.set_result("Foo")
return future

async with self.client.start_session() as s:
self.assertEqual(await s.with_transaction(callback), "Foo")

@async_client_context.require_transactions
async def test_callback_not_retried_after_timeout(self):
listener = OvertCommandListener()
Expand Down
12 changes: 12 additions & 0 deletions test/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Execute Transactions Spec tests."""
from __future__ import annotations

import asyncio
import sys
from io import BytesIO
from test.utils_spec_runner import SpecRunner
Expand Down Expand Up @@ -460,6 +461,17 @@ def callback2(session):
with self.client.start_session() as s:
self.assertEqual(s.with_transaction(callback2), "Foo")

@client_context.require_transactions
@client_context.require_async
def test_callback_awaitable_no_coroutine(self):
def callback(_):
future = asyncio.Future()
future.set_result("Foo")
return future

with self.client.start_session() as s:
self.assertEqual(s.with_transaction(callback), "Foo")

@client_context.require_transactions
def test_callback_not_retried_after_timeout(self):
listener = OvertCommandListener()
Expand Down
8 changes: 8 additions & 0 deletions tools/synchro.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ def translate_coroutine_types(lines: list[str]) -> list[str]:
index = lines.index(type)
new = type.replace(old, res.group(3))
lines[index] = new
coroutine_types = [line for line in lines if "Awaitable[" in line]
for type in coroutine_types:
res = re.search(r"Awaitable\[([A-z]+)\]", type)
if res:
old = res[0]
index = lines.index(type)
new = type.replace(old, res.group(1))
lines[index] = new
return lines


Expand Down
Loading