🐛 A title is not generated in nested models if a custom description is provided
Closed this issue · 2 comments
mwcraig commented
Describe the bug
A title is not generated in nested models if a custom description is provided. A title cannot be added unless it differs from the name of the nested model.
To Reproduce
Steps to reproduce the behavior:
- Paste this code into a jupyter notebook
from typing import Annotated
from pydantic import BaseModel, Field
from ipyautoui import AutoUi
class NestedStr(BaseModel):
"""A nested model"""
string: str
class NestedFloat(BaseModel):
"""Nested float"""
number: float | None
class Compound(BaseModel):
"""My compound model"""
nest_str_1: Annotated[
NestedStr,
Field(description="Overridden description nest_str_1")
]
nest_str_2: NestedStr = Field(description="Non-annotated overridden description nest_str_2")
nest_str_3: NestedStr = Field(title="NestedStr", description="Overridden, and title doesn't work nest_str_3")
nest_str_4: NestedStr = Field(title="Nested Str", description="Overridden, this title works nest_str_4")
nest_float: NestedFloat
AutoUi(Compound)
Many of the nested objects do not have title (screenshot below).
Expected behavior
Each nested object will have a title generated from its name.
Screenshots
Additional context
Version for some of the relevant packages:
ipywidgets 8.1.1
jupyterlab 4.0.10
pydantic 2.5.3
pydantic-core 2.14.6
jgunstone commented
hi @mwcraig ,
thanks for reporting. Was a simple fix, and I added a test with you example here:
f7e0a15
just published the fix: https://pypi.org/project/ipyautoui/0.7.12/
cheers
mwcraig commented
Excellent, thanks!