Skip to content

Commit 4df0f8f

Browse files
committed
update hooks and autoformat with newer black
1 parent e006c25 commit 4df0f8f

17 files changed

+5
-21
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- repo: https://github.com/ambv/black
11-
rev: 22.12.0
11+
rev: 23.1.0
1212
hooks:
1313
- id: black
1414
- repo: https://github.com/pycqa/flake8
@@ -23,6 +23,6 @@ repos:
2323
- id: pyupgrade
2424
args: [--py36-plus]
2525
- repo: https://github.com/pycqa/isort
26-
rev: 5.11.4
26+
rev: 5.12.0
2727
hooks:
2828
- id: isort

mongoengine/base/document.py

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def __delattr__(self, *args, **kwargs):
161161
def __setattr__(self, name, value):
162162
# Handle dynamic data only if an initialised dynamic document
163163
if self._dynamic and not self._dynamic_lock:
164-
165164
if name not in self._fields_ordered and not name.startswith("_"):
166165
DynamicField = _import_class("DynamicField")
167166
field = DynamicField(db_field=name, null=True)

mongoengine/base/metaclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def __new__(mcs, name, bases, attrs):
178178
f.owner_document = new_class
179179
delete_rule = getattr(f, "reverse_delete_rule", DO_NOTHING)
180180
if isinstance(f, CachedReferenceField):
181-
182181
if issubclass(new_class, EmbeddedDocument):
183182
raise InvalidDocumentError(
184183
"CachedReferenceFields is not allowed in EmbeddedDocuments"

mongoengine/connection.py

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def _get_connection_settings(
102102

103103
resolved_hosts = []
104104
for entity in conn_host:
105-
106105
# Reject old mongomock integration
107106
# To be removed in a few versions after 0.27.0
108107
if entity.startswith("mongomock://") or kwargs.get("is_mock"):

mongoengine/dereference.py

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def _fetch_objects(self, doc_type=None):
165165
"""Fetch all references and convert to their document objects"""
166166
object_map = {}
167167
for collection, dbrefs in self.reference_map.items():
168-
169168
# we use getattr instead of hasattr because hasattr swallows any exception under python2
170169
# so it could hide nasty things without raising exceptions (cfr bug #1688))
171170
ref_document_cls_exists = getattr(collection, "objects", None) is not None

mongoengine/document.py

-1
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ def ensure_indexes(cls):
918918
# If _cls is being used (for polymorphism), it needs an index,
919919
# only if another index doesn't begin with _cls
920920
if index_cls and not cls_indexed and cls._meta.get("allow_inheritance"):
921-
922921
# we shouldn't pass 'cls' to the collection.ensureIndex options
923922
# because of https://jira.mongodb.org/browse/SERVER-769
924923
if "cls" in index_opts:

mongoengine/fields.py

-2
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ def prepare_query_value(self, op, value):
981981
self.error("List is too long")
982982

983983
if self.field:
984-
985984
# If the value is iterable and it's not a string nor a
986985
# BaseDocument, call prepare_query_value for each of its items.
987986
if (
@@ -2216,7 +2215,6 @@ def __get__(self, instance, owner):
22162215
return value
22172216

22182217
def __set__(self, instance, value):
2219-
22202218
if value is None and instance._initialised:
22212219
value = self.generate()
22222220

mongoengine/queryset/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,6 @@ def order_by(self, *keys):
11201120
new_ordering = queryset._get_order_by(keys)
11211121

11221122
if queryset._cursor_obj:
1123-
11241123
# If a cursor object has already been created, apply the sort to it
11251124
if new_ordering:
11261125
queryset._cursor_obj.sort(new_ordering)

mongoengine/queryset/queryset.py

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def _iter_results(self):
8787

8888
pos = 0
8989
while True:
90-
9190
# For all positions lower than the length of the current result
9291
# cache, serve the docs straight from the cache w/o hitting the
9392
# database.

tests/document/test_instance.py

-1
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,6 @@ class Doc(Document):
15261526
assert my_doc.int_field == 1
15271527

15281528
def test_document_update(self):
1529-
15301529
# try updating a non-saved document
15311530
with pytest.raises(OperationError):
15321531
person = self.Person(name="dcrosta")

tests/fields/test_dict_field.py

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class Simple(Document):
324324

325325
def test_dictfield_with_referencefield_complex_nesting_cases(self):
326326
"""Ensure complex nesting inside DictField handles dereferencing of ReferenceField(dbref=True | False)"""
327+
327328
# Relates to Issue #1453
328329
class Doc(Document):
329330
s = StringField()

tests/fields/test_fields.py

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def test_default_value_is_not_used_when_changing_value_to_empty_list_for_strict_
239239
self,
240240
):
241241
"""List field with default can be set to the empty list (strict)"""
242+
242243
# Issue #1733
243244
class Doc(Document):
244245
x = ListField(IntField(), default=lambda: [42])
@@ -253,6 +254,7 @@ def test_default_value_is_not_used_when_changing_value_to_empty_list_for_dyn_doc
253254
self,
254255
):
255256
"""List field with default can be set to the empty list (dynamic)"""
257+
256258
# Issue #1733
257259
class Doc(DynamicDocument):
258260
x = ListField(IntField(), default=lambda: [42])

tests/fields/test_file_field.py

-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ class TestFile(Document):
535535
@require_pil
536536
def test_get_image_by_grid_id(self):
537537
class TestImage(Document):
538-
539538
image1 = ImageField()
540539
image2 = ImageField()
541540

tests/fields/test_geo_fields.py

-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ class Parent(Document):
369369
assert len(Location._geo_indices()) == 1
370370

371371
def test_geo_indexes_auto_index(self):
372-
373372
# Test just listing the fields
374373
class Log(Document):
375374
location = PointField(auto_index=False)

tests/queryset/test_queryset.py

-4
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ class BlogPost(Document):
604604
assert post.comments[1].votes == 8
605605

606606
def test_update_using_positional_operator_matches_first(self):
607-
608607
# Currently the $ operator only applies to the first matched item in
609608
# the query
610609

@@ -5611,7 +5610,6 @@ class Person(Document):
56115610
# Check that bool(queryset) does not uses the orderby
56125611
qs = Person.objects.order_by("name")
56135612
with query_counter() as q:
5614-
56155613
if bool(qs):
56165614
pass
56175615

@@ -5624,7 +5622,6 @@ class Person(Document):
56245622
# Check that normal query uses orderby
56255623
qs2 = Person.objects.order_by("name")
56265624
with query_counter() as q:
5627-
56285625
for x in qs2:
56295626
pass
56305627

@@ -5648,7 +5645,6 @@ class Person(Document):
56485645
Person(name="A").save()
56495646

56505647
with query_counter() as q:
5651-
56525648
if Person.objects:
56535649
pass
56545650

tests/test_context_managers.py

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class Group(Document):
7676
assert 1 == Group.objects.count()
7777

7878
with switch_db(Group, "testdb-1") as Group:
79-
8079
assert 0 == Group.objects.count()
8180

8281
Group(name="hello").save()
@@ -104,7 +103,6 @@ class Group(Document):
104103
assert 1 == Group.objects.count()
105104

106105
with switch_collection(Group, "group1") as Group:
107-
108106
assert 0 == Group.objects.count()
109107

110108
Group(name="hello - group1").save()

tests/test_signals.py

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def post_bulk_insert(cls, sender, documents, **kwargs):
9797
Author.id.set_next_value(0)
9898

9999
class Another(Document):
100-
101100
name = StringField()
102101

103102
def __unicode__(self):

0 commit comments

Comments
 (0)