Skip to content

Commit eafd72b

Browse files
authored
Deps/update pymongo (#97)
* Update dependencies in requirements and setup files * Format and lint * Orden * Remove support python 3.9 * Refactor import statements in test_encrypted_string.py * pre-release * Update version to 1.3.0
1 parent 8a57a6e commit eafd72b

10 files changed

Lines changed: 31 additions & 26 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
23+
python-version: ['3.10', '3.11', '3.12', '3.13']
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: Set up Python ${{ matrix.python-version }}

mongoengine_plus/models/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
class BaseModel:
7-
_excluded: ClassVar = []
8-
_hidden: ClassVar = []
7+
_excluded: ClassVar[list[str]] = []
8+
_hidden: ClassVar[list[str]] = []
99

1010
def __init__(self, *args, **values):
1111
return super().__init__(*args, **values)

mongoengine_plus/types/encrypted_string/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import codecs
44

55
import boto3
6-
from pymongo.encryption import _EncryptionIO
6+
from pymongo.synchronous.encryption import _EncryptionIO
77

88
from .fields import EncryptedStringField
99

mongoengine_plus/types/encrypted_string/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Dict
33

44
from bson import CodecOptions
5-
from bson.binary import STANDARD, UUID_SUBTYPE, Binary
5+
from bson.binary import STANDARD, Binary
66
from mongoengine import get_connection
77
from pymongo.encryption import ClientEncryption
88

@@ -32,7 +32,7 @@ def get_data_key_binary(key_namespace: str, key_name: str) -> Binary:
3232
# Buscamos el data key
3333
data_key = get_data_key(key_namespace, key_name)
3434
uuid_data_key = data_key['_id']
35-
return Binary(uuid_data_key.bytes, UUID_SUBTYPE)
35+
return uuid_data_key
3636

3737

3838
def create_data_key(
@@ -52,6 +52,7 @@ def create_data_key(
5252
partialFilterExpression={"keyAltNames": {"$exists": True}},
5353
)
5454

55+
client_encryption: ClientEncryption
5556
with ClientEncryption(
5657
kms_provider,
5758
key_namespace,

mongoengine_plus/types/encrypted_string/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .base import get_data_key_binary
1010

11-
CODEC_OPTION = CodecOptions(uuid_representation=STANDARD)
11+
CODEC_OPTION: CodecOptions = CodecOptions(uuid_representation=STANDARD)
1212

1313

1414
class EncryptedStringField(BaseField):
@@ -57,6 +57,7 @@ def to_python(self, value: Any) -> Any:
5757

5858
connection = get_connection()
5959

60+
client_encryption: ClientEncryption
6061
with ClientEncryption(
6162
self.kms_provider, self.key_namespace, connection, CODEC_OPTION
6263
) as client_encryption:
@@ -66,6 +67,7 @@ def to_mongo(self, value: Any) -> Any:
6667
connection = get_connection()
6768
data_key = get_data_key_binary(self.key_namespace, self.key_name)
6869

70+
client_encryption: ClientEncryption
6971
with ClientEncryption(
7072
self.kms_provider, self.key_namespace, connection, CODEC_OPTION
7173
) as client_encryption:

mongoengine_plus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.2.1'
1+
__version__ = '1.3.0'

requirements-test.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
black==24.10.0
2-
flake8==7.1.1
3-
isort==5.13.2
4-
mypy==1.14.1
5-
moto[server,kms]==5.0.26
6-
pytest==8.3.4
7-
pytest-asyncio==0.25.2
8-
pytest-cov==6.0.0
9-
pytest-freezegun==0.4.2
10-
testcontainers==4.9.0
1+
black==25.11.*
2+
flake8==7.3.*
3+
isort==7.0.*
4+
moto[server,kms]==5.1.*
5+
mypy==1.18.*
6+
pytest==9.0.*
7+
pytest-asyncio==1.3.*
8+
pytest-cov==7.0.*
9+
pytest-freezegun==0.4.*
10+
testcontainers==4.13.*

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blinker==1.9.0
2-
dnspython==2.7.0
2+
boto3==1.40.71
3+
dnspython==2.8.0
34
mongoengine==0.29.1
4-
pymongo==3.13.0
5-
pymongocrypt==1.12.2
6-
boto3==1.35.95
5+
pymongo==4.15.4
6+
pymongocrypt==1.16.0

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
packages=find_packages(),
2424
include_package_data=True,
2525
package_data=dict(mongoengine_plus=['py.typed']),
26-
python_requires='>=3.9',
26+
python_requires='>=3.10',
2727
install_requires=[
2828
'mongoengine>=0.29.1',
2929
'dnspython>=2.7.0',
30-
'pymongo>=3.13.0,<4.0.0',
30+
'pymongo>=4.0.0,<5.0.0',
3131
'pymongocrypt>=1.12.2,<2.0.0',
3232
'boto3>=1.34.106,<2.0.0',
3333
'blinker>=1.9.0,<2.0.0',
3434
],
3535
classifiers=[
36-
'Programming Language :: Python :: 3.9',
3736
'Programming Language :: Python :: 3.10',
3837
'Programming Language :: Python :: 3.11',
3938
'Programming Language :: Python :: 3.12',

tests/types/test_encrypted_string.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from bson import Binary
77
from mongoengine import Document, StringField
88
from pymongo import MongoClient
9-
from pymongo.encryption import Algorithm, ClientEncryption, _EncryptionIO
9+
from pymongo.encryption import Algorithm, ClientEncryption
10+
from pymongo.synchronous.encryption import _EncryptionIO
1011

1112
from mongoengine_plus.models import uuid_field
1213
from mongoengine_plus.types import EncryptedStringField
@@ -85,6 +86,7 @@ def test_create_data_key(
8586
({"keyAltNames": key_name})
8687
)
8788

89+
assert data_key is not None
8890
assert data_key['keyAltNames'] == [key_name]
8991
assert type(data_key['keyMaterial']) is bytes
9092
assert data_key['masterKey'] == dict(
@@ -113,6 +115,7 @@ def test_encrypted_string_on_saving_and_reading(
113115
assert user_dict['name'] == user.name
114116
assert isinstance(user_dict['ssn'], Binary)
115117

118+
client_encryption: ClientEncryption
116119
with ClientEncryption(
117120
EncryptedStringField.kms_provider,
118121
EncryptedStringField.key_namespace,

0 commit comments

Comments
 (0)