3131 cast ,
3232)
3333
34+ from pydantic import GetCoreSchemaHandler
35+ from pydantic_core import CoreSchema , core_schema
36+
3437import temporalio .workflow
3538
3639logger = logging .getLogger (__name__ )
@@ -948,6 +951,14 @@ def _is_restrictable(v: Any) -> bool:
948951
949952
950953class _RestrictedProxy :
954+ @classmethod
955+ def __get_pydantic_core_schema__ (
956+ cls , source_type : Any , handler : GetCoreSchemaHandler
957+ ) -> CoreSchema :
958+ return core_schema .no_info_after_validator_function (
959+ cls , handler (object .__getattribute__ (source_type , "__temporal_state" ).obj )
960+ )
961+
951962 def __init__ (self , * args , ** kwargs ) -> None :
952963 # When we instantiate this class, we have the signature of:
953964 # __init__(
@@ -973,6 +984,8 @@ def __init__(self, *args, **kwargs) -> None:
973984 def __getattribute__ (self , __name : str ) -> Any :
974985 state = _RestrictionState .from_proxy (self )
975986 _trace ("__getattribute__ %s on %s" , __name , state .name )
987+ if __name == "__get_pydantic_core_schema__" :
988+ return object .__getattribute__ (self , "__get_pydantic_core_schema__" )
976989 # We do not restrict __spec__ or __name__
977990 if __name != "__spec__" and __name != "__name__" :
978991 state .assert_child_not_restricted (__name )
0 commit comments