Skip to content

Commit 6ce1501

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents a216788 + a7a645f commit 6ce1501

File tree

13 files changed

+108
-69
lines changed

13 files changed

+108
-69
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ repos:
105105
# - test/test_client.py:188: te ==> the, be, we, to
106106
args: ["-L", "fle,fo,infinit,isnt,nin,te,aks"]
107107

108+
- repo: https://github.com/astral-sh/uv-pre-commit
109+
# uv version.
110+
rev: 0.8.17
111+
hooks:
112+
- id: uv-lock
113+
108114
- repo: local
109115
hooks:
110116
- id: executable-shell

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,3 +514,11 @@ To profile a test script and generate a flame graph, follow these steps:
514514
(Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.)
515515
4. If you need to include native code (for example the C extensions), profiling should be done on a Linux system, as macOS and Windows do not support the `--native` option of `py-spy`.
516516
Creating an ubuntu Evergreen spawn host and using `scp` to copy the flamegraph `.svg` file back to your local machine is the best way to do this.
517+
518+
## Dependabot updates
519+
520+
Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
521+
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
522+
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
523+
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
524+
also run `just typing` and handle any new findings.

bson/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ def decode_iter(
13271327
elements = data[position : position + obj_size]
13281328
position += obj_size
13291329

1330-
yield _bson_to_dict(elements, opts) # type:ignore[misc]
1330+
yield _bson_to_dict(elements, opts)
13311331

13321332

13331333
@overload
@@ -1373,7 +1373,7 @@ def decode_file_iter(
13731373
raise InvalidBSON("cut off in middle of objsize")
13741374
obj_size = _UNPACK_INT_FROM(size_data, 0)[0] - 4
13751375
elements = size_data + file_obj.read(max(0, obj_size))
1376-
yield _bson_to_dict(elements, opts) # type:ignore[arg-type, misc]
1376+
yield _bson_to_dict(elements, opts) # type:ignore[misc]
13771377

13781378

13791379
def is_valid(bson: bytes) -> bool:

doc/changelog.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
Changelog
22
=========
33

4+
Changes in Version 4.15.1 (2025/09/16)
5+
--------------------------------------
6+
7+
Version 4.15.1 is a bug fix release.
8+
9+
- Fixed a bug in :meth:`~pymongo.synchronous.encryption.ClientEncryption.encrypt`
10+
and :meth:`~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt`
11+
that would cause a ``TypeError`` when using ``pymongocrypt<1.16`` by passing
12+
an unsupported ``type_opts`` parameter even if Queryable Encryption text
13+
queries beta was not used.
14+
15+
- Fixed a bug in ``AsyncMongoClient`` that caused a ``ServerSelectionTimeoutError``
16+
when used with ``uvicorn``, ``FastAPI``, or ``uvloop``.
17+
18+
Issues Resolved
19+
...............
20+
21+
See the `PyMongo 4.15.1 release notes in JIRA`_ for the list of resolved issues
22+
in this release.
23+
24+
.. _PyMongo 4.15.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=46486
25+
426
Changes in Version 4.15.0 (2025/09/10)
527
--------------------------------------
628

@@ -13,17 +35,20 @@ PyMongo 4.15 brings a number of changes including:
1335
:attr:`~pymongo.encryption.QueryType.SUBSTRINGPREVIEW`,
1436
as part of the experimental Queryable Encryption text queries beta.
1537
``pymongocrypt>=1.16`` is required for text query support.
16-
- Added :class:`bson.decimal128.DecimalEncoder` and :class:`bson.decimal128.DecimalDecoder`
17-
to support encoding and decoding of BSON Decimal128 values to decimal.Decimal values using the TypeRegistry API.
38+
- Added :class:`bson.decimal128.DecimalEncoder` and
39+
:class:`bson.decimal128.DecimalDecoder`
40+
to support encoding and decoding of BSON Decimal128 values to
41+
decimal.Decimal values using the TypeRegistry API.
1842
- Added support for Windows ``arm64`` wheels.
1943

2044
Changes in Version 4.14.1 (2025/08/19)
2145
--------------------------------------
2246

2347
Version 4.14.1 is a bug fix release.
2448

25-
- Fixed a bug in ``MongoClient.append_metadata()`` and ``AsyncMongoClient.append_metadata()``
26-
that allowed duplicate ``DriverInfo.name`` to be appended to the metadata.
49+
- Fixed a bug in ``MongoClient.append_metadata()`` and
50+
``AsyncMongoClient.append_metadata()``
51+
that allowed duplicate ``DriverInfo.name`` to be appended to the metadata.
2752

2853
Issues Resolved
2954
...............

justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ typing-pyright: && resync
5050
{{typing_run}} pyright -p strict_pyrightconfig.json test/test_typing_strict.py
5151

5252
[group('lint')]
53-
lint: && resync
54-
uv run pre-commit run --all-files
53+
lint *args="": && resync
54+
uv run pre-commit run --all-files {{args}}
5555

5656
[group('lint')]
57-
lint-manual: && resync
58-
uv run pre-commit run --all-files --hook-stage manual
57+
lint-manual *args="": && resync
58+
uv run pre-commit run --all-files --hook-stage manual {{args}}
5959

6060
[group('test')]
6161
test *args="-v --durations=5 --maxfail=10": && resync

pymongo/asynchronous/srv_resolver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def get_options(self) -> Optional[str]:
107107
# No TXT records
108108
return None
109109
except Exception as exc:
110-
raise ConfigurationError(str(exc)) from None
110+
raise ConfigurationError(str(exc)) from exc
111111
if len(results) > 1:
112112
raise ConfigurationError("Only one TXT record is supported")
113113
return (b"&".join([b"".join(res.strings) for res in results])).decode("utf-8") # type: ignore[attr-defined]
@@ -122,7 +122,7 @@ async def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
raise ConfigurationError(str(exc)) from None
125+
raise ConfigurationError(str(exc)) from exc
126126
return results
127127

128128
async def _get_srv_response_and_hosts(
@@ -145,8 +145,8 @@ async def _get_srv_response_and_hosts(
145145
)
146146
try:
147147
nlist = srv_host.split(".")[1:][-self.__slen :]
148-
except Exception:
149-
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None
148+
except Exception as exc:
149+
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc
150150
if self.__plist != nlist:
151151
raise ConfigurationError(f"Invalid SRV host: {node[0]}")
152152
if self.__srv_max_hosts:

pymongo/synchronous/srv_resolver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_options(self) -> Optional[str]:
107107
# No TXT records
108108
return None
109109
except Exception as exc:
110-
raise ConfigurationError(str(exc)) from None
110+
raise ConfigurationError(str(exc)) from exc
111111
if len(results) > 1:
112112
raise ConfigurationError("Only one TXT record is supported")
113113
return (b"&".join([b"".join(res.strings) for res in results])).decode("utf-8") # type: ignore[attr-defined]
@@ -122,7 +122,7 @@ def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
raise ConfigurationError(str(exc)) from None
125+
raise ConfigurationError(str(exc)) from exc
126126
return results
127127

128128
def _get_srv_response_and_hosts(
@@ -145,8 +145,8 @@ def _get_srv_response_and_hosts(
145145
)
146146
try:
147147
nlist = srv_host.split(".")[1:][-self.__slen :]
148-
except Exception:
149-
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None
148+
except Exception as exc:
149+
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc
150150
if self.__plist != nlist:
151151
raise ConfigurationError(f"Invalid SRV host: {node[0]}")
152152
if self.__srv_max_hosts:

test/asynchronous/test_srv_polling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def response_callback(*args):
225225

226226
await self.run_scenario(response_callback, False)
227227

228-
@flaky(reason="PYTHON-5500")
228+
@flaky(reason="PYTHON-5500", max_runs=3)
229229
async def test_dns_failures_logging(self):
230230
from dns import exception
231231

test/lambda/build_internal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash -ex
22

33
cd /src
4-
PYTHON=/opt/python/cp39-cp39/bin/python
4+
PYTHON=/opt/python/cp310-cp310/bin/python
55
$PYTHON -m pip install -v -e .

test/lambda/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Resources:
2323
Variables:
2424
MONGODB_URI: !Ref MongoDbUri
2525
Handler: app.lambda_handler
26-
Runtime: python3.9
26+
Runtime: python3.10
2727
Architectures:
2828
- x86_64
2929
Events:

0 commit comments

Comments
 (0)