+
    AiF              	      |  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   "]/var/www/html/photoedit/myenv/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)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   er2   s   &&&    r&   __get_pydantic_core_schema__,PlainSerializer.__get_pydantic_core_schema__6   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^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)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/   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II#88:AA !,/@ @gF]F]^iFj"-"Q"QYY ==diiP'nn	#
   L1AA!D!KLrB   r$   NrC   r$   r*   r&   rL   rL   Y   s.    <| -,(K("Ix"   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.
zThe `@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%%%6s   FTzThe 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21??r*   )callablern   classmethodr   all)r\   r_   r   r   rZ   r^   rz   s   "ddddj r&   re   re      s    t *UK88E.
 	
 ^V^F3:6:333: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. Q6L 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21??r*   r$   )rs   r_   r   r   rz   s   "ddd r&   r   r   l  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,          # 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#: #3H#= 0;0M0Me0T_-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 =Hi=&Q)Q@%TT?!MOYM0$%=EYZ#$;CVW 
C
 C C !$C 
C 
E !	E
 E E !$E 
ES &-	S )S #S !%Sl  /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*   