Skip to content

Commit 49f2122

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b977b83 commit 49f2122

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

polymorphic/query_translate.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ def translate_polymorphic_field_path(queryset_model, field_path):
182182

183183
submodels = _get_all_sub_models(queryset_model)
184184
model = submodels.get(classname, None)
185-
assert model, f"PolymorphicModel: model {classname} not found (not a subclass of {queryset_model.__name__})!"
185+
assert model, (
186+
f"PolymorphicModel: model {classname} not found (not a subclass of {queryset_model.__name__})!"
187+
)
186188

187189
basepath = _create_base_path(queryset_model, model)
188190

polymorphic/showfields.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _showfields_get_content(self, field_name, field_type=type(None)):
4545
txt = str(content)
4646
max_len = self.polymorphic_showfield_max_field_width
4747
if len(txt) > max_len:
48-
txt = f"{txt[:max_len - 2]}.."
48+
txt = f"{txt[: max_len - 2]}.."
4949
out += f'"{txt}"'
5050
return out
5151

polymorphic/tests/admintestcase.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ def assertFormSuccess(self, request_url, response):
219219
else:
220220
raise KeyError("Unknown field for errors in the TemplateResponse!")
221221

222-
assert (
223-
response.status_code == 302
224-
), f"Form errors in calling {request_url}:\n{errors.as_text()}"
225-
assert (
226-
"/login/?next=" not in response["Location"]
227-
), f"Received login response for {request_url}"
222+
assert response.status_code == 302, (
223+
f"Form errors in calling {request_url}:\n{errors.as_text()}"
224+
)
225+
assert "/login/?next=" not in response["Location"], (
226+
f"Received login response for {request_url}"
227+
)

polymorphic/tests/test_orm.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ def test_defer_fields(self):
235235

236236
objects_deferred = Model2A.objects.defer("field1").order_by("id")
237237

238-
assert (
239-
"field1" not in objects_deferred[0].__dict__
240-
), "field1 was not deferred (using defer())"
238+
assert "field1" not in objects_deferred[0].__dict__, (
239+
"field1 was not deferred (using defer())"
240+
)
241241

242242
# Check that we have exactly one deferred field ('field1') per resulting object.
243243
for obj in objects_deferred:
@@ -247,12 +247,12 @@ def test_defer_fields(self):
247247

248248
objects_only = Model2A.objects.only("pk", "polymorphic_ctype", "field1")
249249

250-
assert (
251-
"field1" in objects_only[0].__dict__
252-
), 'qs.only("field1") was used, but field1 was incorrectly deferred'
253-
assert (
254-
"field1" in objects_only[3].__dict__
255-
), 'qs.only("field1") was used, but field1 was incorrectly deferred on a child model'
250+
assert "field1" in objects_only[0].__dict__, (
251+
'qs.only("field1") was used, but field1 was incorrectly deferred'
252+
)
253+
assert "field1" in objects_only[3].__dict__, (
254+
'qs.only("field1") was used, but field1 was incorrectly deferred on a child model'
255+
)
256256
assert "field4" not in objects_only[3].__dict__, "field4 was not deferred (using only())"
257257
assert "field1" not in objects_only[0].get_deferred_fields()
258258

@@ -290,9 +290,9 @@ def test_defer_related_fields(self):
290290
self.create_model2abcd()
291291

292292
objects_deferred_field4 = Model2A.objects.defer("Model2D___field4")
293-
assert (
294-
"field4" not in objects_deferred_field4[3].__dict__
295-
), "field4 was not deferred (using defer(), traversing inheritance)"
293+
assert "field4" not in objects_deferred_field4[3].__dict__, (
294+
"field4 was not deferred (using defer(), traversing inheritance)"
295+
)
296296
assert objects_deferred_field4[0].__class__ == Model2A
297297
assert objects_deferred_field4[1].__class__ == Model2B
298298
assert objects_deferred_field4[2].__class__ == Model2C

0 commit comments

Comments
 (0)