Skip to content

Commit 832c375

Browse files
authored
Add warning and direct to Pydantic converter sample if Pydantic models are detected (#249)
1 parent 82f723b commit 832c375

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

temporalio/converter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import traceback
1212
import uuid
13+
import warnings
1314
from abc import ABC, abstractmethod
1415
from dataclasses import dataclass
1516
from datetime import datetime
@@ -477,6 +478,11 @@ def encoding(self) -> str:
477478

478479
def to_payload(self, value: Any) -> Optional[temporalio.api.common.v1.Payload]:
479480
"""See base class."""
481+
# Check for pydantic then send warning
482+
if hasattr(value, "parse_obj"):
483+
warnings.warn(
484+
"If you're using pydantic model, refer to https://github.com/temporalio/samples-python/tree/main/pydantic_converter for better support"
485+
)
480486
# We let JSON conversion errors be thrown to caller
481487
return temporalio.api.common.v1.Payload(
482488
metadata={"encoding": self._encoding.encode()},

0 commit comments

Comments
 (0)