Ë
    RPfç!  ã                  óÄ  — 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 ddl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jV                  r2ddl,m-Z-  G d„ dej\                  «      Z/ G d„ de/ej\                  «      Z0neZ1	 	 d	 	 	 	 	 	 	 d d„Z2ddœ	 	 	 	 	 	 	 	 	 d!d„Z3d"d„Z4y)#z0Private logic for creating pydantic dataclasses.é    )ÚannotationsN)ÚpartialÚwraps)ÚAnyÚCallableÚClassVar)Ú
ArgsKwargsÚSchemaSerializerÚSchemaValidatorÚcore_schema)Ú	TypeGuardé   )ÚPydanticUndefinedAnnotation)Ú	FieldInfo)Úcreate_schema_validator)ÚPydanticDeprecatedSince20é   )Ú_configÚ_decoratorsÚ_typing_extra)Úcollect_dataclass_fields)ÚGenerateSchema)Úget_standard_typevars_map)Úset_dataclass_mocks)ÚCallbackGetCoreSchemaHandler)Úgenerate_pydantic_signature)Ú
ConfigDictc                  ó4   — e Zd ZU ded<   ded<   ded<   d	d„Zy)
ÚStandardDataclasszClassVar[dict[str, Any]]Ú__dataclass_fields__zClassVar[Any]Ú__dataclass_params__zClassVar[Callable[..., None]]Ú__post_init__c                 ó   — y ©N© )ÚselfÚargsÚkwargss      úY/var/www/fastapitest/venv/lib/python3.12/site-packages/pydantic/_internal/_dataclasses.pyÚ__init__zStandardDataclass.__init__&   s   € Øó    N)r'   Úobjectr(   r,   ÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r*   r%   r+   r)   r   r   !   s   … Ø6Ó6Ø+Ó+Ø4Ó4ô	r+   r   c                  óX   — 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<   y)Ú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__zClassVar[SchemaValidator]Ú__pydantic_validator__N)r/   r0   r1   Ú__doc__r2   r%   r+   r)   r4   r4   )   s3   … ñ
	ð 2Ó1Ø-Ó-Ø"BÓBØ!EÓEØ;Ó;Ø!;Ó;Ø 9Ô9r+   r4   c                óF   — t        | «      }t        | |||¬«      }|| _        y)zÝCollect 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_mapÚconfig_wrapperN)r   r   r9   )ÚclsÚtypes_namespacer?   r>   Úfieldss        r)   Úset_dataclass_fieldsrC   D   s'   € ô -¨SÓ1€LÜ% c¨?ÈÐftÔu€Fà$€CÕr+   T)Úraise_errorsc          	     ó€  ‡— t        | d«      rt        j                  dt        «       |€t	        j
                  | «      }t        | ||¬«       t        | «      }t        |||«      }t        | j                  | j                  |d¬«      }dd„}| j                  › d�|_        || _
        |j                  | _        || _        t!        | d	d«      }	 |r+ || t#        t%        |j&                  d
¬«      |d¬«      «      }	n|j'                  | d
¬«      }	|j1                  | «      }	 |j3                  |	«      }	t7        j8                  d| «      } |	| _        t=        |	| | j>                  | j                  d||j@                  «      x| _!        ŠtE        |	|«      | _#        |jH                  r5tK        | jL                  «      dˆfd„«       }|jO                  d| «      | _&        y# t(        $ r2}
|r‚ t+        | | j,                  d|
j.                  › d�«       Y d}
~
y
d}
~
ww xY w# |j4                  $ r t+        | | j,                  d«       Y y
w xY w)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)r?   T)ÚinitrB   r?   Úis_dataclassc                óZ   — d}| }|j                   j                  t        ||«      |¬«       y )NT)Úself_instance)r;   Úvalidate_pythonr	   )Ú__dataclass_self__r'   r(   Ú__tracebackhide__Úss        r)   r*   z$complete_dataclass.<locals>.__init__‰   s.   € Ø ÐØˆØ	× Ñ ×0Ñ0´¸DÀ&Ó1IÐYZÐ0Õ[r+   z	.__init__Ú__get_pydantic_core_schema__F)Úfrom_dunder_get_core_schemaÚunpack)Úref_modeú`zall referenced typesztype[PydanticDataclass]Ú	dataclassc               ó,   •— ‰j                  | ||«       y r$   )Úvalidate_assignment)ÚinstanceÚfieldÚvalueÚ	validators      €r)   Úvalidated_setattrz-complete_dataclass.<locals>.validated_setattr»   s   ø€ à×)Ñ)¨(°E¸5ÕAr+   )rL   r4   r'   r   r(   r   r-   r.   )rW   r   rX   ÚstrrY   r\   r-   r.   )(ÚhasattrÚwarningsÚwarnÚDeprecationWarningr   Úget_cls_types_namespacerC   r   r   r   r*   r9   r1   Úconfig_dictr5   Ú__signature__Úgetattrr   r   Úgenerate_schemar   r   r/   ÚnameÚcore_configÚclean_schemaÚCollectedInvalidÚtypingÚcastr7   r   r0   Úplugin_settingsr;   r
   r:   rV   r   Ú__setattr__Ú__get__)r@   r?   rD   rA   r>   Ú
gen_schemaÚsigr*   Úget_core_schemaÚschemaÚerg   r[   rZ   s                @r)   Úcomplete_dataclassrt   V   sE  ø€ ô2 ˆsÐ.Ô/Ü�‰ØdÔfxô	
ð ÐÜ'×?Ñ?ÀÓDˆä˜˜o¸nÕMä,¨SÓ1€LÜØØØó€Jô &Ø�\‰\Ø×&Ñ&Ø%Øô	€Có\ð
  #×/Ñ/Ð0°	Ð:€HÔà€C„LØ,×8Ñ8€CÔØ€CÔÜ˜cÐ#AÀ4ÓH€OðÙÙ$ØÜ,Ü˜J×6Ñ6ÐTYÔZØØ%ôó‰Fð  ×/Ñ/°ÐQVÐ/ÓWˆFð !×,Ñ,¨SÓ1€KðØ×(Ñ(¨Ó0ˆô �+‰+Ð/°Ó
5€Cð $*€CÔ Ü-DØ��S—^‘^ S×%5Ñ%5°{ÀKÐQ_×QoÑQoó.ð €CÔ ô #3°6¸;Ó"G€CÔà×)Ò)ä	ˆs�‰Ó	ô	Bó 
 ð	Bð ,×3Ñ3°D¸#Ó>ˆŒàøôC 'ò ÙØÜ˜C §¡°°1·6±6°(¸!¨}Ô=Üûð	ûð ×&Ñ&ò Ü˜C §¡Ð/EÔFÙðús+   ÃA G ÄH Ç	HÇ(HÈHÈ&H=È<H=c           	     ó¾   — t        j                  | «      xrG t        | d«       xr8 t        | j                  «      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;   r2   )ÚdataclassesrH   r]   Úsetr    Ú
issupersetrd   )Ú_clss    r)   Úis_builtin_dataclassrz   Ä   sZ   € ô> 	× Ñ  Ó&ò 	aÜ˜Ð6Ó7Ð7ò	aä�×)Ñ)Ó*×5Ñ5´c¼'À$ÐHYÐ[]Ó:^Ó6_Ó`ðr+   )NN)r@   ztype[StandardDataclass]rA   údict[str, Any] | Noner?   z_config.ConfigWrapper | Noner-   r.   )
r@   ú	type[Any]r?   z_config.ConfigWrapperrD   ÚboolrA   r{   r-   r}   )ry   r|   r-   z"TypeGuard[type[StandardDataclass]])5r<   Ú
__future__r   Ú_annotationsrv   rj   r^   Ú	functoolsr   r   r   r   r   Úpydantic_corer	   r
   r   r   Útyping_extensionsr   Úerrorsr   rB   r   Úplugin._schema_validatorr   r   Ú r   r   r   Ú_fieldsr   Ú_generate_schemar   Ú	_genericsr   Ú_mock_val_serr   Ú_schema_generation_sharedr   Ú
_signaturer   ÚTYPE_CHECKINGÚconfigr   ÚProtocolr   r4   r`   rC   rt   rz   r%   r+   r)   ú<module>r�      sü   ðÙ 6Ý 2ã Û Û ß $ß *Ñ *÷ó õ (å 0Ý Ý >Ý 0ß 1Ñ 1Ý -Ý ,Ý 0Ý .Ý CÝ 3à	×ÒÝ#ô˜FŸO™Oô ô:Ð-¨v¯©õ :ð0 3Ðð
 .2Ø37ð%Ø	 ð%à*ð%ð 1ð%ð 
ó	%ð, ñ	kØ	ðkà)ðkð ð	kð
 +ðkð 
ókô\"r+   