From c2a39b46d73e2a405cb05aa25773dabdda6e43f3 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Fri, 13 Dec 2024 07:12:16 +0300 Subject: [PATCH] apparently we should use .annotation, and .allow_none is useless --- reflex/utils/types.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index d8c787a8d..cba8ec02a 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -14,6 +14,7 @@ from typing import ( Callable, ClassVar, Dict, + ForwardRef, FrozenSet, Iterable, List, @@ -278,14 +279,9 @@ def true_type_for_pydantic_field(f: ModelField): Returns: The type for the field. """ - outer_type = f.outer_type_ - if ( - f.allow_none - and not is_optional(outer_type) - and outer_type not in (None, type(None)) - ): - return Optional[outer_type] - return outer_type + if not isinstance(f.annotation, (str, ForwardRef)): + return f.annotation + return f.outer_type_ def value_inside_optional(cls: GenericType) -> GenericType: