Skip to content

Commit f10c03c

Browse files
fix linting
1 parent 637e8f0 commit f10c03c

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
@@ -632,7 +633,6 @@ def _get_object_forms(self) -> dict:
632633
form_data = {}
633634
elif isinstance(obj, Model):
634635
# Use model-to-dict so we get plain Python values
635-
from django.forms.models import model_to_dict # lazy import
636636

637637
form_data = model_to_dict(obj)
638638
# model_to_dict skips non-editable fields; also include raw attribute values
@@ -642,7 +642,7 @@ def _get_object_forms(self) -> dict:
642642
for form_field_name in form_instance.fields:
643643
if form_field_name not in form_data:
644644
form_data[form_field_name] = getattr(obj, form_field_name, None)
645-
except Exception:
645+
except Exception: # noqa: S110
646646
pass
647647
elif isinstance(obj, dict):
648648
form_data = obj

tests/components/test_component.py

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

1213
from django_unicorn.components import UnicornView
1314
from django_unicorn.serializer import InvalidFieldNameError
15+
from example.books.models import Book
1416

1517

1618
class ExampleComponent(UnicornView):
@@ -539,7 +541,6 @@ def test_form_classes_validate_all_fields_with_empty_object():
539541
title or date_published, calling ``validate()`` should populate errors for
540542
both ``book.title`` and ``book.date_published``.
541543
"""
542-
from tests.views.fake_components import FakeFormClassesComponent
543544

544545
component = FakeFormClassesComponent(component_id="test_form_classes_validate_all", component_name="example")
545546

@@ -556,7 +557,6 @@ def test_form_classes_validate_model_names_filtered():
556557
When ``model_names`` is specified, only the requested dotted keys should
557558
appear in the errors dict.
558559
"""
559-
from tests.views.fake_components import FakeFormClassesComponent
560560

561561
component = FakeFormClassesComponent(component_id="test_form_classes_filtered", component_name="example")
562562

@@ -568,7 +568,6 @@ def test_form_classes_validate_model_names_filtered():
568568

569569
def test_form_classes_is_valid_with_empty_object():
570570
"""``is_valid()`` should return ``False`` when required object fields are missing."""
571-
from tests.views.fake_components import FakeFormClassesComponent
572571

573572
component = FakeFormClassesComponent(component_id="test_form_classes_is_valid_false", component_name="example")
574573

@@ -580,9 +579,6 @@ def test_form_classes_validate_stale_errors_removed():
580579
Errors for an object field that has since become valid should be removed on
581580
the next ``validate()`` call.
582581
"""
583-
from tests.views.fake_components import FakeFormClassesComponent
584-
585-
from example.books.models import Book
586582

587583
component = FakeFormClassesComponent(component_id="test_form_classes_stale_errors", component_name="example")
588584

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)