Skip to content

Commit 05b872e

Browse files
fix linting
1 parent f7fb511 commit 05b872e

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
@@ -12,6 +12,7 @@
1212
from django.core.exceptions import NON_FIELD_ERRORS
1313
from django.db.models import Model
1414
from django.forms import BaseForm
15+
from django.forms.models import model_to_dict # lazy import
1516
from django.forms.widgets import CheckboxInput, Select
1617
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
1718
from django.utils.decorators import classonlymethod
@@ -609,7 +610,6 @@ def _get_object_forms(self) -> dict:
609610
form_data = {}
610611
elif isinstance(obj, Model):
611612
# Use model-to-dict so we get plain Python values
612-
from django.forms.models import model_to_dict # lazy import
613613

614614
form_data = model_to_dict(obj)
615615
# model_to_dict skips non-editable fields; also include raw attribute values
@@ -619,7 +619,7 @@ def _get_object_forms(self) -> dict:
619619
for form_field_name in form_instance.fields:
620620
if form_field_name not in form_data:
621621
form_data[form_field_name] = getattr(obj, form_field_name, None)
622-
except Exception:
622+
except Exception: # noqa: S110
623623
pass
624624
elif isinstance(obj, dict):
625625
form_data = obj

tests/components/test_component.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from django import forms
66
from tests.views.fake_components import (
77
FakeAuthenticationComponent,
8+
FakeFormClassesComponent,
89
FakeValidationComponent,
910
)
1011

1112
from django_unicorn.components import UnicornView
1213
from django_unicorn.serializer import InvalidFieldNameError
14+
from example.books.models import Book
1315

1416

1517
class ExampleComponent(UnicornView):
@@ -414,7 +416,6 @@ def test_form_classes_validate_all_fields_with_empty_object():
414416
title or date_published, calling ``validate()`` should populate errors for
415417
both ``book.title`` and ``book.date_published``.
416418
"""
417-
from tests.views.fake_components import FakeFormClassesComponent
418419

419420
component = FakeFormClassesComponent(component_id="test_form_classes_validate_all", component_name="example")
420421

@@ -431,7 +432,6 @@ def test_form_classes_validate_model_names_filtered():
431432
When ``model_names`` is specified, only the requested dotted keys should
432433
appear in the errors dict.
433434
"""
434-
from tests.views.fake_components import FakeFormClassesComponent
435435

436436
component = FakeFormClassesComponent(component_id="test_form_classes_filtered", component_name="example")
437437

@@ -443,7 +443,6 @@ def test_form_classes_validate_model_names_filtered():
443443

444444
def test_form_classes_is_valid_with_empty_object():
445445
"""``is_valid()`` should return ``False`` when required object fields are missing."""
446-
from tests.views.fake_components import FakeFormClassesComponent
447446

448447
component = FakeFormClassesComponent(component_id="test_form_classes_is_valid_false", component_name="example")
449448

@@ -455,9 +454,6 @@ def test_form_classes_validate_stale_errors_removed():
455454
Errors for an object field that has since become valid should be removed on
456455
the next ``validate()`` call.
457456
"""
458-
from tests.views.fake_components import FakeFormClassesComponent
459-
460-
from example.books.models import Book
461457

462458
component = FakeFormClassesComponent(component_id="test_form_classes_stale_errors", component_name="example")
463459

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)