+
    NV-jÅF  ã            	      ó|  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 ^RI H!t! ]PD                  ! RB/ ]PF                  BRR/B  ! R R4      4       t$]PD                  ! RB/ ]PF                  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-t0R]'R.&    ]]]]],          .]3,          t1R]'R/&    ]]].]3,          t2R]'R0&    R1t3R]'R2&    R3t4R]'R4&   ]! R5]0R7      t5]! R6]3R7      t6]R7 R8 l4       t7]R R(RR/R9 R: ll4       t7]R$RR R(RR/R; R< ll4       t7RCR$R'R R(R]/R= R> lllt7]! R?4      t8]	'       d   ]
]8R3,          t9R# ]PD                  ! RB/ ]PF                  B  ! R@ RA4      4       t9R# )DzEThis 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)ÚPydanticUserErrorÚ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   "Úp/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/pydantic/functional_serializers.pyÚ__annotate__ÚPlainSerializer.__annotate__6   ó#   € ÷  ñ  ¸ð  Ð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)z¢Gets 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   Úer2   s   &&&    r&   Ú__get_pydantic_core_schema__Ú,PlainSerializer.__get_pydantic_core_schema__6   sÞ   € ñ ˜Ó%ˆØ×ÑÔ#4Ó4Ø×*Ñ*‰Kð	Lô *×BÒBØ—I‘IØ#×8Ñ8Ó:×AÑAô�ð !,Ô/@Ó @™Àg×F]ÑF]Ð^iÓFjˆÜ"-×"RÒ"RØ—Y‘YÜ ×=Ò=¸d¿i¹iÈÓQØ'Ø—n‘nô	#
ˆˆÑð ˆøô ô 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�Ó(Ø"€IˆxÓ"÷ ñ  r*   r   c                  óN   € ] tR t^Yt$ 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)z¿This 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/   r3   )r   r   r   r4   r   r5   r6   r7   r   r8   r9   r   Ú#wrap_serializer_function_ser_schemar;   r   r<   s   &&&    r&   r@   Ú+WrapSerializer.__get_pydantic_core_schema__�   sÞ   € ñ ˜Ó%ˆØ×ÑÔ#4Ó4Ø×*Ñ*‰Kð	Lô *×BÒBØ—I‘IØ#×8Ñ8Ó:×AÑAô�ð !,Ô/@Ó @™Àg×F]ÑF]Ð^iÓFjˆÜ"-×"QÒ"QØ—Y‘YÜ ×=Ò=¸d¿i¹iÈÓPØ'Ø—n‘nô	#
ˆˆÑð ˆøô ô LÜ1×AÒAÀ!ÓDÈ!ÐKûðLúrB   r$   NrC   r$   r*   r&   rL   rL   Y   s.   ‡ ñ<ð| -Ó,Ø(€K�Ó(Ø"€IˆxÓ"÷ ñ  r*   rL   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   rZ   ú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   rZ   r^   s   "$$$$*r&   Úfield_serializerre   Ð   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   rZ   ra   r#   z:Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]r$   )r%   s   "r&   r'   r'   Ý   sZ   € ÷ Eñ EØðEð ðEð ð	Eð
 ðEð ðEð ðEð @ñEr*   c              ó   € R # rc   r$   rd   s   "$$$$*r&   re   re   Ü   s	   € ñ BEr*   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', 'wrap']r   r   r   r   rZ   ra   r#   zuCallable[[_FieldWrapSerializerT], _FieldWrapSerializerT] | Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]r$   )r%   s   "r&   r'   r'   è   sZ   € ÷ Sñ SØðSð ðSð #ð	Sð ðSð ðSð ðSðAñSr*   c              ó,  aaaaa€ \        V 4      '       g   \        V \        4      '       d   \        RRR7      hV .SO5o\        ;QJ d    R S 4       F  '       d   K   RM	  RM! R S 4       4      '       g   \        RRR7      hR	 VVVVV3R
 llpV# )a5  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 for the decorated serializer:

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

Args:
    *fields: The field names the serializer should apply to.
    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.

Raises:
    PydanticUserError:
        - If the decorator is used without any arguments (at least one field name must be provided).
        - If the provided field names are not strings.
zŸThe `@field_serializer` decorator cannot be used without arguments, at least one field must be provided. For example: `@field_serializer('<field_name>', ...)`.zdecorator-missing-arguments)Úcodec              3  óB   "  € T F  p\        V\        4      x € K  	  R # 5irc   )Ú
isinstancer]   )Ú.0r\   s   & r&   Ú	<genexpr>Ú#field_serializer.<locals>.<genexpr>*  s   é € Ð:±6¨%Œz˜%¤×%Ð%³6ùs   ‚FTz›The provided field names to the `@field_serializer` decorator should be strings. For example: `@field_serializer('<field_name_1>', '<field_name_2>', ...).`zdecorator-invalid-fieldsc               ó    € V ^8„  d   QhRRRR/# )r    ÚfrV   r#   ú(_decorators.PydanticDescriptorProxy[Any]r$   )r%   s   "r&   r'   Ú&field_serializer.<locals>.__annotate__1  s   € ÷ @ñ @ˆð @Ð#Kñ @r*   c                óf   <€ \         P                  ! SSSSSR 7      p\         P                  ! W4      # ))r^   r_   r   r   rZ   )r   ÚFieldSerializerDecoratorInfoÚPydanticDescriptorProxy)rs   Údec_inforZ   r^   r_   r   r   s   & €€€€€r&   ÚdecÚfield_serializer.<locals>.dec1  s5   ø€ Ü×;Ò;ØØØ#ØØ%ô
ˆô ×2Ò2°1Ó?Ð?r*   )Úcallablern   Úclassmethodr   Úall)r\   r_   r   r   rZ   r^   rz   s   "ddddj r&   re   re   è   sˆ   ü€ ôt �‡‚œ* U¬K×8Ò8ÜðEà.ô
ð 	
ð ˆ^�V‰^€Fß‹3Ñ:±6Ó:�3�3Š3Ñ:±6Ó:×:Ò:ÜðYà+ô
ð 	
÷@ô @ð €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    rs   r†   r#   r$   )r%   s   "r&   r'   r'   Z  s   € × QÑ QÐ.Ð QÐ6LÑ Qr*   c               ó   € R # rc   r$   )rs   s   "r&   Úmodel_serializerrŠ   Y  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'   ^  s2   € ÷ Cñ CØðCØ)1ðCØKNðCà=ñCr*   c                ó   € R # rc   r$   ©r_   r   r   s   $$$r&   rŠ   rŠ   ]  s	   € ñ @Cr*   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r    r_   rg   r   r   r   r   r#   z:Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]r$   )r%   s   "r&   r'   r'   d  s9   € ÷ Eñ Eà
ðEð ðEð ð	Eð
 @ñEr*   c                ó   € R # rc   r$   r�   s   $$$r&   rŠ   rŠ   c  s	   € ñ BEr*   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r    rs   z5_ModelPlainSerializerT | _ModelWrapSerializerT | Noner_   rj   r   r   r   r   r#   zŽ_ModelPlainSerializerT | Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT] | Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]r$   )r%   s   "r&   r'   r'   l  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    rs   r…   r#   rt   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   ÚModelSerializerDecoratorInforx   )rs   ry   r_   r   r   s   & €€€r&   rz   Úmodel_serializer.<locals>.dec¬  s*   ø€ Ü×;Ò;ÀÐS^ÐjsÔtˆÜ×2Ò2°1Ó?Ð?r*   r$   )rs   r_   r   r   rz   s   "ddd r&   rŠ   rŠ   l  s%   ú€ ÷@@ò @ð 	‚yØˆ
á�1‹vˆr*   ÚAnyTypec                  óJ   € ] tR tRtRtR R ltR R lt]P                  tRt	R# )	ÚSerializeAsAnyiÁ  zµAnnotation 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,          # rc   )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>   Úanyr3   )Ú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Ó#:Ð Ø#3°HÕ#=Ò Ü0;×0MÒ0MÈeÓ0TÐ˜_Ñ-ØˆMr*   r$   N)
rD   rE   rF   rG   rH   rŸ   r@   ÚobjectÚ__hash__rJ   r$   r*   r&   r™   r™   Á  s   † ñ	õ
	5õ		ð —?‘?Œr*   r™   r$   rc   ):Ú__conditional_annotations__rH   Ú
__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   Úerrorsr   Ú	dataclassÚ
slots_truer   rL   rS   rI   rT   rU   rV   rW   rY   re   r   r€   r�   r‚   rƒ   r„   r…   r†   r‡   rŠ   r—   r™   )r¬   s   @r&   Ú<module>rº      sa  øðÜ 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 Ø=€HˆiÓ=à&QÐ˜)ÓQØ@à%TÐ˜ÓTØ?à!M€O�YÓMØ0á$Ð%=ÐEYÔZÐÙ#Ð$;ÐCVÔWÐð 
ðCð
 ðCð ðCð !$öCó 
ðCð 
ðEð !ð	Eð
 ðEð ðEð !$öEó 
ðEðSð &-ð	Sð )ðSð #ðSð !%÷S÷l ð /7¸Ð=NÈsÕ=SÐ7TÐVYÐ7YÕ.ZÐ  )ÓZØNà19¸3¸%À¸*Õ1EÐ# YÓEØQà&fÐ˜)ÓfØ4à-5°sÐ<YÐ[lÐmpÕ[qÐ6rÐtwÐ6wÕ-xÐ ÓxØMà08¸#Ð?\Ð9]Ð_bÐ9bÕ0cÐ" IÓcØPà%cÐ˜ÓcØ3à!M€O�YÓ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*   