fh-pydantic-form 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fh-pydantic-form might be problematic. Click here for more details.
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/PKG-INFO +1 -1
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/pyproject.toml +1 -1
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/form_renderer.py +28 -3
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/.github/workflows/build.yaml +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/.github/workflows/publish.yaml +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/.gitignore +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/.pre-commit-config.yaml +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/LICENSE +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/README.md +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/__init__.py +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/field_renderers.py +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/form_parser.py +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/py.typed +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/registry.py +0 -0
- {fh_pydantic_form-0.1.2 → fh_pydantic_form-0.1.3}/src/fh_pydantic_form/type_helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fh-pydantic-form
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: a library to turn any pydantic BaseModel object into a fasthtml/monsterui input form
|
|
5
5
|
Project-URL: Homepage, https://github.com/Marcura/fh-pydantic-form
|
|
6
6
|
Project-URL: Repository, https://github.com/Marcura/fh-pydantic-form
|
|
@@ -522,6 +522,7 @@ class PydanticForm(Generic[ModelType]):
|
|
|
522
522
|
)
|
|
523
523
|
|
|
524
524
|
# Create a default item
|
|
525
|
+
default_item = None # Initialize default_item
|
|
525
526
|
try:
|
|
526
527
|
# Ensure item_type is not None before checking attributes or type
|
|
527
528
|
if item_type:
|
|
@@ -530,6 +531,10 @@ class PydanticForm(Generic[ModelType]):
|
|
|
530
531
|
try:
|
|
531
532
|
default_item = item_type.model_construct()
|
|
532
533
|
except Exception as e:
|
|
534
|
+
logger.error(
|
|
535
|
+
f"Error constructing model for {field_name}: {e}",
|
|
536
|
+
exc_info=True,
|
|
537
|
+
)
|
|
533
538
|
return fh.Li(
|
|
534
539
|
mui.Alert(
|
|
535
540
|
f"Error creating model instance: {str(e)}",
|
|
@@ -547,7 +552,7 @@ class PydanticForm(Generic[ModelType]):
|
|
|
547
552
|
elif item_type is bool:
|
|
548
553
|
default_item = False
|
|
549
554
|
else:
|
|
550
|
-
default_item = None
|
|
555
|
+
default_item = None # Other simple types or complex non-models
|
|
551
556
|
else:
|
|
552
557
|
# Case where item_type itself was None (should ideally be caught earlier)
|
|
553
558
|
default_item = None
|
|
@@ -555,6 +560,9 @@ class PydanticForm(Generic[ModelType]):
|
|
|
555
560
|
f"item_type was None when trying to create default for {field_name}"
|
|
556
561
|
)
|
|
557
562
|
except Exception as e:
|
|
563
|
+
logger.error(
|
|
564
|
+
f"Error creating default item for {field_name}: {e}", exc_info=True
|
|
565
|
+
)
|
|
558
566
|
return fh.Li(
|
|
559
567
|
mui.Alert(
|
|
560
568
|
f"Error creating default item: {str(e)}", cls=mui.AlertT.error
|
|
@@ -565,7 +573,7 @@ class PydanticForm(Generic[ModelType]):
|
|
|
565
573
|
# Generate a unique placeholder index
|
|
566
574
|
placeholder_idx = f"new_{int(pytime.time() * 1000)}"
|
|
567
575
|
|
|
568
|
-
# Create a list renderer
|
|
576
|
+
# Create a list renderer
|
|
569
577
|
list_renderer = ListFieldRenderer(
|
|
570
578
|
field_name=field_name,
|
|
571
579
|
field_info=field_info,
|
|
@@ -573,9 +581,26 @@ class PydanticForm(Generic[ModelType]):
|
|
|
573
581
|
prefix=self.base_prefix, # Use the form's base prefix
|
|
574
582
|
)
|
|
575
583
|
|
|
584
|
+
# Ensure the item data passed to the renderer is a dict if it's a model instance
|
|
585
|
+
item_data_for_renderer = None
|
|
586
|
+
if isinstance(default_item, BaseModel):
|
|
587
|
+
item_data_for_renderer = default_item.model_dump()
|
|
588
|
+
logger.debug(
|
|
589
|
+
f"Add item: Converted model instance to dict for renderer: {item_data_for_renderer}"
|
|
590
|
+
)
|
|
591
|
+
elif default_item is not None: # Handle simple types directly
|
|
592
|
+
item_data_for_renderer = default_item
|
|
593
|
+
logger.debug(
|
|
594
|
+
f"Add item: Passing simple type directly to renderer: {item_data_for_renderer}"
|
|
595
|
+
)
|
|
596
|
+
# else: item_data_for_renderer remains None if default_item was None
|
|
597
|
+
|
|
576
598
|
# Render the new item card, set is_open=True to make it expanded by default
|
|
577
599
|
new_item_card = list_renderer._render_item_card(
|
|
578
|
-
|
|
600
|
+
item_data_for_renderer, # Pass the dictionary or simple value
|
|
601
|
+
placeholder_idx,
|
|
602
|
+
item_type,
|
|
603
|
+
is_open=True,
|
|
579
604
|
)
|
|
580
605
|
|
|
581
606
|
return new_item_card
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|