
    g%                       S r SSKJr  SSKrSSKrSSKrSSKJrJ	r	  SSKJ
r
Jr  SSKJrJrJrJr  SSKJr  SS	KJr  SS
KJrJr  SSKJr  SSKJrJr  SSKJr  SSKJr  SSK J!r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  SSK(J)r)  SSK*J+r+  \RX                  (       a)  SSK-J.r/  SSK0J1r1  SSK2J3r3   " S S\/\Rh                  5      r5O\r6  S!       S"S jjr7SSSS.           S#S jjr8S$S  jr9g)%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)get_standard_typevars_map)set_dataclass_mocks)
NsResolver)CallbackGetCoreSchemaHandler)generate_pydantic_signature)LazyClassAttribute)DataclassInstance)
ConfigDict)	FieldInfoc                  `    \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   S\S'   S\S'   Srg)PydanticDataclass&   a!  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)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r*       X/home/matz/Project1/venv/lib/python3.13/site-packages/pydantic/_internal/_dataclasses.pyr!   r!   &   s3    
	 21--"BB!EE;;!;; TTr2   r!   c                :    [        U 5      n[        XX2S9nX@l        g)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`.
)ns_resolvertypevars_mapconfig_wrapperN)r   r   r'   )clsr5   r7   r6   fieldss        r3   set_dataclass_fieldsr:   A   s%     -S1L%<F %r2   TF)raise_errorsr5   _force_buildc                 ^ U R                   nSS jnU R                   S3Ul        X`l         UR                  U l        [	        XUS9  U(       d'  UR
                  (       a  [        X R                  5        g[        U S5      (       a  [        R                  " S[        5        [        U 5      n[        UUUS9n[        S[        [         UU R"                  UR$                  UR&                  S	S
95      U l        [+        U SS5      n	 U	(       a%  U	" U [-        [        UR.                  SS9USS95      n
OUR/                  U SS9n
 UR5                  U R                  S9n UR7                  U
5      n
[:        R<                  " SU 5      n Xl        [A        XU RB                  U R                  SXRD                  5      =U l#        m[I        X5      U l%        URL                  (       a7  [O        U RP                  5      SU4S jj5       nURS                  SU 5      U l(        S	U l*        g	! [0         a6  nU(       a  e [        X R                  SUR2                   S35         SnAgSnAff = f! UR8                   a    [        X R                  S5         gf = f)aJ  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                R    SnU nUR                   R                  [        X5      US9  g )NT)self_instance)r)   validate_pythonr   )__dataclass_self__argskwargs__tracebackhide__ss        r3   __init__$complete_dataclass.<locals>.__init__v   s,     	  00D1IYZ0[r2   z	.__init__)r7   F__post_init_post_parse__zVSupport for `__post_init_post_parse__` has been dropped, the method will not be called)r5   r6   __signature__T)initr9   populate_by_nameextrais_dataclass__get_pydantic_core_schema__N)from_dunder_get_core_schemaunpack)ref_mode`)titlezall referenced typesztype[PydanticDataclass]	dataclassc               *   > TR                  XU5        g )N)validate_assignment)instancefieldvalue	validators      r3   validated_setattr-complete_dataclass.<locals>.validated_setattr   s    ))(5Ar2   )rA   r!   rB   r   rC   r   returnNone)rW   r   rX   strrY   r_   r]   r^   )+rF   r-   config_dictr#   r:   defer_buildr   r+   hasattrwarningswarnDeprecationWarningr   r   r   r   r   r'   rK   rL   rI   getattrr   generate_schemar   namecore_configclean_schemaCollectedInvalidtypingcastr%   r   r,   plugin_settingsr)   r	   r(   rV   r   __setattr____get__r$   )r8   r7   r;   r5   r<   original_initrF   r6   
gen_schemaget_core_schemaschemaeri   r[   rZ   s                 @r3   complete_dataclassrv   U   sk   : LLM\
  #//0	:HL,88C.IN66C.s.//dfx	
 -S1L!J +' **+<< &&		
C c#A4HO$,J66TYZ%F  //QV/WF !,,3<<,@K((0 ++/
5C $* -DS^^S%5%5{KQoQo. C #36"GC))	s		B 
 	B ,33D#> $CE ' C166(!}=	 && C/EFs0   +H 1H I! 
I(,II!&J
	J
c           	         [         R                  " U 5      =(       aP    [        U S5      (       + =(       a8    [        U R                  5      R                  [        [        U S0 5      5      5      $ )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.
```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)   r0   )dataclassesrM   rb   set__dataclass_fields__
issupersetrf   )_clss    r3   is_builtin_dataclassr}      sZ    > 	  & 	a677	a))*55c'$HY[]:^6_`r2   )NN)r8   ztype[StandardDataclass]r5   NsResolver | Noner7   z_config.ConfigWrapper | Noner]   r^   )r8   	type[Any]r7   z_config.ConfigWrapperr;   boolr5   r~   r<   r   r]   r   )r|   r   r]   z"TypeGuard[type[StandardDataclass]]):r/   
__future__r   _annotationsrx   rl   rc   	functoolsr   r   r   r   pydantic_corer   r	   r
   r   typing_extensionsr   errorsr   plugin._schema_validatorr   r   r    r   r   _fieldsr   _generate_schemar   	_genericsr   _mock_val_serr   _namespace_utilsr   _schema_generation_sharedr   
_signaturer   _utilsr   TYPE_CHECKING	_typeshedr   StandardDataclassconfigr   r9   r   Protocolr!   re   r:   rv   r}   r*   r2   r3   <module>r      s   6 2    $    ( 0 X 0 " - , 0 . ( C 3 &	@#"U-v U0 3
 &*37%	 %"% 1% 
	%0 %)|	|)| 	|
 #| | 
|~"r2   