Skip to content

Commit 7a0a58c

Browse files
committed
black reformat
1 parent 3d6b650 commit 7a0a58c

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

mongoengine/fields.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def prepare_query_value(self, op, value):
163163
regex = value
164164

165165
# escape unsafe characters which could lead to a re.error
166-
if op == 'regex':
166+
if op == "regex":
167167
value = re.compile(regex, flags)
168168
else:
169169
value = re.escape(value)
@@ -1093,9 +1093,7 @@ def lookup_member(self, member_name):
10931093
return DictField(db_field=member_name)
10941094

10951095
def prepare_query_value(self, op, value):
1096-
match_operators = [
1097-
*STRING_OPERATORS
1098-
]
1096+
match_operators = [*STRING_OPERATORS]
10991097

11001098
if op in match_operators and isinstance(value, str):
11011099
return StringField().prepare_query_value(op, value)

tests/queryset/test_queryset.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -872,17 +872,15 @@ def test_rename(self):
872872
self.Person.objects.create(name="Foo", age=11)
873873

874874
bob = self.Person.objects.as_pymongo().first()
875-
assert 'age' in bob
876-
assert bob['age'] == 11
875+
assert "age" in bob
876+
assert bob["age"] == 11
877877

878-
self.Person.objects(name="Foo").update(
879-
rename__age='person_age'
880-
)
878+
self.Person.objects(name="Foo").update(rename__age="person_age")
881879

882880
bob = self.Person.objects.as_pymongo().first()
883-
assert 'age' not in bob
884-
assert 'person_age' in bob
885-
assert bob['person_age'] == 11
881+
assert "age" not in bob
882+
assert "person_age" in bob
883+
assert bob["person_age"] == 11
886884

887885
def test_save_and_only_on_fields_with_default(self):
888886
class Embed(EmbeddedDocument):
@@ -1257,7 +1255,6 @@ def test_regex_query_shortcuts(self):
12571255
obj = self.Person.objects(name__iexact="gUIDO VAN rOSSU").first()
12581256
assert obj is None
12591257

1260-
12611258
# Test wholeword
12621259
obj = self.Person.objects(name__wholeword="Guido").first()
12631260
assert obj == person
@@ -1370,12 +1367,14 @@ def test_filter_chaining_with_regex(self):
13701367
person.save()
13711368

13721369
people = self.Person.objects
1373-
people = people.filter(name__startswith="Gui")\
1374-
.filter(name__not__endswith="tum")\
1375-
.filter(name__icontains="VAN")\
1376-
.filter(name__regex="^Guido")\
1377-
.filter(name__wholeword="Guido")\
1370+
people = (
1371+
people.filter(name__startswith="Gui")
1372+
.filter(name__not__endswith="tum")
1373+
.filter(name__icontains="VAN")
1374+
.filter(name__regex="^Guido")
1375+
.filter(name__wholeword="Guido")
13781376
.filter(name__wholeword="van")
1377+
)
13791378
assert people.count() == 1
13801379

13811380
def assertSequence(self, qs, expected):

0 commit comments

Comments
 (0)