a
    _g%                     @  s  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	 ddlm
Z
mZ ddlmZmZmZmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddl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% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ej,rFddl-m.Z/ ddl0m1Z1 ddl2m3Z3 G dd de/ej4Z5neZ6d/dddddd d!Z7d"dd#d$d%d&d'dd'd'd(d)d*Z8d%d+d,d-d.Z9dS )0z0Private logic for creating pydantic dataclasses.    )annotationsN)partialwraps)AnyClassVar)
ArgsKwargsSchemaSerializerSchemaValidatorcore_schema)	TypeGuard   )PydanticUndefinedAnnotation)PluggableSchemaValidatorcreate_schema_validator)PydanticDeprecatedSince20   )_config_decorators)collect_dataclass_fields)GenerateSchema)get_standard_typevars_map)set_dataclass_mocks)
NsResolver)CallbackGetCoreSchemaHandler)generate_pydantic_signature)LazyClassAttribute)DataclassInstance)
ConfigDict)	FieldInfoc                   @  sJ   e Zd ZU dZded< ded< ded< ded	< d
ed< ded< ded< dS )PydanticDataclassai  A protocol containing attributes only available once a class has been decorated as a Pydantic dataclass.

        Attributes:
            __pydantic_config__: Pydantic-specific configuration settings for the dataclass.
            __pydantic_complete__: Whether dataclass building is completed, or if there are still undefined fields.
            __pydantic_core_schema__: The pydantic-core schema used to build the SchemaValidator and SchemaSerializer.
            __pydantic_decorators__: Metadata containing the decorators defined on the dataclass.
            __pydantic_fields__: Metadata about the fields defined on the dataclass.
            __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the dataclass.
            __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the dataclass.
        zClassVar[ConfigDict]__pydantic_config__zClassVar[bool]__pydantic_complete__z ClassVar[core_schema.CoreSchema]__pydantic_core_schema__z$ClassVar[_decorators.DecoratorInfos]Z__pydantic_decorators__zClassVar[dict[str, FieldInfo]]__pydantic_fields__zClassVar[SchemaSerializer]__pydantic_serializer__z4ClassVar[SchemaValidator | PluggableSchemaValidator]__pydantic_validator__N)__name__
__module____qualname____doc____annotations__ r+   r+   m/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/pydantic/_internal/_dataclasses.pyr   &   s   
r   ztype[StandardDataclass]zNsResolver | Nonez_config.ConfigWrapper | NoneNone)clsns_resolverconfig_wrapperreturnc                 C  s"   t | }t| |||d}|| _dS )zCollect and set `cls.__pydantic_fields__`.

    Args:
        cls: The class.
        ns_resolver: Namespace resolver to use when getting dataclass annotations.
        config_wrapper: The config wrapper instance, defaults to `None`.
    )r/   typevars_mapr0   N)r   r   r#   )r.   r/   r0   r2   fieldsr+   r+   r,   set_dataclass_fieldsA   s
    r4   TF)raise_errorsr/   _force_buildz	type[Any]z_config.ConfigWrapperbool)r.   r0   r5   r/   r6   r1   c             
     s  | j }ddddddd}| j d|_|| _ |j| _t| ||d |s^|jr^t| | j d	S t| d
rtt	
dt t| }t|||d}tdtt|| j|j|jdd| _t| dd}	z6|	r|	| tt|jd	d|dd}
n|j| d	d}
W nH ty6 } z.|r t| | jd|j d W Y d}~d	S d}~0 0 |j| jd}z||
}
W n& |jyz   t| | jd Y d	S 0 td| } |
| _t |
| | j!| jd||j" | _# t$|
|| _%|j&rt'| j(ddddd fdd}|)d| | _(d| _*dS )a  Finish building a pydantic dataclass.

    This logic is called on a class which has already been wrapped in `dataclasses.dataclass()`.

    This is somewhat analogous to `pydantic._internal._model_construction.complete_model_class`.

    Args:
        cls: The class.
        config_wrapper: The config wrapper instance.
        raise_errors: Whether to raise errors, defaults to `True`.
        ns_resolver: The namespace resolver instance to use when collecting dataclass fields
            and during schema building.
        _force_build: Whether to force building the dataclass, no matter if
            [`defer_build`][pydantic.config.ConfigDict.defer_build] is set.

    Returns:
        `True` if building a pydantic dataclass is successfully completed, `False` otherwise.

    Raises:
        PydanticUndefinedAnnotation: If `raise_error` is `True` and there is an undefined annotations.
    r   r   r-   )__dataclass_self__argskwargsr1   c                 _  s"   d}| }|j jt|||d d S )NT)Zself_instance)r%   Zvalidate_pythonr   )r8   r9   r:   Z__tracebackhide__sr+   r+   r,   __init__v   s    z$complete_dataclass.<locals>.__init__z	.__init__)r0   FZ__post_init_post_parse__zVSupport for `__post_init_post_parse__` has been dropped, the method will not be called)r/   r2   __signature__T)initr3   populate_by_nameextrais_dataclassZ__get_pydantic_core_schema__N)Zfrom_dunder_get_core_schemaunpack)Zref_mode`)titlezall referenced typesztype[PydanticDataclass]	dataclassstr)instancefieldvaluer1   c                  s     | || d S )N)validate_assignment)rG   rH   rI   	validatorr+   r,   validated_setattr   s    z-complete_dataclass.<locals>.validated_setattr)+r<   r(   Zconfig_dictr    r4   Zdefer_buildr   r&   hasattrwarningswarnDeprecationWarningr   r   r   r   r   r#   r?   r@   r=   getattrr   Zgenerate_schemar   namecore_configZclean_schemaZCollectedInvalidtypingcastr"   r   r'   Zplugin_settingsr%   r   r$   rJ   r   __setattr____get__r!   )r.   r0   r5   r/   r6   Zoriginal_initr<   r2   Z
gen_schemaZget_core_schemaZschemaerT   rM   r+   rK   r,   complete_dataclassU   s    

		
rZ   z"TypeGuard[type[StandardDataclass]])_clsr1   c                 C  s2   t | o0t| d o0t| jtt| di S )aB  Returns True if a class is a stdlib dataclass and *not* a pydantic dataclass.

    We check that
    - `_cls` is a dataclass
    - `_cls` does not inherit from a processed pydantic dataclass (and thus have a `__pydantic_validator__`)
    - `_cls` does not have any annotations that are not dataclass fields
    e.g.
    ```python
    import dataclasses

    import pydantic.dataclasses

    @dataclasses.dataclass
    class A:
        x: int

    @pydantic.dataclasses.dataclass
    class B(A):
        y: int
    ```
    In this case, when we first check `B`, we make an extra check and look at the annotations ('y'),
    which won't be a superset of all the dataclass fields (only the stdlib fields i.e. 'x')

    Args:
        cls: The class.

    Returns:
        `True` if the class is a stdlib dataclass, `False` otherwise.
    r%   r*   )dataclassesrA   rN   set__dataclass_fields__
issupersetrR   )r[   r+   r+   r,   is_builtin_dataclass   s
    

r`   )NN):r)   
__future__r   Z_annotationsr\   rU   rO   	functoolsr   r   r   r   Zpydantic_corer   r   r	   r
   Ztyping_extensionsr   errorsr   Zplugin._schema_validatorr   r   r    r   r   _fieldsr   Z_generate_schemar   Z	_genericsr   Z_mock_val_serr   Z_namespace_utilsr   Z_schema_generation_sharedr   
_signaturer   _utilsr   TYPE_CHECKINGZ	_typeshedr   ZStandardDataclassconfigr   r3   r   Protocolr   rQ   r4   rZ   r`   r+   r+   r+   r,   <module>   sD     