+
    }iB              	      p  a  0 t $ R t^ RIHt ^ RIt^ RIHtHt ^ RIH	t	H
t
HtHtHtHtHt ^ RIHtHt ^ RIHtHtHt ^ RIHt ^RIHt ^R	IHtHt ^R
IHt ]P@                  ! RA/ ]PB                  BRR/B  ! R R4      4       t"]P@                  ! RA/ ]PB                  BRR/B  ! R R4      4       t#]	'       d4   Rt$R]%R&   Rt&R]%R&    Rt'R]%R&    Rt(R]%R&    ]! R]&R7      t)]! R]'R7      t*]RRRRR R/R! R" ll4       t+]R#RRRRRR R/R$ R% ll4       t+R#R&R]RR'R R/R( R) llt+]	'       d   ]]]],          .]3,          t,R]%R*&    ]].]3,          t-R]%R+&    R,t.R]%R-&    ]]]]],          .]3,          t/R]%R.&    ]]].]3,          t0R]%R/&    R0t1R]%R1&    R2t2R]%R3&   ]! R4].R7      t3]! R5]1R7      t4]R6 R7 l4       t5]RR'RR/R8 R9 ll4       t5]R#RRR'RR/R: R; ll4       t5RBR#R&RR'R]/R< R= lllt5]! R>4      t6]	'       d   ]
]6R3,          t7R# ]P@                  ! RA/ ]PB                  B  ! R? R@4      4       t7R# )CzEThis module contains related classes and functions for serialization.)annotationsN)partialpartialmethod)TYPE_CHECKING	AnnotatedAnyCallableLiteralTypeVaroverload)PydanticUndefinedcore_schema)SerializationInfoSerializerFunctionWrapHandlerWhenUsed)	TypeAlias)PydanticUndefinedAnnotation)_decorators_internal_dataclass)GetCoreSchemaHandlerfrozenTc                  N    ] tR t^t$ RtR]R&   ]tR]R&   RtR]R&   R	 R
 lt	Rt
R# )PlainSerializera  Plain serializers use a function to modify the output of serialization.

This is particularly helpful when you want to customize the serialization for annotated types.
Consider an input of `list`, which will be serialized into a space-delimited string.

```python
from typing import Annotated

from pydantic import BaseModel, PlainSerializer

CustomStr = Annotated[
    list, PlainSerializer(lambda x: ' '.join(x), return_type=str)
]

class StudentModel(BaseModel):
    courses: CustomStr

student = StudentModel(courses=['Math', 'Chemistry', 'English'])
print(student.model_dump())
#> {'courses': 'Math Chemistry English'}
```

Attributes:
    func: The serializer function.
    return_type: The return type for the function. If omitted it will be inferred from the type annotation.
    when_used: Determines when this serializer should be used. Accepts a string with values `'always'`,
        `'unless-none'`, `'json'`, and `'json-unless-none'`. Defaults to 'always'.
zcore_schema.SerializerFunctionfuncr   return_typealwaysr   	when_usedc               $    V ^8  d   QhRRRRRR/#    source_typer   handlerr   returnzcore_schema.CoreSchema )formats   "q/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/pydantic/functional_serializers.py__annotate__PlainSerializer.__annotate__5   #          FZ  _u      c                   V! V4      pV P                   \        Jd   V P                   pM; \        P                  ! V P                  VP                  4       P                  R7      pV\        J d   RMVP                  V4      p\        P                  ! V P                  \        P                  ! V P                  R4      VV P                  R7      VR&   V#   \         d   p\        P                  ! T4      ThRp?ii ; i)zGets the Pydantic core schema.

Args:
    source_type: The source type.
    handler: The `GetCoreSchemaHandler` instance.

Returns:
    The Pydantic core schema.
localnsNplainfunctioninfo_argreturn_schemar   serialization)r   r   r   get_callable_return_typer   _get_types_namespacelocals	NameErrorr   from_name_errorgenerate_schemar   $plain_serializer_function_ser_schemainspect_annotated_serializerr   selfr    r!   schemar   er1   s   &&&    r%   __get_pydantic_core_schema__,PlainSerializer.__get_pydantic_core_schema__5   s     %#44**K	L *BBII#88:AA !,/@ @gF]F]^iFj"-"R"RYY ==diiQ'nn	#
   L1AA!D!KL   :C C;C66C;r#   N__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r?   __static_attributes__r#   r)   r%   r   r      s-    : )((K("Ix"   r)   r   c                  N    ] tR t^Xt$ RtR]R&   ]tR]R&   RtR]R&   R	 R
 lt	Rt
R# )WrapSerializera*  Wrap serializers receive the raw inputs along with a handler function that applies the standard serialization
logic, and can modify the resulting value before returning it as the final output of serialization.

For example, here's a scenario in which a wrap serializer transforms timezones to UTC **and** utilizes the existing `datetime` serialization logic.

```python
from datetime import datetime, timezone
from typing import Annotated, Any

from pydantic import BaseModel, WrapSerializer

class EventDatetime(BaseModel):
    start: datetime
    end: datetime

def convert_to_utc(value: Any, handler, info) -> dict[str, datetime]:
    # Note that `handler` can actually help serialize the `value` for
    # further custom serialization in case it's a subclass.
    partial_result = handler(value, info)
    if info.mode == 'json':
        return {
            k: datetime.fromisoformat(v).astimezone(timezone.utc)
            for k, v in partial_result.items()
        }
    return {k: v.astimezone(timezone.utc) for k, v in partial_result.items()}

UTCEventDatetime = Annotated[EventDatetime, WrapSerializer(convert_to_utc)]

class EventModel(BaseModel):
    event_datetime: UTCEventDatetime

dt = EventDatetime(
    start='2024-01-01T07:00:00-08:00', end='2024-01-03T20:00:00+06:00'
)
event = EventModel(event_datetime=dt)
print(event.model_dump())
'''
{
    'event_datetime': {
        'start': datetime.datetime(
            2024, 1, 1, 15, 0, tzinfo=datetime.timezone.utc
        ),
        'end': datetime.datetime(
            2024, 1, 3, 14, 0, tzinfo=datetime.timezone.utc
        ),
    }
}
'''

print(event.model_dump_json())
'''
{"event_datetime":{"start":"2024-01-01T15:00:00Z","end":"2024-01-03T14:00:00Z"}}
'''
```

Attributes:
    func: The serializer function to be wrapped.
    return_type: The return type for the function. If omitted it will be inferred from the type annotation.
    when_used: Determines when this serializer should be used. Accepts a string with values `'always'`,
        `'unless-none'`, `'json'`, and `'json-unless-none'`. Defaults to 'always'.
z"core_schema.WrapSerializerFunctionr   r   r   r   r   r   c               $    V ^8  d   QhRRRRRR/# r   r#   )r$   s   "r%   r&   WrapSerializer.__annotate__   r(   r)   c                   V! V4      pV P                   \        Jd   V P                   pM; \        P                  ! V P                  VP                  4       P                  R7      pV\        J d   RMVP                  V4      p\        P                  ! V P                  \        P                  ! V P                  R4      VV P                  R7      VR&   V#   \         d   p\        P                  ! T4      ThRp?ii ; i)zThis method is used to get the Pydantic core schema of the class.

Args:
    source_type: Source type.
    handler: Core schema handler.

Returns:
    The generated core schema of the class.
r+   Nwrapr.   r2   )r   r   r   r3   r   r4   r5   r6   r   r7   r8   r   #wrap_serializer_function_ser_schemar:   r   r;   s   &&&    r%   r?   +WrapSerializer.__get_pydantic_core_schema__   s     %#44**K	L *BBII#88:AA !,/@ @gF]F]^iFj"-"Q"QYY ==diiP'nn	#
   L1AA!D!KLrA   r#   NrB   r#   r)   r%   rK   rK   X   s.    <| -,(K("Ix"   r)   rK   z!partial[Any] | partialmethod[Any]r   _Partialz)core_schema.SerializerFunction | _PartialFieldPlainSerializerz-core_schema.WrapSerializerFunction | _PartialFieldWrapSerializerz*FieldPlainSerializer | FieldWrapSerializerFieldSerializer_FieldPlainSerializerT)bound_FieldWrapSerializerTr   .r   check_fieldsc               4    V ^8  d   QhRRRRRRRRRR	R
RRR/# )r   fieldstrfieldsmodeLiteral['wrap']r   r   r   r   rY   bool | Noner"   z8Callable[[_FieldWrapSerializerT], _FieldWrapSerializerT]r#   )r$   s   "r%   r&   r&      sY     C CC C 	C
 C C C >Cr)   c                  R # Nr#   r[   r^   r   r   rY   r]   s   "$$$$*r%   field_serializerrd      s	     @Cr)   r^   c               4    V ^8  d   QhRRRRRRRRRR	R
RRR/# )r   r[   r\   r]   r^   Literal['plain']r   r   r   r   rY   r`   r"   z:Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]r#   )r$   s   "r%   r&   r&      sZ     E EE E 	E
 E E E @Er)   c                  R # rb   r#   rc   s   "$$$$*r%   rd   rd      s	     BEr)   r-   r   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r   r]   r\   r^   Literal['plain', 'wrap']r   r   r   r   rY   r`   r"   zuCallable[[_FieldWrapSerializerT], _FieldWrapSerializerT] | Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]r#   )r$   s   "r%   r&   r&      sM     A AA
"A 	A
 A AAAr)   c                *   a aaaa R VVV VV3R llpV# )a  Decorator that enables custom field serialization.

In the below example, a field of type `set` is used to mitigate duplication. A `field_serializer` is used to serialize the data as a sorted list.

```python
from pydantic import BaseModel, field_serializer

class StudentModel(BaseModel):
    name: str = 'Jane'
    courses: set[str]

    @field_serializer('courses', when_used='json')
    def serialize_courses_in_order(self, courses: set[str]):
        return sorted(courses)

student = StudentModel(courses={'Math', 'Chemistry', 'English'})
print(student.model_dump_json())
#> {"name":"Jane","courses":["Chemistry","English","Math"]}
```

See [the usage documentation](../concepts/serialization.md#serializers) for more information.

Four signatures are supported:

- `(self, value: Any, info: FieldSerializationInfo)`
- `(self, value: Any, nxt: SerializerFunctionWrapHandler, info: FieldSerializationInfo)`
- `(value: Any, info: SerializationInfo)`
- `(value: Any, nxt: SerializerFunctionWrapHandler, info: SerializationInfo)`

Args:
    fields: Which field(s) the method should be called on.
    mode: The serialization mode.

        - `plain` means the function will be called instead of the default serialization logic,
        - `wrap` means the function will be called with an argument to optionally call the
           default serialization logic.
    return_type: Optional return type for the function, if omitted it will be inferred from the type annotation.
    when_used: Determines the serializer will be used for serialization.
    check_fields: Whether to check that the fields actually exist on the model.

Returns:
    The decorator function.
c                    V ^8  d   QhRRRR/# )r   frU   r"   (_decorators.PydanticDescriptorProxy[Any]r#   )r$   s   "r%   r&   &field_serializer.<locals>.__annotate__  s     @ @ @#K @r)   c                f   < \         P                  ! SSSSSR 7      p\         P                  ! W4      # ))r]   r^   r   r   rY   )r   FieldSerializerDecoratorInfoPydanticDescriptorProxy)rl   dec_inforY   r]   r^   r   r   s   & r%   decfield_serializer.<locals>.dec  s5    ;;#%
 221??r)   r#   )r^   r   r   rY   r]   rs   s   ddddj r%   rd   rd      s    n@ @ Jr)   ModelPlainSerializerWithInfoModelPlainSerializerWithoutInfoz>ModelPlainSerializerWithInfo | ModelPlainSerializerWithoutInfoModelPlainSerializerModelWrapSerializerWithInfoModelWrapSerializerWithoutInfoz<ModelWrapSerializerWithInfo | ModelWrapSerializerWithoutInfoModelWrapSerializerz*ModelPlainSerializer | ModelWrapSerializerModelSerializer_ModelPlainSerializerT_ModelWrapSerializerTc                    V ^8  d   QhRRRR/# )r   rl   r|   r"   r#   )r$   s   "r%   r&   r&   G  s     Q Q. Q6L Qr)   c                   R # rb   r#   )rl   s   "r%   model_serializerr   F  s    NQr)   c               (    V ^8  d   QhRRRRRRRR/# )	r   r^   r_   r   r   r   r   r"   z8Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT]r#   )r$   s   "r%   r&   r&   K  s2     C CC)1CKNC=Cr)   c                    R # rb   r#   r^   r   r   s   $$$r%   r   r   J  s	     @Cr)   c               (    V ^8  d   QhRRRRRRRR/# )	r   r^   rf   r   r   r   r   r"   z:Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]r#   )r$   s   "r%   r&   r&   Q  s9     E E
E E 	E
 @Er)   c                    R # rb   r#   r   s   $$$r%   r   r   P  s	     BEr)   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   rl   z5_ModelPlainSerializerT | _ModelWrapSerializerT | Noner^   ri   r   r   r   r   r"   z_ModelPlainSerializerT | Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT] | Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]r#   )r$   s   "r%   r&   r&   Y  sD     G G<G #	G
 G GAGr)   c              :   aaa R VVV3R llpV f   V# V! V 4      # )a  Decorator that enables custom model serialization.

This is useful when a model need to be serialized in a customized manner, allowing for flexibility beyond just specific fields.

An example would be to serialize temperature to the same temperature scale, such as degrees Celsius.

```python
from typing import Literal

from pydantic import BaseModel, model_serializer

class TemperatureModel(BaseModel):
    unit: Literal['C', 'F']
    value: int

    @model_serializer()
    def serialize_model(self):
        if self.unit == 'F':
            return {'unit': 'C', 'value': int((self.value - 32) / 1.8)}
        return {'unit': self.unit, 'value': self.value}

temperature = TemperatureModel(unit='F', value=212)
print(temperature.model_dump())
#> {'unit': 'C', 'value': 100}
```

Two signatures are supported for `mode='plain'`, which is the default:

- `(self)`
- `(self, info: SerializationInfo)`

And two other signatures for `mode='wrap'`:

- `(self, nxt: SerializerFunctionWrapHandler)`
- `(self, nxt: SerializerFunctionWrapHandler, info: SerializationInfo)`

    See [the usage documentation](../concepts/serialization.md#serializers) for more information.

Args:
    f: The function to be decorated.
    mode: The serialization mode.

        - `'plain'` means the function will be called instead of the default serialization logic
        - `'wrap'` means the function will be called with an argument to optionally call the default
            serialization logic.
    when_used: Determines when this serializer should be used.
    return_type: The return type for the function. If omitted it will be inferred from the type annotation.

Returns:
    The decorator function.
c                    V ^8  d   QhRRRR/# )r   rl   r{   r"   rm   r#   )r$   s   "r%   r&   &model_serializer.<locals>.__annotate__  s     @ @ @#K @r)   c                b   < \         P                  ! SSSR 7      p\         P                  ! W4      # ))r^   r   r   )r   ModelSerializerDecoratorInforq   )rl   rr   r^   r   r   s   & r%   rs   model_serializer.<locals>.dec  s*    ;;S^jst221??r)   r#   )rl   r^   r   r   rs   s   "ddd r%   r   r   Y  s%    @@ @ 	y
1vr)   AnyTypec                  J    ] tR tRtRtR R ltR R lt]P                  tRt	R# )	SerializeAsAnyi  zAnnotation used to mark a type as having duck-typing serialization behavior.

See [usage documentation](../concepts/serialization.md#serializing-with-duck-typing) for more details.
c                    V ^8  d   QhRRRR/# )r   itemr   r"   r#   )r$   s   "r%   r&   SerializeAsAny.__annotate__  s     	5 	5 	5 	5r)   c                	0    \         V\        4       3,          # rb   )r   r   )clsr   s   &&r%   __class_getitem__ SerializeAsAny.__class_getitem__  s    T>#3344r)   c               $    V ^8  d   QhRRRRRR/# r   r#   )r$   s   "r%   r&   r     s$     		 		"		-A		#		r)   c                	    V! V4      pTpVR ,          R8X  d   VP                  4       pVR,          pK)  \        P                  ! R4      VR&   V# )typedefinitionsr=   anyr2   )copyr   simple_ser_schema)r<   r    r!   r=   schema_to_updates   &&&  r%   r?   +SerializeAsAny.__get_pydantic_core_schema__  sV     [)F%"6*m;#3#8#8#: #3H#= 0;0M0Me0T_-Mr)   r#   N)
rC   rD   rE   rF   rG   r   r?   object__hash__rI   r#   r)   r%   r   r     s    	
	5		 ??r)   r   r#   rb   )8__conditional_annotations__rG   
__future__r   dataclasses	functoolsr   r   typingr   r   r   r   r	   r
   r   pydantic_corer   r   pydantic_core.core_schemar   r   r   typing_extensionsr    r   	_internalr   r   annotated_handlersr   	dataclass
slots_truer   rK   rR   rH   rS   rT   rU   rV   rX   rd   ru   rv   rw   rx   ry   rz   r{   r|   r}   r   r   r   )r   s   @r%   <module>r      s\   K "  , V V V 8 ` ` ' ) 7 4 E,77EEB B FBJ E,77EEc c FcL =Hi=&Q)Q@%TT?!MOYM0$%=EYZ#$;CVW 
C
 C C !$C 
C 
E !	E
 E E !$E 
EA%,A )	A
 #A !%AH  /7=Ns=S7TVY7Y.Z )ZN193%*1E#YEQ&f)f4-5s<Y[lmp[q6rtw6w-xxM08#?\9]_b9b0c"IcP%cc3!MOYM$%=EYZ#$;CVW 
 Q 
 Q 
C4<CQTC 
C
 
E E #E 	E 
EG &-	G
 #G )G GT )
 w|,N <0;;<# # =#r)   