Ë
    °ëjF"  ã                  óÈ  — 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jT                  r8d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„Z4d"d„Z5y)#z0Private 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                  ó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      úl/home/oem/CyberBrain26-unified/dev-env/.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__z4ClassVar[SchemaValidator | PluggableSchemaValidator]Ú__pydantic_validator__N)r0   r1   r2   Ú__doc__r3   r&   r,   r*   r5   r5   *   s3   … ñ
	ð 2Ó1Ø-Ó-Ø"BÓBØ!EÓEØ;Ó;Ø!;Ó;Ø TÔTr,   r5   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   r:   )ÚclsÚtypes_namespacer@   r?   Úfieldss        r*   Úset_dataclass_fieldsrD   E   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| «      | _&        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)ÚinitrC   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,   )rM   r5   r(   r   r)   r   r.   r/   )rX   r   rY   ÚstrrZ   r]   r.   r/   ))ÚhasattrÚwarningsÚwarnÚDeprecationWarningr   Úmerge_cls_and_parent_nsrD   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;   rW   r   Ú__setattr__Ú__get__r7   )rA   r@   rE   rB   r?   Ú
gen_schemaÚsigr+   Úget_core_schemaÚschemaÚerh   r\   r[   s                @r*   Úcomplete_dataclassru   W   sM  ø€ ô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ÔØøôE 'ò ÙØÜ˜C §¡°°1·6±6°(¸!¨}Ô=Üûð	ûð ×&Ñ&ò Ü˜C §¡Ð/EÔFÙðús+   ÃA G ÄH Ç	HÇ&(HÈHÈ&IÉI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<   r3   )ÚdataclassesrI   r^   Úsetr!   Ú
issupersetre   )Ú_clss    r*   Úis_builtin_dataclassr{   Æ   sZ   € ô> 	× Ñ  Ó&ò 	aÜ˜Ð6Ó7Ð7ò	aä�×)Ñ)Ó*×5Ñ5´c¼'À$ÐHYÐ[]Ó:^Ó6_Ó`ðr,   )NN)rA   ztype[StandardDataclass]rB   údict[str, Any] | Noner@   z_config.ConfigWrapper | Noner.   r/   )
rA   ú	type[Any]r@   z_config.ConfigWrapperrE   ÚboolrB   r|   r.   r~   )rz   r}   r.   z"TypeGuard[type[StandardDataclass]])6r=   Ú
__future__r   Ú_annotationsrw   rk   r_   Ú	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   rC   r   ÚProtocolr    r5   ra   rD   ru   r{   r&   r,   r*   ú<module>r�      sþ   ðÙ 6å 2ã Û Û ß $ß *Ñ *÷ó õ (å 0ß XÝ 0ß 1Ñ 1Ý -Ý ,Ý 0Ý .Ý CÝ 3à	×ÒÝ#Ý"ô˜FŸO™Oô ôUÐ-¨v¯©õ Uð0 3Ðð
 .2Ø37ð%Ø	 ð%à*ð%ð 1ð%ð 
ó	%ð, ñ	lØ	ðlà)ðlð ð	lð
 +ðlð 
ólô^"r,   