Ë
    ðLqj#  ã                  óº  — 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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                  r)ddl,m-Z. ddl/m0Z0 ddl1m2Z2  G d„ de.ejf                  «      Z4neZ5	 	 d 	 	 	 	 	 	 	 d!d„Z6ddddœ	 	 	 	 	 	 	 	 	 	 	 d"d„Z7d#d„Z8y)$z0Private 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ÚInvalidSchemaError)Úget_standard_typevars_map)Úset_dataclass_mocks)Ú
NsResolver)Úgenerate_pydantic_signature)ÚLazyClassAttribute)ÚDataclassInstance)Ú
ConfigDict)Ú	FieldInfoc                  ój   — 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<   edd„«       Z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__z4ClassVar[SchemaValidator | PluggableSchemaValidator]Ú__pydantic_validator__c                 ó   — y ©N© )Úclss    úk/var/www/html/ai-menu-system/python-ai/venv/lib/python3.12/site-packages/pydantic/_internal/_dataclasses.pyÚ__pydantic_fields_complete__z.PydanticDataclass.__pydantic_fields_complete__:   s   € Ø7:ó    N)ÚreturnÚbool)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Úclassmethodr.   r+   r/   r-   r!   r!   %   sA   … ñ
	ð 2Ó1Ø-Ó-Ø"BÓBØ!EÓEØ;Ó;Ø!;Ó;Ø TÓTà	Ú:ó 
Ù:r/   r!   c                óF   — t        | «      }t        | |||¬«      }|| _        y)zîCollect 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`.
    )Úns_resolverÚtypevars_mapÚconfig_wrapperN)r   r   r&   )r,   r9   r;   r:   Úfieldss        r-   Úset_dataclass_fieldsr=   C   s,   € ô -¨SÓ1€LÜ%Ø˜°<ÐP^ô€Fð %€CÕr/   TF)Úraise_errorsr9   Ú_force_buildc               óB  ‡— | j                   }dd„}| j                  › d�|_        || _         |j                  | _        t	        | ||¬«       |s|j
                  rt        | «       yt        | d«      rt        j                  dt        «       t        | «      }t        |||¬«      }t        dt        t        || j                   |j"                  |j$                  d	¬
«      «      | _        	 |j)                  | «      }	|j/                  | j0                  ¬«      }	 |j3                  |	«      }	t7        j8                  d| «      } |	| _        t=        |	| | j>                  | j                  d||j@                  «      x| _!        ŠtE        |	|«      | _#        |jH                  r5tK        | jL                  «      dˆfd„«       }|jO                  d| «      | _&        d	| _(        y	# t*        $ r'}
|r‚ t        | d|
j,                  › d�«       Y d}
~
yd}
~
ww xY w# t4        $ r t        | «       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`.
        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.
    c                óZ   — d}| }|j                   j                  t        ||«      |¬«       y )NT)Úself_instance)r(   Úvalidate_pythonr   )Ú__dataclass_self__ÚargsÚkwargsÚ__tracebackhide__Úss        r-   Ú__init__z$complete_dataclass.<locals>.__init__x   s.   € Ø ÐØˆØ	× Ñ ×0Ñ0´¸DÀ&Ó1IÐYZÐ0Õ[r/   z	.__init__)r;   FÚ__post_init_post_parse__zVSupport for `__post_init_post_parse__` has been dropped, the method will not be called)r9   r:   Ú__signature__T)Úinitr<   Úvalidate_by_nameÚextraÚis_dataclassú`N)Útitleztype[PydanticDataclass]Ú	dataclassc               ó,   •— ‰j                  | ||«       y r*   )Úvalidate_assignment)ÚinstanceÚfieldÚvalueÚ	validators      €r-   Úvalidated_setattrz-complete_dataclass.<locals>.validated_setattrÂ   s   ø€ à×)Ñ)¨(°E¸5ÕAr/   )rD   r!   rE   r   rF   r   r0   ÚNone)rU   r   rV   ÚstrrW   r[   r0   rZ   ))rI   r4   Úconfig_dictr"   r=   Údefer_buildr   ÚhasattrÚwarningsÚwarnÚDeprecationWarningr   r   r   r   r   r&   rM   rN   rK   Úgenerate_schemar   ÚnameÚcore_configr2   Úclean_schemar   ÚtypingÚcastr$   r   r3   Úplugin_settingsr(   r	   r'   rT   r   Ú__setattr__Ú__get__r#   )r,   r;   r>   r9   r?   Úoriginal_initrI   r:   Ú
gen_schemaÚschemaÚerd   rY   rX   s                @r-   Úcomplete_dataclassro   W   s  ø€ ð: —L‘L€Mó\ð
  #×/Ñ/Ð0°	Ð:€HÔà€C„LØ,×8Ñ8€CÔä˜˜k¸.ÕIá˜N×6Ò6Ü˜CÔ ØäˆsÐ.Ô/Ü�‰ØdÔfxô	
ô -¨SÓ1€LÜØØØ!ô€Jô +ØÜÜ'ð Ø×*Ñ*Ø+×<Ñ<Ø ×&Ñ&Øô		
ó€CÔðØ×+Ñ+¨CÓ0ˆð !×,Ñ,°3·<±<Ð,Ó@€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ÔØøôE 'ò ÙØÜ˜C 1 Q§V¡V H¨A Ô/Üûð	ûô ò Ü˜CÔ Ùðús*   Ã(G ÄH Ç	HÇG?Ç?HÈHÈHc           	     ó¾   — t        j                  | «      xrG t        | d«       xr8 t        | j                  «      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(   r6   )ÚdataclassesrO   r^   ÚsetÚ__dataclass_fields__Ú
issupersetÚgetattr)Ú_clss    r-   Úis_builtin_dataclassrw   Ì   sZ   € ô> 	× Ñ  Ó&ò 	aÜ˜Ð6Ó7Ð7ò	aä�×)Ñ)Ó*×5Ñ5´c¼'À$ÐHYÐ[]Ó:^Ó6_Ó`ðr/   )NN)r,   ztype[StandardDataclass]r9   úNsResolver | Noner;   z_config.ConfigWrapper | Noner0   rZ   )r,   ú	type[Any]r;   z_config.ConfigWrapperr>   r1   r9   rx   r?   r1   r0   r1   )rv   ry   r0   z"TypeGuard[type[StandardDataclass]])9r5   Ú
__future__r   Ú_annotationsrq   rf   r_   Ú	functoolsr   r   r   r   Úpydantic_corer   r	   r
   r   Útyping_extensionsr   Úerrorsr   Úplugin._schema_validatorr   r   r   Ú r   r   Ú_fieldsr   Ú_generate_schemar   r   Ú	_genericsr   Ú_mock_val_serr   Ú_namespace_utilsr   Ú
_signaturer   Ú_utilsr   ÚTYPE_CHECKINGÚ	_typeshedr   ÚStandardDataclassÚconfigr   r<   r   ÚProtocolr!   ra   r=   ro   rw   r+   r/   r-   ú<module>rŽ      sý   ðÙ 6å 2ã Û Û ß $ß  ÷ó õ (å 0ß XÝ 0ß "Ý -ß @Ý 0Ý .Ý (Ý 3Ý &à	×ÒÝ@å#Ý"ô;Ð-¨v¯©õ ;ð6 3Ðð
 &*Ø37ð%Ø	 ð%à"ð%ð 1ð%ð 
ó	%ð0 Ø%)ØñrØ	ðrà)ðrð ð	rð
 #ðrð ðrð 
órôj"r/   