o
    $6d                     @  s   d dl mZ d dl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 er6ddlmZ ddlmZ ed	e	eZG d
d dee ZddddZdddZdS )    )annotations)TYPE_CHECKINGCallableGenericTypeVar)SchemaSerializerSchemaValidator)Literal   )PydanticErrorCodesPydanticUserError)PydanticDataclass)	BaseModelValSerc                   @  s8   e Zd ZdZdZdddddZdddZdddZdS )
MockValSerzMocker for `pydantic_core.SchemaValidator` or `pydantic_core.SchemaSerializer` which optionally attempts to
    rebuild the thing it's mocking when one of its methods is accessed and raises an error if that fails.
    )_error_message_code_val_or_ser_attempt_rebuildN)attempt_rebuilderror_messagestrcoder   
val_or_ser"Literal['validator', 'serializer']r   "Callable[[], ValSer | None] | NonereturnNonec                C  s(   || _ |dkr	tnt| _|| _|| _d S )N	validator)r   r   r   r   r   r   )selfr   r   r   r    r    wC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pydantic/_internal/_mock_val_ser.py__init__   s   
zMockValSer.__init__itemc                 C  s@   d}| j r|   }|d urt||S t| j| t| j| jd)NTr   )r   getattrr   r   r   r   )r   r#   Z__tracebackhide__val_serr    r    r!   __getattr__&   s   
zMockValSer.__getattr__ValSer | Nonec                 C  s.   | j r|   }|d ur|S t| j| jdd S )Nr$   )r   r   r   r   )r   r&   r    r    r!   rebuild1   s   zMockValSer.rebuild)
r   r   r   r   r   r   r   r   r   r   )r#   r   r   r   )r   r(   )__name__
__module____qualname____doc__	__slots__r"   r'   r)   r    r    r    r!   r      s    
r   all referenced typesclstype[BaseModel]cls_namer   undefined_namer   r   c                   s\   d| d| d| d}d fdd}t |d	d
|d _d fdd}t |d	d|d _dS )a&  Set `__pydantic_validator__` and `__pydantic_serializer__` to `MockValSer`s on a model.

    Args:
        cls: The model class to set the mocks on
        cls_name: Name of the model class, used in error messages
        undefined_name: Name of the undefined thing, used in error messages
    `*` is not fully defined; you should define z, then call `z.model_rebuild()`.r   SchemaValidator | Nonec                         j dddr
 jS d S NF   raise_errorsZ_parent_namespace_depth)model_rebuild__pydantic_validator__r    r0   r    r!   attempt_rebuild_validatorH      z2set_model_mocks.<locals>.attempt_rebuild_validatorclass-not-fully-definedr   r   r   r   SchemaSerializer | Nonec                     r7   r8   )r<   __pydantic_serializer__r    r>   r    r!   attempt_rebuild_serializerU   r@   z3set_model_mocks.<locals>.attempt_rebuild_serializer
serializerNr   r6   )r   rC   )r   r=   rD   )r0   r2   r3   undefined_type_error_messager?   rE   r    r>   r!   set_model_mocks;   s$   	rI   type[PydanticDataclass]c                   s<   d| d| d| d}d fdd}t |d	d
|d _d S )Nr4   r5   z4, then call `pydantic.dataclasses.rebuild_dataclass(z)`.r   r6   c                    s$   ddl m}  |  dddr jS d S )Nr
   rebuild_dataclassFr9   r:   )dataclassesrL   r=   rK   r>   r    r!   r   i   s   z5set_dataclass_mock_validator.<locals>.attempt_rebuildrA   r   rB   rG   )r   r=   )r0   r2   r3   rH   r   r    r>   r!   set_dataclass_mock_validatorc   s   rN   N)r/   )r0   r1   r2   r   r3   r   r   r   )r0   rJ   r2   r   r3   r   r   r   )
__future__r   typingr   r   r   r   Zpydantic_corer   r   Ztyping_extensionsr	   errorsr   r   rM   r   mainr   r   r   rI   rN   r    r    r    r!   <module>   s    )(