§
    Ë! hÎB  ã                  ó  — U d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
mZmZmZmZ ddlmZmZ ddlmZmZmZ ddlmZ d	d
lmZ d	dlmZmZ d	dlmZ  ej        dRi ej         ¤ddi¤Ž G d„ d¦  «        ¦   «         Z! ej        dRi ej         ¤ddi¤Ž G d„ d¦  «        ¦   «         Z"er9dZ#de$d<   dZ%de$d<   	 dZ&de$d<   	 dZ'de$d<   	  ede%¬¦  «        Z( ede&¬¦  «        Z)edddd œdSd.„¦   «         Z*eddddd/œdTd2„¦   «         Z*d3ed4dd/œdUd7„Z*eryee
ege
f         Z+de$d8<   	 ee
ge
f         Z,de$d9<   	 d:Z-de$d;<   	 ee
eege
f         Z.de$d<<   	 ee
ege
f         Z/de$d=<   	 d>Z0de$d?<   	 d@Z1de$dA<    edBe-¬¦  «        Z2 edCe0¬¦  «        Z3edVdE„¦   «         Z4ed4ddFœdWdH„¦   «         Z4edd4ddIœdXdK„¦   «         Z4	 dYd3d4edIœdZdN„Z4 edO¦  «        Z5ere	e5df         Z6dS  ej        dRi ej         ¤Ž G dP„ dQ¦  «        ¦   «         Z6dS )[zEThis 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                  óB   — e Zd ZU dZded<   eZded<   dZded<   dd„ZdS )Ú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_usedÚsource_typeÚhandlerr   Úreturnúcore_schema.CoreSchemac                ó¸  —  ||¦  «        }| j         t          ur| j         }n[	 t          j        | j        |                     ¦   «         j        ¬¦  «        }n'# t          $ r}t          j	        |¦  «        |‚d}~ww xY w|t          u rdn| 
                    |¦  «        }t          j        | j        t          j        | j        d¦  «        || j        ¬¦  «        |d<   |S )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   Úer*   s          úYc:\xampp_lite_8_4\www\timesheet\venv\Lib\site-packages\pydantic/functional_serializers.pyÚ__get_pydantic_core_schema__z,PlainSerializer.__get_pydantic_core_schema__5   s  € ð �˜Ñ%Ô%ˆØÔÕ#4Ð4Ð4ØÔ*ˆKˆKð	Lõ *ÔBØ”IØ#×8Ò8Ñ:Ô:ÔAðñ ô ��øõ ð Lð Lð LÝ1ÔAÀ!ÑDÔDÈ!ÐKøøøøðLøøøð !,Õ/@Ð @Ð @˜˜Àg×F]ÒF]Ð^iÑFjÔFjˆÝ"-Ô"RØ”YÝ Ô=¸d¼iÈÑQÔQØ'Ø”nð	#
ñ #
ô #
ˆˆÑð ˆó   £2A Á
A:Á A5Á5A:N©r   r   r    r   r!   r"   ©	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r9   © ó    r8   r   r      sd   € € € € € € ðð ð: )Ð(Ð(Ñ(Ø(€KÐ(Ð(Ð(Ñ(Ø"€IÐ"Ð"Ð"Ñ"ð ð  ð  ð  ð  ð  rC   r   c                  óB   — e Zd ZU dZded<   eZded<   dZded<   dd„ZdS )Ú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   r   r    r   r!   r"   c                ó¸  —  ||¦  «        }| j         t          ur| j         }n[	 t          j        | j        |                     ¦   «         j        ¬¦  «        }n'# t          $ r}t          j	        |¦  «        |‚d}~ww xY w|t          u rdn| 
                    |¦  «        }t          j        | j        t          j        | j        d¦  «        || j        ¬¦  «        |d<   |S )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   r0   r1   r   Ú#wrap_serializer_function_ser_schemar3   r   r4   s          r8   r9   z+WrapSerializer.__get_pydantic_core_schema__œ   s  € ð �˜Ñ%Ô%ˆØÔÕ#4Ð4Ð4ØÔ*ˆKˆKð	Lõ *ÔBØ”IØ#×8Ò8Ñ:Ô:ÔAðñ ô ��øõ ð Lð Lð LÝ1ÔAÀ!ÑDÔDÈ!ÐKøøøøðLøøøð !,Õ/@Ð @Ð @˜˜Àg×F]ÒF]Ð^iÑFjÔFjˆÝ"-Ô"QØ”YÝ Ô=¸d¼iÈÑPÔPØ'Ø”nð	#
ñ #
ô #
ˆˆÑð ˆr:   Nr;   r<   rB   rC   r8   rE   rE   X   se   € € € € € € ð<ð <ð| -Ð,Ð,Ñ,Ø(€KÐ(Ð(Ð(Ñ(Ø"€IÐ"Ð"Ð"Ñ"ð ð  ð  ð  ð  ð  rC   rE   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_fieldsÚfieldÚstrÚfieldsÚmodeúLiteral['wrap']r   r   r   r   rP   úbool | Noner!   ú8Callable[[_FieldWrapSerializerT], _FieldWrapSerializerT]c              ó   — d S ©NrB   ©rQ   rT   r   r   rP   rS   s         r8   Úfield_serializerr[   Ï   s   € ð @C¸srC   )rT   r   r   rP   úLiteral['plain']ú:Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]c              ó   — d S rY   rB   rZ   s         r8   r[   r[   Û   s   € ð BEÀrC   r&   r   úLiteral['plain', 'wrap']úuCallable[[_FieldWrapSerializerT], _FieldWrapSerializerT] | Callable[[_FieldPlainSerializerT], _FieldPlainSerializerT]c                ó$   ‡ ‡‡‡‡— dˆˆˆ ˆˆfd„}|S )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 typing import Set

    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 [Custom serializers](../concepts/serialization.md#custom-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.
    ÚfrL   r!   ú(_decorators.PydanticDescriptorProxy[Any]c                ó`   •— t          j        ‰‰‰‰‰¬¦  «        }t          j        | |¦  «        S )N)rS   rT   r   r   rP   )r   ÚFieldSerializerDecoratorInfoÚPydanticDescriptorProxy)rb   Údec_inforP   rS   rT   r   r   s     €€€€€r8   Údeczfield_serializer.<locals>.dec  s>   ø€ ÝÔ;ØØØ#ØØ%ð
ñ 
ô 
ˆõ Ô2°1°hÑ?Ô?Ð?rC   )rb   rL   r!   rc   rB   )rT   r   r   rP   rS   rh   s   ````` r8   r[   r[   ç   sK   øøøøø€ ðp@ð @ð @ð @ð @ð @ð @ð @ð @ð @ð €JrC   ÚModelPlainSerializerWithInfoÚModelPlainSerializerWithoutInfoz>ModelPlainSerializerWithInfo | ModelPlainSerializerWithoutInfoÚModelPlainSerializerÚModelWrapSerializerWithInfoÚModelWrapSerializerWithoutInfoz<ModelWrapSerializerWithInfo | ModelWrapSerializerWithoutInfoÚModelWrapSerializerz*ModelPlainSerializer | ModelWrapSerializerÚModelSerializerÚ_ModelPlainSerializerTÚ_ModelWrapSerializerTrb   c               ó   — d S rY   rB   )rb   s    r8   Úmodel_serializerrs   G  s   € ØNQÈcrC   )r   r   ú8Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT]c                ó   — d S rY   rB   ©rT   r   r   s      r8   rs   rs   K  s   € ð @C¸srC   rv   ú:Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]c                ó   — d S rY   rB   rv   s      r8   rs   rs   Q  s   € ð BEÀrC   ú5_ModelPlainSerializerT | _ModelWrapSerializerT | NoneúŽ_ModelPlainSerializerT | Callable[[_ModelWrapSerializerT], _ModelWrapSerializerT] | Callable[[_ModelPlainSerializerT], _ModelPlainSerializerT]c              ó6   ‡‡‡— dˆˆˆfd„}| €|S  || ¦  «        S )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 [Custom serializers](../concepts/serialization.md#custom-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.
    rb   ro   r!   rc   c                ó\   •— t          j        ‰‰‰¬¦  «        }t          j        | |¦  «        S )N)rT   r   r   )r   ÚModelSerializerDecoratorInforf   )rb   rg   rT   r   r   s     €€€r8   rh   zmodel_serializer.<locals>.decš  s/   ø€ ÝÔ;ÀÐS^ÐjsÐtÑtÔtˆÝÔ2°1°hÑ?Ô?Ð?rC   N)rb   ro   r!   rc   rB   )rb   rT   r   r   rh   s    ``` r8   rs   rs   Z  sO   øøø€ ð@@ð @ð @ð @ð @ð @ð @ð @ð 	€yØˆ
àˆs�1‰vŒvˆrC   ÚAnyTypec                  ó,   — e Zd Zdd„Zdd	„Zej        Zd
S )ÚSerializeAsAnyÚitemr   r!   c                ó8   — t           |t          ¦   «         f         S rY   )r   r€   )Úclsr�   s     r8   Ú__class_getitem__z SerializeAsAny.__class_getitem__²  s   € Ý˜T¥>Ñ#3Ô#3Ð3Ô4Ð4rC   r   r    r   r"   c                óÞ   —  ||¦  «        }|}|d         dk    r(|                      ¦   «         }|d         }|d         dk    °(t          j        d„ t          j        ¦   «         ¬¦  «        |d<   |S )NÚtypeÚdefinitionsr6   c                ó   —  || ¦  «        S rY   rB   )ÚxÚhs     r8   ú<lambda>z=SerializeAsAny.__get_pydantic_core_schema__.<locals>.<lambda>¾  s   € ˜Q˜Q˜q™TœT€ rC   )r6   r+   )Úcopyr   rH   Ú
any_schema)r5   r   r    r6   Úschema_to_updates        r8   r9   z+SerializeAsAny.__get_pydantic_core_schema__µ  s�   € ð �W˜[Ñ)Ô)ˆFØ%ÐØ" 6Ô*¨mÒ;Ð;Ø#3×#8Ò#8Ñ#:Ô#:Ð Ø#3°HÔ#=Ð ð # 6Ô*¨mÒ;Ð;õ 1<Ô0_Ø!Ð!­+Ô*@Ñ*BÔ*Bð1ñ 1ô 1Ð˜_Ñ-ð ˆMrC   N)r�   r   r!   r   r;   )r=   r>   r?   r„   r9   ÚobjectÚ__hash__rB   rC   r8   r€   r€   °  s?   € € € € € ð	5ð 	5ð 	5ð 	5ð	ð 	ð 	ð 	ð ”?ˆˆˆrC   r€   rB   )rQ   rR   rS   rR   rT   rU   r   r   r   r   rP   rV   r!   rW   )rQ   rR   rS   rR   rT   r\   r   r   r   r   rP   rV   r!   r]   )rS   rR   rT   r_   r   r   r   r   rP   rV   r!   r`   )rb   rp   r!   rp   )rT   rU   r   r   r   r   r!   rt   )rT   r\   r   r   r   r   r!   rw   rY   )
rb   ry   rT   r_   r   r   r   r   r!   rz   )7r@   Ú
__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   rE   rI   rA   rJ   rK   rL   rM   rO   r[   ri   rj   rk   rl   rm   rn   ro   rp   rq   rs   r~   r€   rB   rC   r8   ú<module>r�      sN  ðØ KÐ KÐ Kà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ Và 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à )Ð )Ð )Ð )Ð )Ð )Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4ð €ÔÐEÐEÐ,Ô7ÐEÐEÀÐEÐEÐEðBð Bð Bð Bð Bñ Bô Bñ FÔEðBðJ €ÔÐEÐEÐ,Ô7ÐEÐEÀÐEÐEÐEðcð cð cð cð cñ cô cñ FÔEðcðL ð XØ=€HÐ=Ð=Ð=Ñ=à&QÐÐQÐQÐQÑQØ@à%TÐÐTÐTÐTÑTØ?à!M€OÐMÐMÐMÑMØ0à$˜WÐ%=ÐEYÐZÑZÔZÐØ#˜GÐ$;ÐCVÐWÑWÔWÐð 
ð ØØ #ðCð Cð Cð Cð Cñ 
„ðCð 
ð
 !ØØØ #ðEð Eð Eð Eð Eñ 
„ðEð &-Ø(Ø"Ø $ðBð Bð Bð Bð Bð BðJ ð Xð /7¸Ð=NÐ7OÐQTÐ7TÔ.UÐ ÐUÐUÐUÑUØNà19¸3¸%À¸*Ô1EÐ#ÐEÐEÐEÑEØQà&fÐÐfÐfÐfÑfØ4à-5°sÐ<YÐ[lÐ6mÐorÐ6rÔ-sÐÐsÐsÐsÑsØMà08¸#Ð?\Ð9]Ð_bÐ9bÔ0cÐ"ÐcÐcÐcÑcØPà%cÐÐcÐcÐcÑcØ3à!M€OÐMÐMÐMÑMà$˜WÐ%=ÐEYÐZÑZÔZÐØ#˜GÐ$;ÐCVÐWÑWÔWÐð 
Ø QÐ QÐ Qñ 
„Ø Qð 
à4<ÐQTðCð Cð Cð Cð Cñ 
„ðCð
 
ð !Ø"Øð	Eð Eð Eð Eð Eñ 
„ðEð @DðGð &-Ø"Ø(ðGð Gð Gð Gð Gð GðT ˆ'�)Ñ
Ô
€ð ð #Ø˜w¨˜|Ô,€Nðð ð €[ÔÐ<Ð<Ð0Ô;Ð<Ð<ð#ð #ð #ð #ð #ñ #ô #ñ =Ô<ð#ð #ð #rC   