from typing import Any
from typing import Union
from datetime import datetime


def _pre_serialize(value: Any) -> Union[Any, str]:
    """Convert `value` to str if datetime, otherwise do nothing."""
    return value if not isinstance(value, datetime) else str(value)