o
    $6dN*                     @  s<  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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re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d@d(d%Z)edddddAd+d%Z)d,ed-dd.dBd1d%Z)e
d2e	def dZ*edCd4d5Z+edd-dd6dDd8d5Z+	dEd,d-ed6dFd:d5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 )GzEThis 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)_annotated_handlers_decorators_internal_dataclass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handler(_annotated_handlers.GetCoreSchemaHandler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 )zGets the Pydantic core schema.

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

        Returns:
            The Pydantic core schema.
        NplainfunctionZinfo_argreturn_schemar   serialization)r   get_function_return_typer   r   _get_types_namespace	NameErrorr   from_name_errorr
   generate_schemar   Z$plain_serializer_function_ser_schemainspect_annotated_serializerr   selfr   r   schemar   er%    r1   vC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\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   r3   r1   r1   r1   r2   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!   )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.
        Nwrapr#   r&   )r   r'   r   r   r(   r)   r   r*   r
   r+   r   #wrap_serializer_function_ser_schemar,   r   r-   r1   r1   r2   r3   L   r4   z+WrapSerializer.__get_pydantic_core_schema__Nr5   r6   r1   r1   r1   r2   r<   <   s   
 
r<   r   _PartialClsOrStaticMethod_PlainSerializeMethodType)bound_WrapSerializeMethodType.)r   r   check_fields__fieldstrfieldsr   r   r   r   rC   bool | Noner   @Callable[[_PlainSerializeMethodType], _PlainSerializeMethodType]c                G     d S Nr1   )rD   r   r   rC   rF   r1   r1   r2   field_serializerq   s   rK   modeLiteral['plain']c                G  rI   rJ   r1   rD   rL   r   r   rC   rF   r1   r1   r2   rK   |      	Literal['wrap']>Callable[[_WrapSerializeMethodType], _WrapSerializeMethodType]c                G  rI   rJ   r1   rN   r1   r1   r2   rK      rO   r"   r   )rL   r   r   rC   Literal['plain', 'wrap']Callable[[Any], Any]c                   s   d fdd}|S )	ax  Decorator that enables custom field serialization.

    See [Custom serializers](../usage/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.
    fHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]r   (_decorators.PydanticDescriptorProxy[Any]c                   s    t j d}t | |S )N)rF   rL   r   r   rC   )r   ZFieldSerializerDecoratorInfoPydanticDescriptorProxyrT   Zdec_inforC   rF   rL   r   r   r1   r2   dec   s   zfield_serializer.<locals>.decN)rT   rU   r   rV   r1   )rL   r   r   rC   rF   rZ   r1   rY   r2   rK      s   !FuncType__fc                 C  rI   rJ   r1   )r\   r1   r1   r2   model_serializer   s   r]   rL   r   r   Callable[[FuncType], FuncType]c                 C  rI   rJ   r1   r^   r1   r1   r2   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](../usage/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.
    rT   Callable[..., Any]r   rV   c                   s   t j d}t | |S )NrL   r   r   )r   ZModelSerializerDecoratorInforW   rX   rb   r1   r2   rZ      s   zmodel_serializer.<locals>.decN)rT   ra   r   rV   r1   )r\   rL   r   r   rZ   r1   rb   r2   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 rJ   )r   rd   )clsre   r1   r1   r2   __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typeZdefinitionsr/   c                 S  s   || S rJ   r1   )xhr1   r1   r2   <lambda>  s    z=SerializeAsAny.__get_pydantic_core_schema__.<locals>.<lambda>)r/   r&   )copyr   r>   Z
any_schema)r.   r   r   r/   Zschema_to_updater1   r1   r2   r3   
  s   
z+SerializeAsAny.__get_pydantic_core_schema__N)re   r   r   r   r5   )r7   r8   r9   rg   r3   object__hash__r1   r1   r1   r2   rd     s    


rd   r1   )rD   rE   rF   rE   r   r   r   r   rC   rG   r   rH   )rD   rE   rF   rE   rL   rM   r   r   r   r   rC   rG   r   rH   )rD   rE   rF   rE   rL   rP   r   r   r   r   rC   rG   r   rQ   )rF   rE   rL   rR   r   r   r   r   rC   rG   r   rS   )r\   r[   r   r[   )rL   rR   r   r   r   r   r   r_   rJ   )
r\   r`   rL   rR   r   r   r   r   r   rS   ).r:   
__future__r   dataclasses	functoolsr   typingr   r   r   r   r   r	   Zpydantic_corer
   r   Z_core_schemaZtyping_extensionsr   r   r    r   	_internalr   r   r   	dataclassZ
slots_truer   r<   classmethodstaticmethodr?   r;   ZSerializerFunctionZ_PlainSerializationFunctionZWrapSerializerFunctionZ_WrapSerializationFunctionr@   rB   rK   r[   r]   rc   rd   r1   r1   r1   r2   <module>   sx     +,,
0
#