Skip to content

Commit 2ed687e

Browse files
committed
perf: Extend the LabelField default type to reduce validation errors under pydantic v2.
1 parent 091ce36 commit 2ed687e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fastapi_amis_admin/crud/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def _get_label_modelfield(label: Label) -> ModelField:
262262
try:
263263
type_ = label.expression.type.python_type
264264
except NotImplementedError:
265-
type_ = str
265+
type_ = Union[float, int, str, None]
266266
modelfield = create_response_field(
267267
name=label.key,
268268
type_=type_,
@@ -271,7 +271,7 @@ def _get_label_modelfield(label: Label) -> ModelField:
271271
return modelfield
272272

273273

274-
def LabelField(label: Label, field: FieldInfo, type_: type = str) -> Label:
274+
def LabelField(label: Label, field: FieldInfo, type_: type = Union[float, int, str, None]) -> Label:
275275
"""Use for adding FieldInfo to sqlalchemy Label type"""
276276
modelfield = _get_label_modelfield(label)
277277
field.alias = label.key

0 commit comments

Comments
 (0)