Skip to content

Commit 164e3a3

Browse files
committed
format
1 parent ebd87bf commit 164e3a3

File tree

3 files changed

+45
-41
lines changed

3 files changed

+45
-41
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Don't forget to remove deprecated code on each major release!
2525

2626
### Fixed
2727

28-
- Fixed bregression from the previous release where components would sometimes not output debug messages when `settings.py:DEBUG` is enabled.
28+
- Fixed regression from the previous release where components would sometimes not output debug messages when `settings.py:DEBUG` is enabled.
2929

3030
### Changed
3131

src/reactpy_django/components.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import os
55
from pathlib import Path
6-
from typing import TYPE_CHECKING, Any, Callable, Type, Union, cast
6+
from typing import TYPE_CHECKING, Any, Callable, Union, cast
77
from urllib.parse import urlencode
88
from uuid import uuid4
99

@@ -129,7 +129,7 @@ def django_js(static_path: str, key: Key | None = None):
129129

130130

131131
def django_form(
132-
form: Type[Form],
132+
form: type[Form],
133133
*,
134134
top_children: Sequence = (),
135135
bottom_children: Sequence = (),
@@ -265,7 +265,7 @@ def _django_js(static_path: str):
265265

266266
@component
267267
def _django_form(
268-
form: Type[Form], top_children: Sequence, bottom_children: Sequence, auto_submit: bool, auto_submit_wait: int
268+
form: type[Form], top_children: Sequence, bottom_children: Sequence, auto_submit: bool, auto_submit_wait: int
269269
):
270270
# TODO: Implement form restoration on page reload. Probably want to create a new setting called
271271
# form_restoration_method that can be set to "URL", "CLIENT_STORAGE", "SERVER_SESSION", or None.
@@ -284,18 +284,20 @@ def _django_form(
284284

285285
# Don't allow the count of top and bottom children to change
286286
if len(top_children) != top_children_count.current or len(bottom_children) != bottom_children_count.current:
287-
raise ValueError("Dynamically changing the number of top or bottom children is not allowed.")
287+
msg = "Dynamically changing the number of top or bottom children is not allowed."
288+
raise ValueError(msg)
288289

289290
# Try to initialize the form with the provided data
290291
try:
291292
initialized_form = form(data=submitted_data)
292293
except Exception as e:
293294
if not isinstance(form, type(Form)):
294-
raise ValueError(
295+
msg = (
295296
"The provided form must be an uninitialized Django Form. "
296297
"Do NOT initialize your form by calling it (ex. `MyForm()`)."
297-
) from e
298-
raise e
298+
)
299+
raise TypeError(msg) from e
300+
raise
299301

300302
# Run the form validation, if data was provided
301303
if submitted_data:

0 commit comments

Comments
 (0)