diff --git a/mongoengine/pymongo_support.py b/mongoengine/pymongo_support.py index d9c5ee27..3aef4e09 100644 --- a/mongoengine/pymongo_support.py +++ b/mongoengine/pymongo_support.py @@ -11,7 +11,9 @@ PYMONGO_VERSION = tuple(pymongo.version_tuple[:2]) IS_PYMONGO_GTE_37 = PYMONGO_VERSION >= _PYMONGO_37 -def count_documents(collection, filter, skip=None, limit=None, hint=None, collation=None): +def count_documents( + collection, filter, skip=None, limit=None, hint=None, collation=None +): """Pymongo>3.7 deprecates count in favour of count_documents """ if limit == 0: diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index 303271f5..ae45297d 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -404,7 +404,7 @@ class BaseQuerySet(object): if self._limit == 0: # mimic the fact that historically .limit(0) sets no limit - kwargs.pop('limit', None) + kwargs.pop("limit", None) if self._hint not in (-1, None): kwargs["hint"] = self._hint diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 801473b1..5133b007 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -554,7 +554,7 @@ class TestIndexes(unittest.TestCase): incorrect_collation = {"arndom": "wrdo"} with pytest.raises(OperationFailure) as exc_info: BlogPost.objects.collation(incorrect_collation).count() - assert 'Missing expected field' in str(exc_info.value) + assert "Missing expected field" in str(exc_info.value) query_result = BlogPost.objects.collation({}).order_by("name") assert [x.name for x in query_result] == sorted(names)