
    o iI                    t   d Z ddlmZ ddl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mZ ddl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  ddl!m"Z" ddl#m$Z$m%Z%m&Z& e	rddl'm(Z( ddl)m*Z* dZ+ ed          Z,ej-        dk    re eej.        e$e&f          eddddddddddd
dHd(                        Z/ eej.        e$e&f          eddddddddddd
dId,                        Z/n` eej.        e$e&f          eddddddddd-dJd.                        Z/ eej.        e$e&f          eddddddddd-dKd/                        Z/ eej.        e$e&f          	 dLddddddddddd
dMd2            Z/dNd4Z0 ee1          Z2ej-        d5k     rdOd:Z3e3ej4        _5        ddd;dd<dPdCZ6dQdGZ7dS )Rz7Provide an enhanced dataclass that performs validation.    )annotationsN)TYPE_CHECKINGAnyCallableGenericLiteralNoReturnTypeVaroverload)warn)	TypeGuarddataclass_transform   )_config_decorators_namespace_utils_typing_extra)_dataclasses)getattr_migration)
ConfigDict)PydanticUserError)Field	FieldInfoPrivateAttr)PydanticDataclass)MappingNamespace)	dataclassrebuild_dataclass_T   
   )field_specifiersFT.
initrepreqorderunsafe_hashfrozenconfigvalidate_on_initkw_onlyslotsr%   Literal[False]r&   boolr'   r(   r)   r*   r+    ConfigDict | type[object] | Noner,   bool | Noner-   r.   return-Callable[[type[_T]], type[PydanticDataclass]]c        
            d S N r$   s
             K/var/www/findabus/venv/lib/python3.11/site-packages/pydantic/dataclasses.pyr   r      s	     	    _clstype[_T]type[PydanticDataclass]c       
            d S r6   r7   )r:   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   s              r8   r   r   0   s	     #&#r9   r%   r&   r'   r(   r)   r*   r+   r,   c                    d S r6   r7   r>   s           r8   r   r   C   s	     	r9   c                   d S r6   r7   )	r:   r%   r&   r'   r(   r)   r*   r+   r,   s	            r8   r   r   R   s	     #&#r9   type[_T] | NoneGCallable[[type[_T]], type[PydanticDataclass]] | type[PydanticDataclass]c       
   	        
 |du s
J d            |dus
J d            t           j        dk    r|	
dni d
fd
}| |n
 ||           S )a  !!! abstract "Usage Documentation"
        [`dataclasses`](../concepts/dataclasses.md)

    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 to include the field in the `__repr__` output.
        eq: Determines if a `__eq__` method 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 a `__hash__` method should be included in the class, as in `dataclasses.dataclass`.
        frozen: Determines if the generated class should be a 'frozen' `dataclass`, which does not allow its
            attributes to be modified after it has been initialized. If not set, the value from the provided `config` argument will be used (and will default to `False` otherwise).
        config: The Pydantic config to use for the `dataclass`.
        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.   cls	type[Any]r3   r<   c                b   ddl m}  ||           rt          d| j         dd          | }t	          d | j        D                       }|s20t          | d	          r t          d
| j         dt          d           nt          | d	d          }t          j        |          }t          j                            |           }|                    |           | j        }t#          j        |           rLd}| f}t'          | t(                    rt(          | j                 }	||	fz   }t-          j        | j        |          } *|j        r t          d| j        dt          d           n	|j        pdt3          j        |           }
|
D ]K}t          | |d          }t7          |t8                    r#t;          | |t#          j        |                     Lt#          j        |           5  tA          j!        | fdd} ddd           n# 1 swxY w Y   |j"        rp| j#        tI          j%        | j#                  d%fd            }|&                    d|           | _#        r&t          | d          sd&d}d'd!}|| _'        || _(        d| _)        || _*        || _        t          |d"d          }|j+        | _+        tX          j-        d#k    r|||_.        || _.        |j/        | _/        ta          tb                    | _2        d| _3        t#          j4        | |d$           | S )(zCreate a Pydantic dataclass from a regular dataclass.

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

        Returns:
            A Pydantic dataclass.
        r   )is_model_classz(Cannot create a Pydantic dataclass from z" as it is already a Pydantic modelzdataclass-on-model)codec              3  >   K   | ]}t          j        |          V  d S r6   )dataclassesis_dataclass).0bases     r8   	<genexpr>z6dataclass.<locals>.create_dataclass.<locals>.<genexpr>   s-       Z ZD!9$!?!? Z Z Z Z Z Zr9   N__pydantic_config__z[`config` is set via both the `dataclass` decorator and `__pydantic_config__` for dataclass zK. The `config` specification from `dataclass` decorator will take priority.   )category
stacklevelzN`frozen` is set via both the `dataclass` decorator and `config` for dataclass zW.This is not recommended. The `frozen` specification on `dataclass` will take priority.FT)r%   r&   r'   r(   r)   r*   instancer   namestrvaluer   r3   Nonec               f   r | ||          S t          |           }t          ||d           }t          |t                    r|                    | |           d S t          |t
          j                  r| j                            ||           d S |j	        
                    | ||           d S r6   )typegetattr
isinstanceproperty__set__	functoolscached_property__dict____setitem____pydantic_validator__validate_assignment)rS   rT   rV   inst_clsattrfrozen_original_setattrs        r8   validated_setattrz>dataclass.<locals>.create_dataclass.<locals>.validated_setattr   s     C++HdEBBB>>xt44dH-- _LL511111i&?@@ _%11$>>>>>3GGRVX]^^^^^r9   __setstate__self	list[Any]c                D      fdt          j                   D             S )Nc                :    g | ]}t          |j                  S r7   )rZ   rT   )rL   frj   s     r8   
<listcomp>zTdataclass.<locals>.create_dataclass.<locals>._dataclass_getstate.<locals>.<listcomp>  s%    TTTaGD!&11TTTr9   )rJ   fields)rj   s   `r8   _dataclass_getstatez@dataclass.<locals>.create_dataclass.<locals>._dataclass_getstate  s(    TTTT;;Md;S;STTTTr9   statec                    t          t          j        |           |          D ]&\  }}t                              | |j        |           'd S r6   )ziprJ   rp   object__setattr__rT   )rj   rr   fieldrV   s       r8   _dataclass_setstatez@dataclass.<locals>.create_dataclass.<locals>._dataclass_setstate  sU    (+K,>t,D,De(L(L D Du**4UCCCCD Dr9   __firstlineno__)r!      )raise_errors)rS   r   rT   rU   rV   r   r3   rW   )rj   r   r3   rk   )rj   r   rr   rk   r3   rW   )5_internal._utilsrG   r   __name__any	__bases__hasattrr   UserWarningrZ   r   ConfigWrapperr   DecoratorInfosbuildupdate_from_config__doc___pydantic_dataclassesis_stdlib_dataclass
issubclassr   __parameters__types	new_classr*   r   safe_get_annotationsr[   r   setattras_dataclass_fieldpatch_base_fieldsrJ   r   rc   rv   r^   wraps__get____getstate__ri   __is_pydantic_dataclass____pydantic_decorators__
__module__sysversion_infory   __qualname__classmethod_pydantic_fields_complete__pydantic_fields_complete____pydantic_complete__complete_dataclass)rD   rG   original_clshas_dataclass_baseconfig_dictconfig_wrapper
decoratorsoriginal_docbasesgeneric_basecls_anns
field_namefield_valuerh   rq   rx   firstlinenorf   rg   r+   r'   r*   kwargsr(   r&   r.   r)   s                    @@r8   create_dataclassz#dataclass.<locals>.create_dataclass   sp    	544444># 	#k3<kkk)   
  ! Z ZCM Z Z ZZZ! 	f&8WSJ_=`=`&8]nqnz ] ] ]$	    !' 2ffEZ\`8a8a .{;; /55c::
%%n555
 { 4S99 	7  L
 FE#w'' 0&s'9://#,66C G$ meheq m m m( 	    %+4uG !5c::" 	` 	`J "#z488K+y11 `Z)>)QR])^)^___ #4S99 	 	'
 '
 
 
 
C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 - &	7"_S_--_ _ _ _ _ _ .-_ 077cBBCO 7WS.99 7U U U UD D D D $7 #6  )-%&0#"l,=tDD%0w&&;+B ,7L("-C'4+67P+Q+Q($)! 	0nSXYYYY
s   2HHHN)rD   rE   r3   r<   )r   r   )r:   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r   r   s     ``````  ` @r8   r   r   b   s    ^ 5===S===5(((*Y(((
7""$u55^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^@  $|1A1A$1G1GGr9   rD   c                b    t          d | j                                        D                       S )zReturn whether the fields where successfully collected (i.e. type hints were successfully resolves).

    This is a private property, not meant to be used outside Pydantic.
    c              3  $   K   | ]}|j         V  d S r6   )	_complete)rL   
field_infos     r8   rN   z,_pydantic_fields_complete.<locals>.<genexpr>A  s%      WW
z#WWWWWWr9   )all__pydantic_fields__values)rD   s    r8   r   r   <  s0    
 WWc6M6T6T6V6VWWWWWWr9   )r!      argsr   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)r   r   s     r8   _call_initvarr   J  s    
 :;;;r9   rP   )forcer{   _parent_namespace_depth_types_namespacer   r{   r   intr   MappingNamespace | Nonec               <   |s	| j         rdS dD ]}|| j        v rt          | |           d| _         ||}n!|dk    rt          j        |d          pi }ni }t          j        |          }t          j        | t          j
        | j        d          ||d	          S )
ax  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 rebuild the pydantic-core schema for.
        force: Whether to force the rebuilding of the 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`.
    N)__pydantic_core_schema__rb   __pydantic_serializer__Fr   T)parent_depthr   )parent_namespace)check)r{   ns_resolver_force_build)r   r`   delattrr   parent_frame_namespacer   
NsResolverr   r   r   r   rO   )rD   r   r{   r   r   re   
rebuild_nsr   s           r8   r   r   T  s    4  S. ta  3< C %C#%

	 1	$	$"9G^fjkkkqoq


"-#  K !3c5UCCC!
 
 
 
 
r9   class_rE   "TypeGuard[type[PydanticDataclass]]c               `    	 d| j         v ot          j        |           S # t          $ r Y dS w xY w)zWhether a class is a pydantic dataclass.

    Args:
        class_: The class.

    Returns:
        `True` if the class is a pydantic dataclass, `False` otherwise.
    r   F)r`   rJ   rK   AttributeError)r   s    r8   is_pydantic_dataclassr     sG    *fo=b+BZ[aBbBbb   uus    
--)r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r0   r+   r1   r,   r2   r-   r0   r.   r0   r3   r4   )r:   r;   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r-   r0   r.   r0   r3   r<   )r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r3   r4   )r:   r;   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r3   r<   r6   )r:   rA   r%   r/   r&   r0   r'   r0   r(   r0   r)   r0   r*   r2   r+   r1   r,   r2   r-   r0   r.   r0   r3   rB   )rD   r<   r3   r0   )r   r   r   r   r3   r	   )rD   r<   r   r0   r{   r0   r   r   r   r   r3   r2   )r   rE   r3   r   )8r   
__future__r   _annotationsrJ   r^   r   r   typingr   r   r   r   r   r	   r
   r   warningsr   typing_extensionsr   r   	_internalr   r   r   r   r   r   
_migrationr   r+   r   errorsr   rp   r   r   r   _internal._dataclassesr   _internal._namespace_utilsr   __all__r   r   rw   r   r   r}   __getattr__r   InitVar__call__r   r   r7   r9   r8   <module>r      sQ   = = 2 2 2 2 2 2         



  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^       < < < < < < < < L L L L L L L L L L L L < < < < < < ) ) ) ) ) )       % % % % % % 1 1 1 1 1 1 1 1 1 1 =999999<<<<<<
*WT]]w;+<e[*QRRR  %!37(,     X SR ;+<e[*QRRR  %!"37(,& & & & & X SR& &" ;+<e[*QRRR  %!"37(,     X SR ;+<e[*QRRR  %!"37(,& & & & & X SR& {'8%&MNNN VH !/3$(VH VH VH VH VH ONVHrX X X X  ))g< < < < $1K  #$04: : : : : :z     r9   