o
    %if4                     @  s0  d Z ddlmZ ddlZddlZddl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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 ddlmZmZ er\ddl m!Z! dZ"edZ#ej$dkreej%efdeddddddddddd
dId%d&Z&eej%efdeddddddddddd
dJd*d&Z&n2eej%efdeddddddddd+dKd,d&Z&eej%efdeddddddddd+dLd-d&Z&eej%efd	dMddddddddddd
dNd0d&Z&ee'Z(d1ej$  krd2k rn n	dOd7d8Z)e)ej*_+ddd9dd:dPdBdCZ,dQdGdHZ-dS )Rz7Provide an enhanced dataclass that performs validation.    )annotationsN)TYPE_CHECKINGAnyCallableGenericNoReturnTypeVaroverload)Literal	TypeGuarddataclass_transform   )_config_decorators_typing_extra)_dataclasses)getattr_migration)
ConfigDict)Field	FieldInfo)PydanticDataclass)	dataclassrebuild_dataclass_T   
   )field_specifiersFT.
initrepreqorderunsafe_hashfrozenconfigvalidate_on_initkw_onlyslotsr   Literal[False]r    boolr!   r"   r#   r$   r%    ConfigDict | type[object] | Noner&   bool | Noner'   r(   return-Callable[[type[_T]], type[PydanticDataclass]]c        
   
      C     d S N r   r1   r1   M/var/www/html/corbot_env/lib/python3.10/site-packages/pydantic/dataclasses.pyr      s   r   _clstype[_T]type[PydanticDataclass]c       
         C  r/   r0   r1   )r3   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r1   r1   r2   r   +   s   r   r    r!   r"   r#   r$   r%   r&   c                 C  r/   r0   r1   r6   r1   r1   r2   r   ?   s   c          	      C  r/   r0   r1   )	r3   r   r    r!   r"   r#   r$   r%   r&   r1   r1   r2   r   N   s   type[_T] | NoneGCallable[[type[_T]], type[PydanticDataclass]] | type[PydanticDataclass]c       
      	     sv   |du sJ d|dusJ dt jdkrt|	|
dni dd
dd fdd}| du r7|S || S )aS  Usage docs: https://docs.pydantic.dev/2.7/concepts/dataclasses/

    A decorator used to create a Pydantic-enhanced dataclass, similar to the standard Python `dataclass`,
    but with added validation.

    This function should be used similarly to `dataclasses.dataclass`.

    Args:
        _cls: The target `dataclass`.
        init: Included for signature compatibility with `dataclasses.dataclass`, and is passed through to
            `dataclasses.dataclass` when appropriate. If specified, must be set to `False`, as pydantic inserts its
            own  `__init__` function.
        repr: A boolean indicating whether to include the field in the `__repr__` output.
        eq: Determines if a `__eq__` method should be generated for the class.
        order: Determines if comparison magic methods should be generated, such as `__lt__`, but not `__eq__`.
        unsafe_hash: Determines if a `__hash__` method should be included in the class, as in `dataclasses.dataclass`.
        frozen: Determines if the generated class should be a 'frozen' `dataclass`, which does not allow its
            attributes to be modified after it has been initialized.
        config: The Pydantic config to use for the `dataclass`.
        validate_on_init: A deprecated parameter included for backwards compatibility; in V2, all Pydantic dataclasses
            are validated on init.
        kw_only: Determines if `__init__` method parameters must be specified by keyword only. Defaults to `False`.
        slots: Determines if the generated class should be a 'slots' `dataclass`, which does not allow the addition of
            new attributes after instantiation.

    Returns:
        A decorator that accepts a class as its argument and returns a Pydantic `dataclass`.

    Raises:
        AssertionError: Raised if `init` is not `False` or `validate_on_init` is `False`.
    Fz7pydantic.dataclasses.dataclass only supports init=Falsez-validate_on_init=False is no longer supportedr   )r'   r(   cls	type[Any]r-   Nonec              	   S  s   | j D ]Q}t|dg }|D ]F}t| |d}t|tsqd|i}tjdkr+|jr+d|d< |jdur5|j|d< t| |t	j
di | | jddu rLi | _|| | j|< qqdS )	a  Make sure that stdlib `dataclasses` understands `Field` kwargs like `kw_only`
        To do that, we simply change
          `x: int = pydantic.Field(..., kw_only=True)`
        into
          `x: int = dataclasses.field(default=pydantic.Field(..., kw_only=True), kw_only=True)`
        __annotations__Ndefaultr   Tr'   r    r1   )__mro__getattr
isinstancer   sysversion_infor'   r    setattrdataclassesfield__dict__getr<   )r9   annotation_clsr   
field_namefield_value
field_argsr1   r1   r2   make_pydantic_fields_compatible   s"   



z2dataclass.<locals>.make_pydantic_fields_compatibler5   c           
   	     s   | } }|du rt | dd}|dur|}t|}tj| }| j}t| rBd}| f}t	| t
r;t
| j }||f }t| j|} |  tj| fdd} || _|| _|j| _|j| _tj| |ddd}	|	| _| S )zCreate a Pydantic dataclass from a regular dataclass.

        Args:
            cls: The class to create the Pydantic dataclass from.

        Returns:
            A Pydantic dataclass.
        N__pydantic_config__T)r   r    r!   r"   r#   r$   Fraise_errorstypes_namespace)r?   r   ConfigWrapperr   DecoratorInfosbuild__doc___pydantic_dataclassesis_builtin_dataclass
issubclassr   __parameters__types	new_class__name__rD   r   __pydantic_decorators__
__module____qualname__complete_dataclass__pydantic_complete__)
r9   original_clsconfig_dict
cls_configconfig_wrapper
decoratorsoriginal_docbasesgeneric_basepydantic_completer%   r!   r$   kwargsrL   r"   r    r#   r1   r2   create_dataclass   sL   	




	z#dataclass.<locals>.create_dataclassN)r9   r:   r-   r;   )r9   r:   r-   r5   )rA   rB   dict)r3   r   r    r!   r"   r#   r$   r%   r&   r'   r(   rl   r1   rj   r2   r   _   s   .

#?)r      )r      argsr   rk   r   c                  O  s   t d)a9  This function does nothing but raise an error that is as similar as possible to what you'd get
        if you were to try calling `InitVar[int]()` without this monkeypatch. The whole purpose is just
        to ensure typing._type_check does not error if the type hint evaluates to `InitVar[<parameter>]`.
        z 'InitVar' object is not callable)	TypeError)rp   rk   r1   r1   r2   _call_initvar  s   rr      )forcerO   _parent_namespace_depth_types_namespacer9   rt   rO   ru   intrv   dict[str, Any] | Nonec                C  sl   |s| j rdS |dur| }n|dkrtj|dpi }|}ni }t| |}tj| tj| j	dd||dS )ax  Try to rebuild the pydantic-core schema for the dataclass.

    This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
    the initial attempt to build the schema, and automatic rebuilding fails.

    This is analogous to `BaseModel.model_rebuild`.

    Args:
        cls: The class to rebuild the pydantic-core schema for.
        force: Whether to force the rebuilding of the schema, defaults to `False`.
        raise_errors: Whether to raise errors, defaults to `True`.
        _parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
        _types_namespace: The types namespace, defaults to `None`.

    Returns:
        Returns `None` if the schema is already "complete" and rebuilding was not required.
        If rebuilding _was_ required, returns `True` if rebuilding was successful, otherwise `False`.
    Nr   )parent_depthF)checkrN   )
r`   copyr   parent_frame_namespaceget_cls_types_namespacerU   r_   r   rQ   rM   )r9   rt   rO   ru   rv   rP   frame_parent_nsr1   r1   r2   r     s   

r   __clsr:   "TypeGuard[type[PydanticDataclass]]c                 C  s   t | o	d| jv S )zWhether a class is a pydantic dataclass.

    Args:
        __cls: The class.

    Returns:
        `True` if the class is a pydantic dataclass, `False` otherwise.
    __pydantic_validator__)rD   is_dataclassrF   )r   r1   r1   r2   is_pydantic_dataclass>  s   	r   )r   r)   r    r*   r!   r*   r"   r*   r#   r*   r$   r*   r%   r+   r&   r,   r'   r*   r(   r*   r-   r.   )r3   r4   r   r)   r    r*   r!   r*   r"   r*   r#   r*   r$   r*   r%   r+   r&   r,   r'   r*   r(   r*   r-   r5   )r   r)   r    r*   r!   r*   r"   r*   r#   r*   r$   r*   r%   r+   r&   r,   r-   r.   )r3   r4   r   r)   r    r*   r!   r*   r"   r*   r#   r*   r$   r*   r%   r+   r&   r,   r-   r5   r0   )r3   r7   r   r)   r    r*   r!   r*   r"   r*   r#   r*   r$   r*   r%   r+   r&   r,   r'   r*   r(   r*   r-   r8   )rp   r   rk   r   r-   r   )r9   r5   rt   r*   rO   r*   ru   rw   rv   rx   r-   r,   )r   r:   r-   r   ).rT   
__future__r   _annotationsrD   rA   rY   typingr   r   r   r   r   r   r	   typing_extensionsr
   r   r   	_internalr   r   r   r   rU   
_migrationr   r%   r   fieldsr   r   _internal._dataclassesr   __all__r   rB   rE   r   r[   __getattr__rr   InitVar__call__r   r   r1   r1   r1   r2   <module>   s    $
 
1