diff --git a/pydantic_redis/_shared/utils.py b/pydantic_redis/_shared/utils.py index 5ecc2130..4b2ef362 100644 --- a/pydantic_redis/_shared/utils.py +++ b/pydantic_redis/_shared/utils.py @@ -82,7 +82,11 @@ def from_str_or_bytes_to_any(value: Any, field_type: Type) -> Any: """ if isinstance(value, (bytes, bytearray, memoryview)): return orjson.loads(value) - elif isinstance(value, str) and field_type != str: + elif ( + isinstance(value, str) + and field_type != str + and (str not in typing_get_args(field_type)) + ): return orjson.loads(value) return value