def true_type_for_pydantic_field(f: ModelField):
    """Get the type for a pydantic field.

    Args:
        f: The field to get the type for.

    Returns:
        The type for the field.
    """
    if not isinstance(f.annotation, (str, ForwardRef)):
        return f.annotation

    type_ = f.outer_type_

    if (
        f.field_info.default is None
        or (isinstance(f.annotation, str) and f.annotation.startswith("Optional"))
        or (
            isinstance(f.annotation, ForwardRef)
            and f.annotation.__forward_arg__.startswith("Optional")
        )
    ) and not is_optional(type_):
        return type_ | None

    return type_
Get the type for a pydantic field.

    Args:
        f: The field to get the type for.

    Returns:
        The type for the field.
    
reflex/utils/types.py