Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #611

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
rev: v0.9.1
hooks:
- id: ruff
args:
Expand Down
4 changes: 3 additions & 1 deletion polymorphic/query_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def translate_polymorphic_field_path(queryset_model, field_path):

submodels = _get_all_sub_models(queryset_model)
model = submodels.get(classname, None)
assert model, f"PolymorphicModel: model {classname} not found (not a subclass of {queryset_model.__name__})!"
assert model, (
f"PolymorphicModel: model {classname} not found (not a subclass of {queryset_model.__name__})!"
)

basepath = _create_base_path(queryset_model, model)

Expand Down
2 changes: 1 addition & 1 deletion polymorphic/showfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _showfields_get_content(self, field_name, field_type=type(None)):
txt = str(content)
max_len = self.polymorphic_showfield_max_field_width
if len(txt) > max_len:
txt = f"{txt[:max_len - 2]}.."
txt = f"{txt[: max_len - 2]}.."
out += f'"{txt}"'
return out

Expand Down
12 changes: 6 additions & 6 deletions polymorphic/tests/admintestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def assertFormSuccess(self, request_url, response):
else:
raise KeyError("Unknown field for errors in the TemplateResponse!")

assert (
response.status_code == 302
), f"Form errors in calling {request_url}:\n{errors.as_text()}"
assert (
"/login/?next=" not in response["Location"]
), f"Received login response for {request_url}"
assert response.status_code == 302, (
f"Form errors in calling {request_url}:\n{errors.as_text()}"
)
assert "/login/?next=" not in response["Location"], (
f"Received login response for {request_url}"
)
24 changes: 12 additions & 12 deletions polymorphic/tests/test_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ def test_defer_fields(self):

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

assert (
"field1" not in objects_deferred[0].__dict__
), "field1 was not deferred (using defer())"
assert "field1" not in objects_deferred[0].__dict__, (
"field1 was not deferred (using defer())"
)

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

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

assert (
"field1" in objects_only[0].__dict__
), 'qs.only("field1") was used, but field1 was incorrectly deferred'
assert (
"field1" in objects_only[3].__dict__
), 'qs.only("field1") was used, but field1 was incorrectly deferred on a child model'
assert "field1" in objects_only[0].__dict__, (
'qs.only("field1") was used, but field1 was incorrectly deferred'
)
assert "field1" in objects_only[3].__dict__, (
'qs.only("field1") was used, but field1 was incorrectly deferred on a child model'
)
assert "field4" not in objects_only[3].__dict__, "field4 was not deferred (using only())"
assert "field1" not in objects_only[0].get_deferred_fields()

Expand Down Expand Up @@ -290,9 +290,9 @@ def test_defer_related_fields(self):
self.create_model2abcd()

objects_deferred_field4 = Model2A.objects.defer("Model2D___field4")
assert (
"field4" not in objects_deferred_field4[3].__dict__
), "field4 was not deferred (using defer(), traversing inheritance)"
assert "field4" not in objects_deferred_field4[3].__dict__, (
"field4 was not deferred (using defer(), traversing inheritance)"
)
assert objects_deferred_field4[0].__class__ == Model2A
assert objects_deferred_field4[1].__class__ == Model2B
assert objects_deferred_field4[2].__class__ == Model2C
Expand Down
Loading