o
    +iI                     @  sl  d Z ddlmZ ddl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mZ ddlmZ ddlmZmZ ddlmZmZ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# ddl$m%Z%m&Z&m'Z' e	rxddl(m)Z) ddl*m+Z+ dZ,edZ-ej.dkreej/e%e'fdeddddddddddd
dMd(d)Z0eej/e%e'fdeddddddddddd
dNd-d)Z0n4eej/e%e'fdeddddddddd.dOd/d)Z0eej/e%e'fdeddddddddd.dPd0d)Z0eej/e%e'fd	dQddddddddddd
dRd3d)Z0dSd5d6Z1ee2Z3ej.d7k r$dTd<d=Z4e4ej5_6ddd>dd?dUdFdGZ7dVdKdLZ8dS )Wz7Provide an enhanced dataclass that performs validation.    )annotationsN)TYPE_CHECKINGAnyCallableGenericLiteralNoReturnTypeVaroverload)warn)	TypeGuarddataclass_transform   )_config_decorators_mock_val_ser_namespace_utils_typing_extra)_dataclasses)getattr_migration)
ConfigDict)PydanticUserError)Field	FieldInfoPrivateAttr)PydanticDataclass)MappingNamespace)	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$   r7   r7   G/var/www/html/venv/lib/python3.10/site-packages/pydantic/dataclasses.pyr         r   _clstype[_T]type[PydanticDataclass]c       
         C  r5   r6   r7   )r:   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r7   r7   r8   r   0   r9   r%   r&   r'   r(   r)   r*   r+   r,   c                 C  r5   r6   r7   r=   r7   r7   r8   r   C      c          	      C  r5   r6   r7   )	r:   r%   r&   r'   r(   r)   r*   r+   r,   r7   r7   r8   r   R   r>   type[_T] | NoneGCallable[[type[_T]], type[PydanticDataclass]] | type[PydanticDataclass]c       
      	     sj   |du sJ d|dusJ dt jdkr|	dni d fd
d}| du r1|S || S )a  !!! abstract "Usage Documentation"
        [`dataclasses`](../concepts/dataclasses.md)

    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. If not set, the value from the provided `config` argument will be used (and will default to `False` otherwise).
        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]r3   r<   c              
     s  ddl m} || rtd| j ddd| }tdd | jD }|s8d	ur8t| d
r8td| j dtdd d	ur>nt	| d
d	}t
|}tj| }|| | j}t| rwd	}| f}t| trpt| j }	||	f }t| j|} d	ur |jrtd| jdtdd n|jpd t| }
|
D ]}t	| |d	}t|trt| |t| qt|  t j!| fd	 d} W d	   n1 sw   Y  |j"r
| j#t$%| j#d) fdd}|&d	| | _#r
t| ds
d*d!d"}d+d$d%}|| _'|| _(d| _)|| _*|| _t	|d&d	}|j+| _+t,j-d'kr.|d	ur.||_.|| _.|j/| _/t0t1| _2d| _3tj4| |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.
        r   )is_model_classz(Cannot create a Pydantic dataclass from z" as it is already a Pydantic modelzdataclass-on-model)codec                 s  s    | ]}t |V  qd S r6   )dataclassesis_dataclass).0baser7   r7   r8   	<genexpr>   s    z6dataclass.<locals>.create_dataclass.<locals>.<genexpr>N__pydantic_config__z[`config` is set via both the `dataclass` decorator and `__pydantic_config__` for dataclass zK. The `config` specification from `dataclass` decorator will take priority.   )category
stacklevelzN`frozen` is set via both the `dataclass` decorator and `config` for dataclass zW.This is not recommended. The `frozen` specification on `dataclass` will take priority.FT)r%   r&   r'   r(   r)   r*   instancer   namestrvaluer   r3   Nonec                  sp    r| ||S t | }t||d }t|tr|| | d S t|tjr.| j|| d S |j	
| || d S r6   )typegetattr
isinstanceproperty__set__	functoolscached_property__dict____setitem____pydantic_validator__validate_assignment)rN   rO   rQ   inst_clsattrfrozen_original_setattrr7   r8   validated_setattr   s   
z>dataclass.<locals>.create_dataclass.<locals>.validated_setattr__setstate__self	list[Any]c                   s    fddt  D S )Nc                   s   g | ]}t  |jqS r7   )rT   rO   )rG   fre   r7   r8   
<listcomp>  s    zTdataclass.<locals>.create_dataclass.<locals>._dataclass_getstate.<locals>.<listcomp>)rE   fieldsrh   r7   rh   r8   _dataclass_getstate  s   z@dataclass.<locals>.create_dataclass.<locals>._dataclass_getstatestatec                 S  s.   t t| |D ]\}}t| |j| qd S r6   )ziprE   rj   object__setattr__rO   )re   rl   fieldrQ   r7   r7   r8   _dataclass_setstate  s   z@dataclass.<locals>.create_dataclass.<locals>._dataclass_setstate__firstlineno__)r!      )raise_errors)rN   r   rO   rP   rQ   r   r3   rR   )re   r   r3   rf   )re   r   rl   rf   r3   rR   )5_internal._utilsrC   r   __name__any	__bases__hasattrr   UserWarningrT   r   ConfigWrapperr   DecoratorInfosbuildupdate_from_config__doc___pydantic_dataclassesis_stdlib_dataclass
issubclassr   __parameters__types	new_classr*   r   safe_get_annotationsrU   r   setattras_dataclass_fieldpatch_base_fieldsrE   r   r]   ro   rX   wraps__get____getstate__rd   __is_pydantic_dataclass____pydantic_decorators__
__module__sysversion_inforr   __qualname__classmethod_pydantic_fields_complete__pydantic_fields_complete____pydantic_complete__complete_dataclass)rA   rC   original_clshas_dataclass_baseconfig_dictconfig_wrapper
decoratorsoriginal_docbasesgeneric_basecls_anns
field_namefield_valuerc   rk   rq   firstlinenor+   r'   r*   kwargsr(   r&   r.   r)   r`   r8   create_dataclass   s   	








	



z#dataclass.<locals>.create_dataclassN)rA   rB   r3   r<   )r   r   )r:   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r   r7   r   r8   r   b   s   /
 !rA   c                 C  s   t dd | j D S )zReturn whether the fields where successfully collected (i.e. type hints were successfully resolves).

    This is a private property, not meant to be used outside Pydantic.
    c                 s  s    | ]}|j V  qd S r6   )	_complete)rG   
field_infor7   r7   r8   rI   A  s    z,_pydantic_fields_complete.<locals>.<genexpr>)all__pydantic_fields__values)rA   r7   r7   r8   r   <  s   r   )r!      argsr   r   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)r   r   r7   r7   r8   _call_initvarJ  s   r   rK   )forcert   _parent_namespace_depth_types_namespacer   rt   r   intr   MappingNamespace | Nonec                C  s   |s| j rdS dD ]}|| jv rtt| |tjst| | q	d| _ |dur)|}n|dkr7tj|ddp5i }ni }t	j
|d}tj| tj| jd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`.
    N)__pydantic_core_schema__r\   __pydantic_serializer__Fr   T)parent_depthr   )parent_namespace)check)rt   ns_resolver_force_build)r   rZ   rU   rT   r   
MockValSerdelattrr   parent_frame_namespacer   
NsResolverr   r   r   r{   rJ   )rA   r   rt   r   r   r_   
rebuild_nsr   r7   r7   r8   r   T  s,   

r   class_rB   "TypeGuard[type[PydanticDataclass]]c                C  s,   zd| j v o
t| W S  ty   Y dS w )zWhether a class is a pydantic dataclass.

    Args:
        class_: The class.

    Returns:
        `True` if the class is a pydantic dataclass, `False` otherwise.
    r   F)rZ   rE   rF   AttributeError)r   r7   r7   r8   is_pydantic_dataclass  s
   	r   )r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r0   r+   r1   r,   r2   r-   r0   r.   r0   r3   r4   )r:   r;   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r-   r0   r.   r0   r3   r<   )r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r3   r4   )r:   r;   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r3   r<   r6   )r:   r?   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r-   r0   r.   r0   r3   r@   )rA   r<   r3   r0   )r   r   r   r   r3   r   )rA   r<   r   r0   rt   r0   r   r   r   r   r3   r2   )r   rB   r3   r   )9r   
__future__r   _annotationsrE   rX   r   r   typingr   r   r   r   r   r   r	   r
   warningsr   typing_extensionsr   r   	_internalr   r   r   r   r   r   r   
_migrationr   r+   r   errorsr   rj   r   r   r   _internal._dataclassesr   _internal._namespace_utilsr   __all__r   r   rp   r   r   rv   __getattr__r   InitVar__call__r   r   r7   r7   r7   r8   <module>   s    (
 
Z
=