o
    FÊÆh*  ã                   @  sD  U d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZmZ ddlmZ ddlmZmZmZ d	d
lmZ d	dlmZmZ d	dlmZ ejd?i ej¤ddi¤ŽG dd„ dƒƒZejd?i ej¤ddi¤ŽG dd„ dƒƒZer©ee eeef e!eef ee f Z"de#d< eej$e"f Z%eej&e"f Z'e
de%d�Z(e
de'd�Z)eddddœd@d%d&„ƒZ*eddddœdAd)d&„ƒZ*eddddœdBd,d&„ƒZ*d-ed.dd/œdCd2d&„Z*e
d3e	def d�Z+edDd5d6„ƒZ,edd.dd7œdEd9d6„ƒZ,	dFd-d.ed7œdGd;d6„Z,e
d<ƒZ-e�ree-df Z.dS ejd?i ej¤ŽG d=d>„ d>ƒƒZ.dS )HzEThis module contains related classes and functions for serialization.é    )ÚannotationsN)Úpartialmethod)ÚTYPE_CHECKINGÚAnyÚCallableÚTypeVarÚUnionÚoverload)ÚPydanticUndefinedÚcore_schema)r   )Ú	AnnotatedÚLiteralÚ	TypeAliasé   )ÚPydanticUndefinedAnnotation)Ú_decoratorsÚ_internal_dataclass)ÚGetCoreSchemaHandlerÚfrozenTc                   @  ó<   e Zd ZU dZded< eZded< dZded< ddd„ZdS )ÚPlainSerializera·  Plain serializers use a function to modify the output of serialization.

    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Úalwaysú<Literal['always', 'unless-none', 'json', 'json-unless-none']Ú	when_usedÚsource_typeÚhandlerr   Úreturnúcore_schema.CoreSchemac              
   C  ó†   ||ƒ}zt  | j| j| ¡ ¡}W n ty# } zt |¡|‚d}~ww |tu r*dn| 	|¡}t
j| jt  | jd¡|| jd�|d< |S )zÒGets the Pydantic core schema.

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

        Returns:
            The Pydantic core schema.
        NÚplain©ÚfunctionÚinfo_argÚreturn_schemar   Úserialization)r   Úget_function_return_typer   r   Ú_get_types_namespaceÚ	NameErrorr   Úfrom_name_errorr
   Úgenerate_schemar   Ú$plain_serializer_function_ser_schemaÚinspect_annotated_serializerr   ©Úselfr   r   Úschemar   Úer%   © r2   úl/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/pydantic/functional_serializers.pyÚ__get_pydantic_core_schema__    ó"   
ÿ€ÿ
üz,PlainSerializer.__get_pydantic_core_schema__N©r   r   r   r   r   r   ©	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r
   r   r   r4   r2   r2   r2   r3   r      s   
 	r   c                   @  r   )ÚWrapSerializeraS  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.

    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              
   C  r    )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.
        NÚwrapr"   r&   )r   r'   r   r   r(   r)   r   r*   r
   r+   r   Ú#wrap_serializer_function_ser_schemar-   r   r.   r2   r2   r3   r4   K   r5   z+WrapSerializer.__get_pydantic_core_schema__Nr6   r7   r2   r2   r2   r3   r=   ;   s   
 
r=   r   Ú_PartialClsOrStaticMethodÚ_PlainSerializeMethodType)ÚboundÚ_WrapSerializeMethodType.)r   r   Úcheck_fieldsÚ__fieldÚstrÚfieldsr   r   r   r   rD   úbool | Noner   ú@Callable[[_PlainSerializeMethodType], _PlainSerializeMethodType]c                G  ó   d S ©Nr2   )rE   r   r   rD   rG   r2   r2   r3   Úfield_serializern   s   rL   ÚmodeúLiteral['plain']c                G  rJ   rK   r2   ©rE   rM   r   r   rD   rG   r2   r2   r3   rL   y   ó   	úLiteral['wrap']ú>Callable[[_WrapSerializeMethodType], _WrapSerializeMethodType]c                G  rJ   rK   r2   rO   r2   r2   r3   rL   …   rP   r!   r   )rM   r   r   rD   úLiteral['plain', 'wrap']úCallable[[Any], Any]c                   s   d‡ ‡‡‡‡fdd„}|S )	a{  Decorator that enables custom field serialization.

    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.
    ÚfúHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]r   ú(_decorators.PydanticDescriptorProxy[Any]c                   s    t jˆˆˆˆˆ d�}t  | |¡S )N)rG   rM   r   r   rD   )r   ÚFieldSerializerDecoratorInfoÚPydanticDescriptorProxy©rU   Údec_info©rD   rG   rM   r   r   r2   r3   Údec²   s   ûzfield_serializer.<locals>.decN)rU   rV   r   rW   r2   )rM   r   r   rD   rG   r]   r2   r\   r3   rL   ‘   s   !ÚFuncTypeÚ__fc                 C  rJ   rK   r2   )r_   r2   r2   r3   Úmodel_serializerÄ   s   r`   ©rM   r   r   úCallable[[FuncType], FuncType]c                 C  rJ   rK   r2   ra   r2   r2   r3   r`   É   s   úCallable[..., Any] | Nonec                  s&   d‡ ‡‡fdd„}| du r|S || ƒS )	aÍ  Decorator that enables custom model serialization.

    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.
    rU   úCallable[..., Any]r   rW   c                   s   t jˆ ˆˆd�}t  | |¡S )N©rM   r   r   )r   ÚModelSerializerDecoratorInforY   rZ   re   r2   r3   r]   ì   s   zmodel_serializer.<locals>.decN)rU   rd   r   rW   r2   )r_   rM   r   r   r]   r2   re   r3   r`   Ó   s   ÚAnyTypec                   @  s&   e Zd Zddd„Zdd
d„ZejZdS )ÚSerializeAsAnyÚitemr   r   c                 C  s   t |tƒ f S rK   )r   rh   )Úclsri   r2   r2   r3   Ú__class_getitem__  s   z SerializeAsAny.__class_getitem__r   r   r   r   c                 C  sR   ||ƒ}|}|d dkr|  ¡ }|d }|d dkstjdd„ t ¡ d�|d< |S )NÚtypeÚdefinitionsr0   c                 S  s   || ƒS rK   r2   )ÚxÚhr2   r2   r3   Ú<lambda>  s    z=SerializeAsAny.__get_pydantic_core_schema__.<locals>.<lambda>)r0   r&   )Úcopyr   r?   Ú
any_schema)r/   r   r   r0   Úschema_to_updater2   r2   r3   r4     s   þ
ÿz+SerializeAsAny.__get_pydantic_core_schema__N)ri   r   r   r   r6   )r8   r9   r:   rk   r4   ÚobjectÚ__hash__r2   r2   r2   r3   rh     s    


rh   r2   )rE   rF   rG   rF   r   r   r   r   rD   rH   r   rI   )rE   rF   rG   rF   rM   rN   r   r   r   r   rD   rH   r   rI   )rE   rF   rG   rF   rM   rQ   r   r   r   r   rD   rH   r   rR   )rG   rF   rM   rS   r   r   r   r   rD   rH   r   rT   )r_   r^   r   r^   )rM   rS   r   r   r   r   r   rb   rK   )
r_   rc   rM   rS   r   r   r   r   r   rT   )/r;   Ú
__future__r   ÚdataclassesÚ	functoolsr   Útypingr   r   r   r   r   r	   Úpydantic_corer
   r   Ú_core_schemaÚtyping_extensionsr   r   r   Ú r   Ú	_internalr   r   Úannotated_handlersr   Ú	dataclassÚ
slots_truer   r=   ÚclassmethodÚstaticmethodr@   r<   ÚSerializerFunctionÚ_PlainSerializationFunctionÚWrapSerializerFunctionÚ_WrapSerializationFunctionrA   rC   rL   r^   r`   rg   rh   r2   r2   r2   r3   Ú<module>   sz     )*,û
úúû0ü
ÿû#