diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 328a8cbc8..97a5cd336 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ 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 @@ -16,11 +16,11 @@ repos: 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 diff --git a/benchmarks/test_basic_doc_ops.py b/benchmarks/test_basic_doc_ops.py index 91efc7e32..66b6a17f9 100644 --- a/benchmarks/test_basic_doc_ops.py +++ b/benchmarks/test_basic_doc_ops.py @@ -38,34 +38,34 @@ def init_book(): author_email="alec@example.com", ) - 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(): @@ -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) ) @@ -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() @@ -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(): @@ -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) ) diff --git a/docs/changelog.rst b/docs/changelog.rst index fc80342e8..b3da43920 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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 diff --git a/mongoengine/__init__.py b/mongoengine/__init__.py index ef75e7529..14519da25 100644 --- a/mongoengine/__init__.py +++ b/mongoengine/__init__.py @@ -29,7 +29,7 @@ ) -VERSION = (0, 24, 0) +VERSION = (0, 24, 1) def get_version(): diff --git a/mongoengine/document.py b/mongoengine/document.py index 5d6a47a0e..e7a1938f2 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -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 diff --git a/tests/document/test_instance.py b/tests/document/test_instance.py index 1f9a76b47..db72e580e 100644 --- a/tests/document/test_instance.py +++ b/tests/document/test_instance.py @@ -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): diff --git a/tests/fields/test_float_field.py b/tests/fields/test_float_field.py index 30f829ae8..41c063f64 100644 --- a/tests/fields/test_float_field.py +++ b/tests/fields/test_float_field.py @@ -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()