Skip to content

Commit

Permalink
Merge pull request #2637 from bagerard/prepare_0_24_1
Browse files Browse the repository at this point in the history
Prepare release 0 24 1
  • Loading branch information
bagerard committed Mar 21, 2022
2 parents dd17d73 + 968625c commit 2cab8a0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/ambv/black
rev: 21.5b2
rev: 22.1.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.19.1
rev: v2.31.1
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/pycqa/isort
rev: 5.8.0
rev: 5.10.1
hooks:
- id: isort
30 changes: 15 additions & 15 deletions benchmarks/test_basic_doc_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ def init_book():
author_email="[email protected]",
)

print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10 ** 6))
print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10**6))

b = init_book()
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10 ** 6))
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10**6))

print(
"Doc setattr: %.3fus"
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10 ** 6) # noqa B010
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10**6) # noqa B010
)

print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10 ** 6))
print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10**6))

print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10 ** 6))
print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10**6))

def save_book():
b._mark_as_changed("name")
b._mark_as_changed("tags")
b.save()

print("Save to database: %.3fus" % (timeit(save_book, 100) * 10 ** 6))
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10**6))

son = b.to_mongo()
print(
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10 ** 6)
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10**6)
)

print(
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10 ** 6)
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10**6)
)

def create_and_delete_book():
Expand All @@ -75,7 +75,7 @@ def create_and_delete_book():

print(
"Init + save to database + delete: %.3fms"
% (timeit(create_and_delete_book, 10) * 10 ** 3)
% (timeit(create_and_delete_book, 10) * 10**3)
)


Expand All @@ -101,9 +101,9 @@ def init_company():
)

company = init_company()
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10 ** 3))
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10**3))

print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10 ** 3))
print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10**3))

company.save()

Expand All @@ -112,17 +112,17 @@ def save_company():
company._mark_as_changed("contacts")
company.save()

print("Save to database: %.3fms" % (timeit(save_company, 100) * 10 ** 3))
print("Save to database: %.3fms" % (timeit(save_company, 100) * 10**3))

son = company.to_mongo()
print(
"Load from SON: %.3fms"
% (timeit(lambda: Company._from_son(son), 100) * 10 ** 3)
% (timeit(lambda: Company._from_son(son), 100) * 10**3)
)

print(
"Load from database: %.3fms"
% (timeit(lambda: Company.objects[0], 100) * 10 ** 3)
% (timeit(lambda: Company.objects[0], 100) * 10**3)
)

def create_and_delete_company():
Expand All @@ -132,7 +132,7 @@ def create_and_delete_company():

print(
"Init + save to database + delete: %.3fms"
% (timeit(create_and_delete_company, 10) * 10 ** 3)
% (timeit(create_and_delete_company, 10) * 10**3)
)


Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Development
===========
- (Fill this out as you fix issues and develop your features).

Changes in 0.24.1
=================
- Allow pymongo<5.0 to be pulled
- Don't use deprecated property for emptiness check in queryset base #2633


Changes in 0.24.0
=================
- EnumField improvements: now ``choices`` limits the values of an enum to allow
Expand Down
2 changes: 1 addition & 1 deletion mongoengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)


VERSION = (0, 24, 0)
VERSION = (0, 24, 1)


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion mongoengine/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _get_capped_collection(cls):
collection_name = cls._get_collection_name()

# Get max document limit and max byte size from meta.
max_size = cls._meta.get("max_size") or 10 * 2 ** 20 # 10MB default
max_size = cls._meta.get("max_size") or 10 * 2**20 # 10MB default
max_documents = cls._meta.get("max_documents")

# MongoDB will automatically raise the size to make it a multiple of
Expand Down
2 changes: 1 addition & 1 deletion tests/document/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Log(Document):
options = Log.objects._collection.options()
assert options["capped"] is True
assert options["max"] == 10
assert options["size"] == 10 * 2 ** 20
assert options["size"] == 10 * 2**20

# Check that the document with default value can be recreated
class Log(Document):
Expand Down
4 changes: 2 additions & 2 deletions tests/fields/test_float_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class BigPerson(Document):
big_person.height = int(0)
big_person.validate()

big_person.height = 2 ** 500
big_person.height = 2**500
big_person.validate()

big_person.height = 2 ** 100000 # Too big for a float value
big_person.height = 2**100000 # Too big for a float value
with pytest.raises(ValidationError):
big_person.validate()

0 comments on commit 2cab8a0

Please sign in to comment.