Skip to content

Commit 92b7946

Browse files
authored
Merge branch 'master' into async-improvements
2 parents f6e35d9 + 63c3f8a commit 92b7946

36 files changed

+1410
-398
lines changed

.evergreen/generated_configs/variants.yml

Lines changed: 223 additions & 231 deletions
Large diffs are not rendered by default.

.evergreen/scripts/configure-env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export PROJECT="$project"
4646
export PIP_QUIET=1
4747
EOT
4848

49+
# Skip CSOT tests on non-linux platforms.
50+
if [ "$(uname -s)" != "Linux" ]; then
51+
echo "export SKIP_CSOT_TESTS=1" >> $SCRIPT_DIR/env.sh
52+
fi
53+
4954
# Add these expansions to make it easier to call out tests scripts from the EVG yaml
5055
cat <<EOT > expansion.yml
5156
DRIVERS_TOOLS: "$DRIVERS_TOOLS"

.evergreen/scripts/generate_config.py

Lines changed: 452 additions & 73 deletions
Large diffs are not rendered by default.

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
uses: actions/checkout@v4
4040
with:
4141
ref: ${{ inputs.ref }}
42+
persist-credentials: false
4243
- uses: actions/setup-python@v5
4344

4445
# Initializes the CodeQL tools for scanning.

.github/workflows/dist.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
uses: actions/checkout@v4
4949
with:
5050
fetch-depth: 0
51+
persist-credentials: false
5152
ref: ${{ inputs.ref }}
5253

5354
- uses: actions/setup-python@v5
@@ -106,6 +107,7 @@ jobs:
106107
- uses: actions/checkout@v4
107108
with:
108109
fetch-depth: 0
110+
persist-credentials: false
109111
ref: ${{ inputs.ref }}
110112

111113
- uses: actions/setup-python@v5

.github/workflows/test-python.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2325
- uses: actions/setup-python@v5
2426
with:
2527
python-version: "3.9"
@@ -55,6 +57,8 @@ jobs:
5557
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
5658
steps:
5759
- uses: actions/checkout@v4
60+
with:
61+
persist-credentials: false
5862
- if: ${{ matrix.python-version == '3.13t' }}
5963
name: Setup free-threaded Python
6064
uses: deadsnakes/[email protected]
@@ -99,6 +103,8 @@ jobs:
99103
name: DocTest
100104
steps:
101105
- uses: actions/checkout@v4
106+
with:
107+
persist-credentials: false
102108
- name: Setup Python
103109
uses: actions/setup-python@v5
104110
with:
@@ -121,6 +127,8 @@ jobs:
121127
runs-on: ubuntu-latest
122128
steps:
123129
- uses: actions/checkout@v4
130+
with:
131+
persist-credentials: false
124132
- uses: actions/setup-python@v5
125133
with:
126134
cache: 'pip'
@@ -139,6 +147,8 @@ jobs:
139147
runs-on: ubuntu-latest
140148
steps:
141149
- uses: actions/checkout@v4
150+
with:
151+
persist-credentials: false
142152
- uses: actions/setup-python@v5
143153
with:
144154
cache: 'pip'
@@ -160,6 +170,8 @@ jobs:
160170
python: ["3.9", "3.11"]
161171
steps:
162172
- uses: actions/checkout@v4
173+
with:
174+
persist-credentials: false
163175
- uses: actions/setup-python@v5
164176
with:
165177
python-version: "${{matrix.python}}"
@@ -177,6 +189,8 @@ jobs:
177189
name: "Make an sdist"
178190
steps:
179191
- uses: actions/checkout@v4
192+
with:
193+
persist-credentials: false
180194
- uses: actions/setup-python@v5
181195
with:
182196
cache: 'pip'

.github/workflows/zizmor.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor latest via Cargo
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
20+
- name: Setup Rust
21+
uses: actions-rust-lang/setup-rust-toolchain@v1
22+
- name: Get zizmor
23+
run: cargo install zizmor
24+
- name: Run zizmor 🌈
25+
run: zizmor --format sarif . > results.sarif
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Upload SARIF file
29+
uses: github/codeql-action/upload-sarif@v3
30+
with:
31+
sarif_file: results.sarif
32+
category: zizmor

bson/binary.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import struct
1717
from dataclasses import dataclass
1818
from enum import Enum
19-
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Type, Union
19+
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Type, Union, overload
2020
from uuid import UUID
2121

2222
"""Tools for representing BSON binary data.
@@ -195,7 +195,7 @@ class UuidRepresentation:
195195

196196

197197
VECTOR_SUBTYPE = 9
198-
"""**(BETA)** BSON binary subtype for densely packed vector data.
198+
"""BSON binary subtype for densely packed vector data.
199199
200200
.. versionadded:: 4.10
201201
"""
@@ -207,7 +207,7 @@ class UuidRepresentation:
207207

208208

209209
class BinaryVectorDtype(Enum):
210-
"""**(BETA)** Datatypes of vector subtype.
210+
"""Datatypes of vector subtype.
211211
212212
:param FLOAT32: (0x27) Pack list of :class:`float` as float32
213213
:param INT8: (0x03) Pack list of :class:`int` in [-128, 127] as signed int8
@@ -229,7 +229,7 @@ class BinaryVectorDtype(Enum):
229229

230230
@dataclass
231231
class BinaryVector:
232-
"""**(BETA)** Vector of numbers along with metadata for binary interoperability.
232+
"""Vector of numbers along with metadata for binary interoperability.
233233
.. versionadded:: 4.10
234234
"""
235235

@@ -256,7 +256,7 @@ class Binary(bytes):
256256
the difference between what should be considered binary data and
257257
what should be considered a string when we encode to BSON.
258258
259-
**(BETA)** Subtype 9 provides a space-efficient representation of 1-dimensional vector data.
259+
Subtype 9 provides a space-efficient representation of 1-dimensional vector data.
260260
Its data is prepended with two bytes of metadata.
261261
The first (dtype) describes its data type, such as float32 or int8.
262262
The second (padding) prescribes the number of bits to ignore in the final byte.
@@ -278,7 +278,7 @@ class Binary(bytes):
278278
Support any bytes-like type that implements the buffer protocol.
279279
280280
.. versionchanged:: 4.10
281-
**(BETA)** Addition of vector subtype.
281+
Addition of vector subtype.
282282
"""
283283

284284
_type_marker = 5
@@ -397,14 +397,26 @@ def as_uuid(self, uuid_representation: int = UuidRepresentation.STANDARD) -> UUI
397397
f"cannot decode subtype {self.subtype} to {UUID_REPRESENTATION_NAMES[uuid_representation]}"
398398
)
399399

400+
@classmethod
401+
@overload
402+
def from_vector(cls: Type[Binary], vector: BinaryVector) -> Binary:
403+
...
404+
405+
@classmethod
406+
@overload
407+
def from_vector(
408+
cls: Type[Binary], vector: list[int, float], dtype: BinaryVectorDtype, padding: int = 0
409+
) -> Binary:
410+
...
411+
400412
@classmethod
401413
def from_vector(
402414
cls: Type[Binary],
403415
vector: Union[BinaryVector, list[int, float]],
404416
dtype: Optional[BinaryVectorDtype] = None,
405417
padding: Optional[int] = None,
406418
) -> Binary:
407-
"""**(BETA)** Create a BSON :class:`~bson.binary.Binary` of Vector subtype.
419+
"""Create a BSON :class:`~bson.binary.Binary` of Vector subtype.
408420
409421
To interpret the representation of the numbers, a data type must be included.
410422
See :class:`~bson.binary.BinaryVectorDtype` for available types and descriptions.
@@ -447,7 +459,7 @@ def from_vector(
447459
return cls(metadata + data, subtype=VECTOR_SUBTYPE)
448460

449461
def as_vector(self) -> BinaryVector:
450-
"""**(BETA)** From the Binary, create a list of numbers, along with dtype and padding.
462+
"""From the Binary, create a list of numbers, along with dtype and padding.
451463
452464
:return: BinaryVector
453465

pymongo/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888

8989
from pymongo import _csot
9090
from pymongo._version import __version__, get_version_string, version_tuple
91+
from pymongo.asynchronous.mongo_client import AsyncMongoClient
9192
from pymongo.common import MAX_SUPPORTED_WIRE_VERSION, MIN_SUPPORTED_WIRE_VERSION, has_c
9293
from pymongo.cursor import CursorType
9394
from pymongo.operations import (
@@ -104,14 +105,6 @@
104105
from pymongo.synchronous.mongo_client import MongoClient
105106
from pymongo.write_concern import WriteConcern
106107

107-
try:
108-
from pymongo.asynchronous.mongo_client import AsyncMongoClient
109-
except Exception as e:
110-
# PYTHON-4781: Importing asyncio can fail on Windows.
111-
import warnings as _warnings
112-
113-
_warnings.warn(f"Failed to import Async PyMongo: {e!r}", ImportWarning, stacklevel=2)
114-
115108
version = __version__
116109
"""Current version of PyMongo."""
117110

pymongo/asynchronous/auth_oidc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _get_authenticator(
5555
properties = credentials.mechanism_properties
5656

5757
# Validate that the address is allowed.
58-
if not properties.environment:
58+
if properties.human_callback is not None:
5959
found = False
6060
allowed_hosts = properties.allowed_hosts
6161
for patt in allowed_hosts:

0 commit comments

Comments
 (0)