
    h-i0                       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	m
Z
mZmZmZmZ ddlmZmZ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mZ erddl m!Z! dZ" ed      Z#ejH                  dk\  r eejJ                  ef      eddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"d              Z& eejJ                  ef      eddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#d              Z&nz eejJ                  ef      eddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d$d              Z& eejJ                  ef      eddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%d              Z& eejJ                  ef      	 d&ddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd       Z& ee'      Z(dejH                  cxk  rdk  rn nd(dZ)e)ejT                  _+        ddddd	 	 	 	 	 	 	 	 	 	 	 d)d Z,d*d!Z-y)+z7Provide an enhanced dataclass that performs validation.    )annotationsN)TYPE_CHECKINGAnyCallableGenericNoReturnTypeVaroverload)Literal	TypeGuarddataclass_transform   )_config_decorators_typing_extra)_dataclasses)getattr_migration)
ConfigDict)Field	FieldInfo)PydanticDataclass)	dataclassrebuild_dataclass_T   
   )field_specifiersFT.
initrepreqorderunsafe_hashfrozenconfigvalidate_on_initkw_onlyslotsc        
             y N r   s
             SD:\DhanshreeandTeamAI\Github\ai_code\venv\Lib\site-packages\pydantic/dataclasses.pyr   r      s     	    c       
             y r+   r,   )_clsr    r!   r"   r#   r$   r%   r&   r'   r(   r)   s              r-   r   r   +   s      	r.   r    r!   r"   r#   r$   r%   r&   r'   c                     y r+   r,   r1   s           r-   r   r   ?   s     	r.   c                    y r+   r,   )	r0   r    r!   r"   r#   r$   r%   r&   r'   s	            r-   r   r   N   s     	r.   c       
   	         |du sJ d       |dusJ d       t         j                  dk\  rt        |	|
      d	dni d
ddfd}| |S  ||       S )a2  Usage docs: https://docs.pydantic.dev/2.5/concepts/dataclasses/

    A decorator used to create a Pydantic-enhanced dataclass, similar to the standard Python `dataclass`,
    but with added validation.

    This function should be used similarly to `dataclasses.dataclass`.

    Args:
        _cls: The target `dataclass`.
        init: Included for signature compatibility with `dataclasses.dataclass`, and is passed through to
            `dataclasses.dataclass` when appropriate. If specified, must be set to `False`, as pydantic inserts its
            own  `__init__` function.
        repr: A boolean indicating whether or not to include the field in the `__repr__` output.
        eq: Determines if a `__eq__` should be generated for the class.
        order: Determines if comparison magic methods should be generated, such as `__lt__`, but not `__eq__`.
        unsafe_hash: Determines if an unsafe hashing function should be included in the class.
        frozen: Determines if the generated class should be a 'frozen' `dataclass`, which does not allow its
            attributes to be modified from its constructor.
        config: A configuration for the `dataclass` generation.
        validate_on_init: A deprecated parameter included for backwards compatibility; in V2, all Pydantic dataclasses
            are validated on init.
        kw_only: Determines if `__init__` method parameters must be specified by keyword only. Defaults to `False`.
        slots: Determines if the generated class should be a 'slots' `dataclass`, which does not allow the addition of
            new attributes after instantiation.

    Returns:
        A decorator that accepts a class as its argument and returns a Pydantic `dataclass`.

    Raises:
        AssertionError: Raised if `init` is not `False` or `validate_on_init` is `False`.
    Fz7pydantic.dataclasses.dataclass only supports init=Falsez-validate_on_init=False is no longer supportedr   )r(   r)   c           	         | j                   D ]O  }	 t        | |      }t        |t              s!|j
                  s.t        | |t        j                  |d             Q y# t        $ r Y ^w xY w)a3  Make sure that stdlib `dataclasses` understands `Field` kwargs like `kw_only`
            To do that, we simply change
              `x: int = pydantic.Field(..., kw_only=True)`
            into
              `x: int = dataclasses.field(default=pydantic.Field(..., kw_only=True), kw_only=True)`
            T)defaultr(   N)	__annotations__getattrAttributeError
isinstancer   r(   setattrdataclassesfield)cls
field_namefield_values      r-   make_pydantic_fields_compatiblez2dataclass.<locals>.make_pydantic_fields_compatible   sg     "11
")#z":K k95+:M:MC[->->{\`-ab 2 & s   A  	A,+A,c                     y r+   r,   )_s    r-   rA   z2dataclass.<locals>.make_pydantic_fields_compatible   s    r.   c           
     f   | }
}|t        | dd      }||}t        j                  |      }t        j                  j                  |       }| j                  }t        j                  |       rNd}| f}t        | t              rt        | j                     }||fz   }t        j                  | j                  |      }  |        t        j                   | fdd} || _        || _        |j$                  | _        |j&                  | _        t        j(                  | |dd      }	|	| _        | S )zCreate a Pydantic dataclass from a regular dataclass.

        Args:
            cls: The class to create the Pydantic dataclass from.

        Returns:
            A Pydantic dataclass.
        N__pydantic_config__T)r    r!   r"   r#   r$   r%   Fraise_errorstypes_namespace)r8   r   ConfigWrapperr   DecoratorInfosbuild__doc___pydantic_dataclassesis_builtin_dataclass
issubclassr   __parameters__types	new_class__name__r<   r   __pydantic_decorators__
__module____qualname__complete_dataclass__pydantic_complete__)r>   original_clsconfig_dict
cls_configconfig_wrapper
decoratorsoriginal_docbasesgeneric_basepydantic_completer&   r"   r%   kwargsrA   r#   r!   r$   s             r-   create_dataclassz#dataclass.<locals>.create_dataclass   sK     &;TBJ%( ..{; //55c:

 {{ 55c:  L
 FE#w'&s'9'9:///#,,6C',##

 #

 

 '1#"%00'441DDeT
 %6!
r.   )r>   	type[Any]returnNone)re   rf   )r>   rd   re   type[PydanticDataclass])sysversion_infodict)r0   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   rc   rb   rA   s     ``````    @@r-   r   r   _   s{    \ 5=SSS=5(Y*YY(
7"gU3	c" 	= =~ |D!!r.   )r      )r      c                     t        d      )a9  This function does nothing but raise an error that is as similar as possible to what you'd get
        if you were to try calling `InitVar[int]()` without this monkeypatch. The whole purpose is just
        to ensure typing._type_check does not error if the type hint evaluates to `InitVar[<parameter>]`.
        z 'InitVar' object is not callable)	TypeError)argsrb   s     r-   _call_initvarrp      s    
 :;;r.      )forcerG   _parent_namespace_depth_types_namespacec               *   |s| j                   ry||j                         }n:|dkD  rt        j                  |      xs i }|}ni }t        j                  | |      }t        j                  | t        j                  | j                  d      ||      S )a}  Try to rebuild the pydantic-core schema for the dataclass.

    This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
    the initial attempt to build the schema, and automatic rebuilding fails.

    This is analogous to `BaseModel.model_rebuild`.

    Args:
        cls: The class to build the dataclass core schema for.
        force: Whether to force the rebuilding of the model schema, defaults to `False`.
        raise_errors: Whether to raise errors, defaults to `True`.
        _parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
        _types_namespace: The types namespace, defaults to `None`.

    Returns:
        Returns `None` if the schema is already "complete" and rebuilding was not required.
        If rebuilding _was_ required, returns `True` if rebuilding was successful, otherwise `False`.
    Nr   )parent_depthF)checkrF   )
rX   copyr   parent_frame_namespaceget_cls_types_namespacerM   rW   r   rI   rE   )r>   rr   rG   rs   rt   rH   frame_parent_nss          r-   r   r      s    4 S..'5E5J5J5LO&*"/"F"FTk"l"rpr #2"$+CCCYO$77!!#"9"9G%+	
 	
r.   c                L    t        j                  |       xr d| j                  v S )zWhether a class is a pydantic dataclass.

    Args:
        __cls: The class.

    Returns:
        `True` if the class is a pydantic dataclass, `False` otherwise.
    __pydantic_validator__)r<   is_dataclass__dict__)__clss    r-   is_pydantic_dataclassr   /  s$     ##E*Y/G5>>/YYr.   )r    Literal[False]r!   boolr"   r   r#   r   r$   r   r%   r   r&    ConfigDict | type[object] | Noner'   bool | Noner(   r   r)   r   re   -Callable[[type[_T]], type[PydanticDataclass]])r0   type[_T]r    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r   r(   r   r)   r   re   rg   )r    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r   re   r   )r0   r   r    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r   re   rg   r+   )r0   ztype[_T] | Noner    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r   r(   r   r)   r   re   zGCallable[[type[_T]], type[PydanticDataclass]] | type[PydanticDataclass])ro   r   rb   r   re   r   )r>   rg   rr   r   rG   r   rs   intrt   zdict[str, Any] | Nonere   r   )r   rd   re   z"TypeGuard[type[PydanticDataclass]]).rL   
__future__r   _annotationsr<   rh   rQ   typingr   r   r   r   r   r	   r
   typing_extensionsr   r   r   	_internalr   r   r   r   rM   
_migrationr   r&   r   fieldsr   r   _internal._dataclassesr   __all__r   ri   r=   r   rS   __getattr__rp   InitVar__call__r   r   r,   r.   r-   <module>r      su   = 2  
  U U U E E : : < )  $9
*T]w;+<+<e*DE  %!37(,  	
    1 &   
7  F ;+<+<e*DE  %!37(,  	
     1 &   
!  F$ ;+<+<e*DE  %!37(,  	
    1 & 
7  F ;+<+<e*DE  %!37(,  	
     1 & 
!  F {'8'8%&@A K" !/3$(K"
K" K" 	K"
 	K" K" K" K" -K" "K" K" K" MK" BK"\  )	S''< $1K  #$.2.
	 .
 .
 	.

 !.
 ,.
 .
b	Zr.   