
    9CgF"                       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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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*        r4ddl+m,Z, ddl-m.Z.  G d dej/                  Z0 G d de0ej/                  Z1neZ2	 	 d-d.d"Z3d#d$d/d)Z4d0d,Z5dS )1z0Private logic for creating pydantic dataclasses.    )annotationsN)partialwraps)AnyCallableClassVar)
ArgsKwargsSchemaSerializerSchemaValidatorcore_schema)	TypeGuard   )PydanticUndefinedAnnotation)PluggableSchemaValidatorcreate_schema_validator)PydanticDeprecatedSince20   )_config_decorators_typing_extra)collect_dataclass_fields)GenerateSchema)get_standard_typevars_map)set_dataclass_mocks)CallbackGetCoreSchemaHandler)generate_pydantic_signature)
ConfigDict)	FieldInfoc                  6    e Zd ZU ded<   ded<   ded<   ddZdS )StandardDataclasszClassVar[dict[str, Any]]__dataclass_fields__zClassVar[Any]__dataclass_params__zClassVar[Callable[..., None]]__post_init__argsobjectkwargsreturnNonec                    d S N )selfr$   r&   s      Q/var/www/api/venv/lib/python3.11/site-packages/pydantic/_internal/_dataclasses.py__init__zStandardDataclass.__init__'   s    D    N)r$   r%   r&   r%   r'   r(   )__name__
__module____qualname____annotations__r.   r+   r/   r-   r    r    "   sN         6666++++4444	 	 	 	 	 	r/   r    c                  Z    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]__pydantic_decorators__zClassVar[dict[str, FieldInfo]]__pydantic_fields__zClassVar[SchemaSerializer]__pydantic_serializer__z4ClassVar[SchemaValidator | PluggableSchemaValidator]__pydantic_validator__N)r0   r1   r2   __doc__r3   r+   r/   r-   r5   r5   *   sr         
	 
	 	2111----BBBBEEEE;;;;;;;;TTTTTTr/   r5   clstype[StandardDataclass]types_namespacedict[str, Any] | Noneconfig_wrapper_config.ConfigWrapper | Noner'   r(   c                X    t          |           }t          | |||          }|| _        dS )zCollect and set `cls.__pydantic_fields__`.

    Args:
        cls: The class.
        types_namespace: The types namespace, defaults to `None`.
        config_wrapper: The config wrapper instance, defaults to `None`.
    )typevars_maprB   N)r   r   r:   )r>   r@   rB   rE   fieldss        r-   set_dataclass_fieldsrG   E   s6     -S11L%c?ftuuuF$Cr/   T)raise_errors	type[Any]_config.ConfigWrapperrH   boolc          	        t          | d          rt          j        dt                     |t	          j        |           }t          | ||           t          |           }t          |||          }t          | j
        | j        |d          }dd}| j         d|_        || _
        |j        | _        || _        t!          | dd          }	 |r1 || t#          t%          |j        d          |d                    }	n|                    | d          }	n:# t(          $ r-}
|r t+          | | j        d|
j         d           Y d}
~
dS d}
~
ww xY w|                    |           }	 |                    |	          }	n'# |j        $ r t+          | | j        d           Y dS w xY wt7          j        d|           } |	| _        t=          |	| | j        | j        d||j                   x| _!        tE          |	|          | _#        |j$        r;tK          | j&                  df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`.
        types_namespace: The types namespace.

    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.
    __post_init_post_parse__zVSupport for `__post_init_post_parse__` has been dropped, the method will not be calledN)rB   T)initrF   rB   is_dataclass__dataclass_self__r5   r$   r   r&   r'   r(   c                b    d}| }|j                             t          ||          |           d S )NT)self_instance)r<   validate_pythonr	   )rP   r$   r&   __tracebackhide__ss        r-   r.   z$complete_dataclass.<locals>.__init__   s:     	 00D&1I1IYZ0[[[[[r/   z	.__init____get_pydantic_core_schema__F)from_dunder_get_core_schemaunpack)ref_mode`zall referenced typesztype[PydanticDataclass]	dataclassinstancefieldstrvaluec               6                         | ||           d S r*   )validate_assignment)r\   r]   r_   	validators      r-   validated_setattrz-complete_dataclass.<locals>.validated_setattr   s!    ))(E5AAAAAr/   )rP   r5   r$   r   r&   r   r'   r(   )r\   r   r]   r^   r_   r^   r'   r(   ))hasattrwarningswarnDeprecationWarningr   merge_cls_and_parent_nsrG   r   r   r   r.   r:   r2   config_dictr6   __signature__getattrr   r   generate_schemar   r   r0   namecore_configclean_schemaCollectedInvalidtypingcastr8   r   r1   plugin_settingsr<   r
   r;   ra   r   __setattr____get__r7   )r>   rB   rH   r@   rE   
gen_schemasigr.   get_core_schemaschemaern   rc   rb   s                @r-   complete_dataclassr{   W   s   2 s.// 
dfx	
 	
 	
 '?DDonMMMM,S11L J &\&%	  C\ \ \ \
  #/:::HCL,8CCc#A4HHO 
	X$_,J6TYZZZ%   FF  //QV/WWF&    	C}16}}}===uuuuu	 !,,S11K((00&   C/EFFFuu +/
5
5C $*C -DS^S%5{KQ_Qo. . C #36;"G"GC) ?	s			B 	B 	B 	B 	B 
 		B ,33D#>> $C4s+   A
D 
E%"EE+F  F%$F%_cls"TypeGuard[type[StandardDataclass]]c           	         t          j        |           oSt          | d           oBt          | j                                      t          t          | di                               S )a>  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.
    ```py
    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<   r3   )dataclassesrO   rd   setr!   
issupersetrk   )r|   s    r-   is_builtin_dataclassr      sf    > 	 && 	a6777	a)**55c'$HY[]:^:^6_6_``r/   )NN)r>   r?   r@   rA   rB   rC   r'   r(   )
r>   rI   rB   rJ   rH   rK   r@   rA   r'   rK   )r|   rI   r'   r}   )6r=   
__future__r   _annotationsr   rq   re   	functoolsr   r   r   r   r   pydantic_corer	   r
   r   r   typing_extensionsr   errorsr   plugin._schema_validatorr   r   r    r   r   r   _fieldsr   _generate_schemar   	_genericsr   _mock_val_serr   _schema_generation_sharedr   
_signaturer   TYPE_CHECKINGconfigr   rF   r   Protocolr    r5   rg   rG   r{   r   r+   r/   r-   <module>r      s   6 6 2 2 2 2 2 2       $ $ $ $ $ $ $ $ * * * * * * * * * *            ( ' ' ' ' ' 0 0 0 0 0 0 X X X X X X X X 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 - - - - - - , , , , , , 0 0 0 0 0 0 . . . . . . C C C C C C 3 3 3 3 3 3	 $3######""""""    FO   U U U U U-v U U U U0 3
 .237% % % % %, 	l l l l l l^" " " " " "r/   