Skip to content

Commit 3e126d3

Browse files
fix linting
1 parent a9e05a3 commit 3e126d3

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/django_unicorn/components/unicorn_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.apps import apps as django_apps_module
1212
from django.core.exceptions import NON_FIELD_ERRORS
1313
from django.db.models import Model
14+
from django.forms.models import model_to_dict # lazy import
1415
from django.forms.widgets import CheckboxInput, Select
1516
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
1617
from django.utils.decorators import classonlymethod
@@ -589,7 +590,6 @@ def _get_object_forms(self) -> dict:
589590
form_data = {}
590591
elif isinstance(obj, Model):
591592
# Use model-to-dict so we get plain Python values
592-
from django.forms.models import model_to_dict # lazy import
593593

594594
form_data = model_to_dict(obj)
595595
# model_to_dict skips non-editable fields; also include raw attribute values
@@ -599,7 +599,7 @@ def _get_object_forms(self) -> dict:
599599
for form_field_name in form_instance.fields:
600600
if form_field_name not in form_data:
601601
form_data[form_field_name] = getattr(obj, form_field_name, None)
602-
except Exception:
602+
except Exception: # noqa: S110
603603
pass
604604
elif isinstance(obj, dict):
605605
form_data = obj

tests/components/test_component.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import pytest
55
from tests.views.fake_components import (
66
FakeAuthenticationComponent,
7+
FakeFormClassesComponent,
78
FakeValidationComponent,
89
)
910

1011
from django_unicorn.components import UnicornView
1112
from django_unicorn.serializer import InvalidFieldNameError
13+
from example.books.models import Book
1214

1315

1416
class ExampleComponent(UnicornView):
@@ -358,7 +360,6 @@ def test_form_classes_validate_all_fields_with_empty_object():
358360
title or date_published, calling ``validate()`` should populate errors for
359361
both ``book.title`` and ``book.date_published``.
360362
"""
361-
from tests.views.fake_components import FakeFormClassesComponent
362363

363364
component = FakeFormClassesComponent(component_id="test_form_classes_validate_all", component_name="example")
364365

@@ -375,7 +376,6 @@ def test_form_classes_validate_model_names_filtered():
375376
When ``model_names`` is specified, only the requested dotted keys should
376377
appear in the errors dict.
377378
"""
378-
from tests.views.fake_components import FakeFormClassesComponent
379379

380380
component = FakeFormClassesComponent(component_id="test_form_classes_filtered", component_name="example")
381381

@@ -387,7 +387,6 @@ def test_form_classes_validate_model_names_filtered():
387387

388388
def test_form_classes_is_valid_with_empty_object():
389389
"""``is_valid()`` should return ``False`` when required object fields are missing."""
390-
from tests.views.fake_components import FakeFormClassesComponent
391390

392391
component = FakeFormClassesComponent(component_id="test_form_classes_is_valid_false", component_name="example")
393392

@@ -399,9 +398,6 @@ def test_form_classes_validate_stale_errors_removed():
399398
Errors for an object field that has since become valid should be removed on
400399
the next ``validate()`` call.
401400
"""
402-
from tests.views.fake_components import FakeFormClassesComponent
403-
404-
from example.books.models import Book
405401

406402
component = FakeFormClassesComponent(component_id="test_form_classes_stale_errors", component_name="example")
407403

tests/views/message/test_form_classes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
(e.g. ``book.title``) are correctly surfaced in the response JSON.
77
"""
88

9-
import pytest
109
from tests.views.message.utils import post_and_get_response
1110

1211
COMPONENT_URL = "/message/tests.views.fake_components.FakeFormClassesComponent"

0 commit comments

Comments
 (0)