ó
    pyüiÅF  ã                  ór  • % S r SSKJr  SSKrSSKJrJr  SSKJrJ	r	J
r
JrJrJrJr  SSKJrJr  SSKJrJrJr  SSKJr  S	S
KJr  S	SKJrJr  S	SKJr  S	SKJ r   \RB                  " S=0 \RD                  DSS0D6 " S S5      5       r#\RB                  " S=0 \RD                  DSS0D6 " S S5      5       r$\(       a-  Sr%S\&S'   Sr'S\&S'    Sr(S\&S'    Sr)S\&S'    \" S\'S9r*\" S\(S9r+\S S S S!.             S>S" jj5       r,\S S S S S#.             S?S$ jj5       r,S%\S&SS#.             S@S' jjr,\(       ag  \\
\\
   /\
4   r-S\&S('    \\
/\
4   r.S\&S)'    S*r/S\&S+'    \\
\\\
   /\
4   r0S\&S,'    \\
\/\
4   r1S\&S-'    S.r2S\&S/'    S0r3S\&S1'   \" S2\/S9r4\" S3\2S9r5\SAS4 j5       r6\S&S S5.       SBS6 jj5       r6\S S&S S7.       SCS8 jj5       r6 SDS%S&\S7.         SES9 jjjr6\" S:5      r7\(       a  \	\7S 4   r8g\RB                  " S=0 \RD                  D6 " S; S<5      5       r8g)FzEThis 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                  óJ   • \ rS rSr% SrS\S'   \rS\S'   SrS\S	'   SS
 jr	Sr
g)ÚPlainSerializeré   aË  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                óê  • U" U5      nU R                   [        La  U R                   nO8 [        R                  " U R                  UR                  5       R                  S9nU[        L a  SOUR                  U5      n[        R                  " U R                  [        R                  " U R                  S5      UU R                  S9US'   U$ ! [         a  n[        R                  " U5      UeSnAff = f)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    ©ÚselfÚsource_typeÚhandlerÚschemar   Úer(   s          Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic/functional_serializers.pyÚ__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úó   ª7C Ã
C2ÃC-Ã-C2© N©r4   r   r5   r   Úreturnzcore_schema.CoreSchema©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   r   r    r9   Ú__static_attributes__r<   ó    r8   r   r      s(   ‡ ñð: )Ó(Ø(€K�Ó(Ø"€IˆxÓ"÷ rG   r   c                  óJ   • \ rS rSr% SrS\S'   \rS\S'   SrS\S	'   SS
 jr	Sr
g)ÚWrapSerializeréY   a*  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                óê  • U" U5      nU R                   [        La  U R                   nO8 [        R                  " U R                  UR                  5       R                  S9nU[        L a  SOUR                  U5      n[        R                  " U R                  [        R                  " U R                  S5      UU R                  S9US'   U$ ! [         a  n[        R                  " U5      UeSnAff = f)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%   r)   )r   r   r   r*   r   r+   r,   r-   r   r.   r/   r   Ú#wrap_serializer_function_ser_schemar1   r    r2   s          r8   r9   Ú+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úr;   r<   Nr=   r?   r<   rG   r8   rI   rI   Y   s)   ‡ ñ<ð| -Ó,Ø(€K�Ó(Ø"€IˆxÓ"÷ rG   rI   z!partial[Any] | partialmethod[Any]r   Ú_Partialz)core_schema.SerializerFunction | _PartialÚFieldPlainSerializerz-core_schema.WrapSerializerFunction | _PartialÚFieldWrapSerializerz*FieldPlainSerializer | FieldWrapSerializerÚFieldSerializerÚ_FieldPlainSerializerT)ÚboundÚ_FieldWrapSerializerT.)r   r    Úcheck_fieldsc              ó   • g ©Nr<   ©ÚfieldÚmoder   r    rV   Úfieldss         r8   Úfield_serializerr]   Ð   s	   € ð @CrG   )r[   r   r    rV   c              ó   • g rX   r<   rY   s         r8   r]   r]   Ü   s	   € ð BErG   r$   r   c              óÔ   ^^^^^• [        U 5      (       d  [        U [        5      (       a
  [        SSS9eU /TQ7m[	        S T 5       5      (       d
  [        SSS9eSUUUUU4S jjnU$ )	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   #   • U  H  n[        U[        5      v •  M     g 7frX   )Ú
isinstanceÚstr)Ú.0rZ   s     r8   Ú	<genexpr>Ú#field_serializer.<locals>.<genexpr>*  s   é € Ð:²6¨%Œz˜%¤×%Ð%²6ùs   ‚z›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                ó`   >• [         R                  " TTTTTS9n[         R                  " X5      $ )N)r\   r[   r   r    rV   )r   ÚFieldSerializerDecoratorInfoÚPydanticDescriptorProxy)ÚfÚdec_inforV   r\   r[   r   r    s     €€€€€r8   ÚdecÚfield_serializer.<locals>.dec1  s5   ø€ Ü×;Ò;ØØØ#ØØ%ñ
ˆô ×2Ò2°1Ó?Ð?rG   )rj   rR   r>   ú(_decorators.PydanticDescriptorProxy[Any])Úcallablerb   Úclassmethodr   Úall)rZ   r[   r   r    rV   r\   rl   s    ````` r8   r]   r]   è   sx   ü€ ôt �‡�œ* U¬K×8Ñ8ÜðEà.ñ
ð 	
ð ˆ^�V‰^€FÜÑ:±6Ó:×:Ñ:ÜðYà+ñ
ð 	
÷@ó @ð €JrG   ÚModelPlainSerializerWithInfoÚModelPlainSerializerWithoutInfoz>ModelPlainSerializerWithInfo | ModelPlainSerializerWithoutInfoÚModelPlainSerializerÚModelWrapSerializerWithInfoÚModelWrapSerializerWithoutInfoz<ModelWrapSerializerWithInfo | ModelWrapSerializerWithoutInfoÚModelWrapSerializerz*ModelPlainSerializer | ModelWrapSerializerÚModelSerializerÚ_ModelPlainSerializerTÚ_ModelWrapSerializerTc               ó   • g rX   r<   )rj   s    r8   Úmodel_serializerr|   Y  s   € ØNQrG   )r    r   c                ó   • g rX   r<   ©r[   r    r   s      r8   r|   r|   ]  s	   € ð @CrG   r~   c                ó   • g rX   r<   r~   s      r8   r|   r|   c  s	   € ð BErG   c              ó6   ^^^• SUUU4S jjnU c  U$ U" U 5      $ )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                ó\   >• [         R                  " TTTS9n[         R                  " X5      $ )N)r[   r   r    )r   ÚModelSerializerDecoratorInfori   )rj   rk   r[   r   r    s     €€€r8   rl   Úmodel_serializer.<locals>.dec¬  s*   ø€ Ü×;Ò;ÀÐS^ÐjsÑtˆÜ×2Ò2°1Ó?Ð?rG   )rj   rx   r>   rn   r<   )rj   r[   r    r   rl   s    ``` r8   r|   r|   l  s%   ú€ ÷@@ñ @ð 	�yØˆ
á�1‹vˆrG   ÚAnyTypec                  óP   • \ rS rSrSrSS jr      SS jr\R                  rSr	g)	Ú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                ó(   • [         U[        5       4   $ rX   )r   r†   )ÚclsÚitems     r8   Ú__class_getitem__Ú SerializeAsAny.__class_getitem__È  s   € Ü˜T¤>Ó#3Ð3Ñ4Ð4rG   c                óž   • U" U5      nUnUS   S:X  a   UR                  5       nUS   nUS   S:X  a  M   [        R                  " S5      US'   U$ )NÚtypeÚdefinitionsr6   Úanyr)   )Úcopyr   Úsimple_ser_schema)r3   r4   r5   r6   Úschema_to_updates        r8   r9   Ú+SerializeAsAny.__get_pydantic_core_schema__Ë  sg   € ñ ˜[Ó)ˆFØ%ÐØ" 6Ñ*¨mÓ;Ø#3×#8Ñ#8Ó#:Ð Ø#3°HÑ#=Ð ð # 6Ñ*¨mÕ;ô 1<×0MÒ0MÈeÓ0TÐ˜_Ñ-ØˆMrG   r<   N)r‰   r   r>   r   r=   )
r@   rA   rB   rC   rD   rŠ   r9   ÚobjectÚ__hash__rF   r<   rG   r8   r†   r†   Á  s4   † ñ	ô
	5ð		Ø"ð		Ø-Að		à#ô		ð —?‘?‹rG   r†   r<   )rZ   rc   r\   rc   r[   úLiteral['wrap']r   r   r    r   rV   úbool | Noner>   z8Callable[[_FieldWrapSerializerT], _FieldWrapSerializerT])rZ   rc   r\   rc   r[   úLiteral['plain']r   r   r    r   rV   r—   r>   z:Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT])rZ   rc   r\   rc   r[   úLiteral['plain', 'wrap']r   r   r    r   rV   r—   r>   zuCallable[[_FieldWrapSerializerT], _FieldWrapSerializerT] | Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT])rj   ry   r>   ry   )r[   r–   r    r   r   r   r>   z8Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT])r[   r˜   r    r   r   r   r>   z:Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]rX   )
rj   z5_ModelPlainSerializerT | _ModelWrapSerializerT | Noner[   r™   r    r   r   r   r>   zŽ_ModelPlainSerializerT | Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT] | Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT])9rD   Ú
__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   rI   rO   rE   rP   rQ   rR   rS   rU   r]   rr   rs   rt   ru   rv   rw   rx   ry   rz   r|   r„   r†   r<   rG   r8   Ú<module>r§      sG  ðÚ 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ð ðCð ðCð >ôCó 
ðCð 
ð
 !ØØØ #ñEØðEð ðEð ð	Eð
 ðEð ðEð ðEð @ôEó 
ðEð &-à(Ø"Ø $ñSØðSð ðSð #ð	Sð ðSð ðSð ðSðAõ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ð 
à4<ÐQTñCØðCØ)1ðCØKNðCà=ôCó 
ðCð
 
ð !Ø"Øñ	Eà
ðEð ðEð ð	Eð
 @ôEó 
ðEð @DðGð &-Ø"Ø(ñGØ<ðGð #ð	Gð
 ðGð ðGðAöGñT �)Ó
€ö Ø˜w¨˜|Ñ,€Nðð ×ÒÑ<Ð0×;Ñ;Ñ<÷#ð #ó =ñ#rG   