a
    “˜ëj˜  ã                
   @  sN  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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mZmZmZmZmZmZmZ ddlmZmZ dd	l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( ddlm)Z)m*Z* ddl+m,Z, ddl-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZGmHZHmIZImJZJ ddlKmLZLmMZM e�rðddlNmOZP ddlNmQZQmRZR ddlNmSZT ddlUmVZV ddl2mWZW neXƒ ZPeXƒ ZTeXjYZZG d d!„ d!e[ƒZ\d"d#œd$d%d&œd'd(„Z]ed)ƒZ^ed*ePeTe]fd+�G d,d-„ d-e
ƒƒZ_d.d%d/d0œd1d2„Z`d3d4d5d6œd7d8„Zad3d3d4d9d9d:d;œd<d=„Zbd>d4d/d?œd@dA„Zcd>d%dBœdCdD„Zdd>dEdFd/dGœdHdI„Zed*d*dd"dJœd>dEdFdKdKdLdKdKdMœdNdO„Zfd>d/dBœdPdQ„ZgG dRdS„ dSƒZhG dTdU„ dUƒZidVdVdWœdXdY„ZjdVdVdWœdZd[„Zked4d\œd]d^„ƒZldS )_z"Private logic for creating models.é    )ÚannotationsN)ÚABCMeta)ÚcacheÚpartialÚwraps)ÚFunctionType)ÚTYPE_CHECKINGÚAnyÚCallableÚGenericÚLiteralÚNoReturnÚTypeVarÚcast)ÚPydanticUndefinedÚSchemaSerializer)ÚTypeAliasTypeÚdataclass_transformÚ
deprecatedÚget_argsÚ
get_origin)Útyping_objectsé   )ÚPydanticUndefinedAnnotationÚPydanticUserError)Úcreate_schema_validator)ÚGenericBeforeBaseModelWarningÚPydanticDeprecatedSince20é   )ÚConfigWrapper)ÚDecoratorInfosÚPydanticDescriptorProxyÚget_attribute_from_basesÚunwrap_wrapped_function)Úcollect_model_fieldsÚis_valid_field_nameÚis_valid_privateattr_nameÚrebuild_model_fields)ÚGenerateSchemaÚInvalidSchemaError)ÚPydanticGenericMetadataÚget_model_typevars_map)Úimport_cached_base_modelÚimport_cached_field_info)Úset_model_mocks)Ú
NsResolver)Úgenerate_pydantic_signature)Ú_make_forward_refÚeval_type_backportÚis_classvar_annotationÚparent_frame_namespace)ÚLazyClassAttributeÚSafeGetItemProxy)ÚField)Ú	FieldInfoÚModelPrivateAttr)ÚPrivateAttr)Ú	BaseModel)ÚPydanticExtraInfoc                      s*   e Zd ZdZddddœ‡ fdd„Z‡  ZS )Ú_ModelNamespaceDictz{A dictionary subclass that intercepts attribute setting on model classes and
    warns about overriding of decorators.
    ÚstrÚobjectÚNone)ÚkÚvÚreturnc                   sP   |   |d ¡}|rB||urBt|tƒrBtjd|› d|jj› d�dd� tƒ  ||¡S )Nú`z"` overrides an existing Pydantic `z` decoratorr   ©Ú
stacklevel)	ÚgetÚ
isinstancer!   ÚwarningsÚwarnZdecorator_infoZdecorator_reprÚsuperÚ__setitem__)ÚselfrA   rB   Úexisting©Ú	__class__© úe/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pydantic/_internal/_model_construction.pyrL   9   s    þz_ModelNamespaceDict.__setitem__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rL   Ú__classcell__rQ   rQ   rO   rR   r=   4   s   r=   F©ÚinitzLiteral[False]r	   )rY   rC   c                 C  s   dS )zÍOnly for typing purposes. Used as default value of `__pydantic_fields_set__`,
    `__pydantic_extra__`, `__pydantic_private__`, so they could be ignored when
    synthesizing the `__init__` signature.
    NrQ   rX   rQ   rQ   rR   ÚNoInitFieldD   s    rZ   Ú_TT)Zkw_only_defaultZfield_specifiersc                
      sÒ   e Zd Zd(ddddddd	d
dœ‡ fdd„Zes>dd	dœdd„Zed	d	ddœdd„ƒZdddœ‡ fdd„Ze	j
Z
e	jZedddœdd„ƒZeeddd�dd œd!d"„ƒƒZedd œd#d$„ƒZd%d œ‡ fd&d'„Z‡  ZS ))ÚModelMetaclassNTr>   útuple[type[Any], ...]údict[str, Any]zPydanticGenericMetadata | NoneÚboolú
str | Noner	   Útype)Úcls_nameÚbasesÚ	namespaceÚ__pydantic_generic_metadata__Ú#__pydantic_reset_parent_namespace__Ú_create_model_moduleÚkwargsrC   c           "        s   |�rÚt jdkrXd|v r"|d }qdddlm}	m}
m} ||ƒ }rR|
||	jd�}qdi }n| di ¡}|  |¡\}}}t	 
||||¡}|j|d< t|||j||ƒ}|s¨|rêt||ƒ‰ ˆ durâtˆ ƒdd	d
dœ‡ fdd„ƒ}||d< nt|d< ||d< i |¥|¥|d< tdtƒ j| |||fi |¤Žƒ}tƒ }|j}t|v �r`| t¡| |¡k �r`tjtdƒdd� t|jddƒ |_|j|ju �r„dnd|_i |_ t!j"|dd�|_#|j# $|¡ |�r¼||_%�n<t|di ƒ dd¡‰t|ddƒ�pàˆ‰ˆ�rêˆ�rêt&‡fdd„ˆD ƒƒ�sêddl'm(} t)‡fd d„ˆD ƒƒ}|ˆv �rr|ˆv�rrd! *d"d#„ |D ƒ¡}|j+› d$|› d%|j+› d&|› d'�}npˆ| }d! *d(d#„ |D ƒ¡}d)|› d*�}d+|› d,�}t|v�râd! *d-d#„ |D ƒ|g ¡}|d.|j+› d/|› d0�7 }t,|ƒ‚ddˆd1œ|_%d|_-| .¡ D ]\}}| /||¡ �q|�r0t0t1ƒ ƒ|_2t|d2dƒ}t3|t4ƒ�rPt5|ƒ}t6|d3�} t7||| d4� d5d6„ |j#j8 .¡ D ƒ|_9|j:�r’t;|ƒ nt<||| d|d7� |j=�rÀd8|v�rÀt>||ƒ t||ƒj?f i |¤Ž |S d9D ]}!| @|!d¡ �qÞ| di ¡ A¡  tƒ j| |||fi |¤ŽS dS ):a…  Metaclass for creating Pydantic models.

        Args:
            cls_name: The name of the class to be created.
            bases: The base classes of the class to be created.
            namespace: The attribute dictionary of the class to be created.
            __pydantic_generic_metadata__: Metadata for generic models.
            __pydantic_reset_parent_namespace__: Reset parent namespace.
            _create_model_module: The module of the class to be created, if created by `create_model`.
            **kwargs: Catch-all for any other keyword arguments.

        Returns:
            The new class created by the metaclass.
        )é   é   Ú__annotations__r   )ÚFormatÚcall_annotate_functionÚ!get_annotate_from_class_namespace)ÚformatÚmodel_configNr;   r	   r@   ©rM   ÚcontextrC   c                  s   t | |ƒ ˆ | |ƒ dS )z�We need to both initialize private attributes and call the user-defined model_post_init
                        method.
                        N)Úinit_private_attributes)rM   rr   )Úoriginal_model_post_initrQ   rR   Úwrapped_model_post_init�   s    
z7ModelMetaclass.__new__.<locals>.wrapped_model_post_initÚmodel_post_initÚ__class_vars__Ú__private_attributes__útype[BaseModel]z�Classes should inherit from `BaseModel` before generic classes (e.g. `typing.Generic[T]`) for pydantic generics to work properly.r   rE   Z__pydantic_base_init__FT)Zreplace_wrapped_methodsre   Ú
parametersrQ   Ú__parameters__c                 3  s   | ]}|ˆ v V  qd S ©NrQ   ©Ú.0Úx)rz   rQ   rR   Ú	<genexpr>¹   ó    z)ModelMetaclass.__new__.<locals>.<genexpr>)ÚRootModelRootTypec                 3  s   | ]}|ˆ vr|V  qd S r|   rQ   r}   )Úparent_parametersrQ   rR   r€   ¼   r�   z, c                 S  s   g | ]
}|j ‘qS rQ   ©rS   r}   rQ   rQ   rR   Ú
<listcomp>Å   r�   z*ModelMetaclass.__new__.<locals>.<listcomp>zS is a subclass of `RootModel`, but does not include the generic type identifier(s) zL in its parameters. You should parametrize RootModel directly, e.g., `class z(RootModel[z	]): ...`.c                 S  s   g | ]}t |ƒ‘qS rQ   )r>   r}   rQ   rQ   rR   r…   Í   r�   ztyping.Generic[ú]zJAll parameters must be present on typing.Generic; you should inherit from Ú.c                 S  s   g | ]
}|j ‘qS rQ   r„   r}   rQ   rQ   rR   r…   Ø   r�   z- Note: `typing.Generic` must go last: `class ú(z): ...`))ÚoriginÚargsrz   Ú__pydantic_parent_namespace__)Úparent_namespace)Úconfig_wrapperÚns_resolverc                 S  s   i | ]\}}||j “qS rQ   ©Úinfo©r~   rA   rB   rQ   rQ   rR   Ú
<dictcomp>÷   s   z*ModelMetaclass.__new__.<locals>.<dictcomp>)Úraise_errorsÚcreate_model_moduleÚ__hash__)Z__pydantic_fields_set__Ú__pydantic_extra__Ú__pydantic_private__)BÚsysÚversion_infoZannotationlibrl   rm   rn   Z
FORWARDREFrG   Ú_collect_bases_datar   Z	for_modelZconfig_dictÚinspect_namespaceÚignored_typesÚget_model_post_initr   rs   r   rK   Ú__new__r,   Ú__mro__r   ÚindexrI   rJ   r   ÚgetattrÚ__init__Z__pydantic_custom_init__rv   Z__pydantic_post_init__Z__pydantic_setattr_handlers__r    ÚbuildÚ__pydantic_decorators__Zupdate_from_configre   ÚallZ
root_modelr‚   ÚtupleÚjoinrS   Ú	TypeErrorÚ__pydantic_complete__ÚitemsÚ__set_name__Úbuild_lenient_weakvaluedictr4   r‹   rH   ÚdictÚunpack_lenient_weakvaluedictr/   Úset_model_fieldsÚcomputed_fieldsÚ__pydantic_computed_fields__Zdefer_buildr.   Úcomplete_model_classÚfrozenÚset_default_hash_funcZ__pydantic_init_subclass__ÚpopÚclear)"Zmcsrb   rc   rd   re   rf   rg   rh   Úraw_annotationsrl   rm   rn   ZannotateZbase_field_namesÚ
class_varsZbase_private_attributesr�   Úprivate_attributesru   ÚclsZ
BaseModel_Úmror‚   Zmissing_parametersZparameters_strÚerror_messageZcombined_parametersZgeneric_type_labelZ	bases_strÚnameÚobjrŒ   rŽ   Zinstance_slotrO   )rt   rz   rƒ   rR   rž   T   sØ    
ÿ

ÿ

  ÿûÿ
$ÿþþÿÿÿ
ÿý

ÿ
û
þzModelMetaclass.__new__)ÚitemrC   c                 C  s,   | j  d¡}|r ||v r || S t|ƒ‚dS )zNThis is necessary to keep attribute access working for class attribute access.rx   N)Ú__dict__rG   ÚAttributeError)rM   r¿   r¹   rQ   rQ   rR   Ú__getattr__  s    zModelMetaclass.__getattr__zdict[str, object])rŠ   rh   rC   c                 O  s   t ƒ S r|   )r=   )rº   rŠ   rh   rQ   rQ   rR   Ú__prepare__$  s    zModelMetaclass.__prepare__ztype[_T])ÚsubclassrC   c                   s$   t jd| j› d�dd� tƒ  |¡S )Nz>For performance reasons, virtual subclasses registered using 'zK.register()' are not supported in 'isinstance()' and 'issubclass()' checks.r   rE   )rI   rJ   rU   rK   Úregister)rM   rÄ   rO   rQ   rR   rÅ   ,  s
    ýzModelMetaclass.registerz6tuple[set[str], set[str], dict[str, ModelPrivateAttr]])rc   rC   c                 C  sj   t ƒ }tƒ }tƒ }i }| D ]D}t||ƒr||ur| t|di ƒ ¡ ¡ | |j¡ | |j¡ q|||fS )NÚ__pydantic_fields__)r,   ÚsetÚ
issubclassÚupdater¡   Úkeysrw   rx   )rc   r;   Úfield_namesr¸   r¹   ÚbaserQ   rQ   rR   rš   7  s    z"ModelMetaclass._collect_bases_dataúXThe `__fields__` attribute is deprecated, use the `model_fields` class property instead.)Úcategoryúdict[str, FieldInfo]©rC   c                 C  s   t jdtdd� t| di ƒS )NrÍ   r   rE   rÆ   )rI   rJ   r   r¡   ©rM   rQ   rQ   rR   Ú
__fields__F  s    ýzModelMetaclass.__fields__c                 C  sT   d| j vrdS td| jƒ}td| jƒ}|dur6|j}nd}tdd„ | ¡ D ƒƒoR|S )	z²Whether the fields were successfully collected (i.e. type hints were successfully resolved).

        This is a private attribute, not meant to be used outside Pydantic.
        rÆ   FrÏ   zPydanticExtraInfo | NoneNTc                 s  s   | ]}|j V  qd S r|   )Z	_complete)r~   Ú
field_inforQ   rQ   rR   r€   c  r�   z>ModelMetaclass.__pydantic_fields_complete__.<locals>.<genexpr>)rÀ   r   rÆ   Ú__pydantic_extra_info__Zcompleter¥   Úvalues)rM   Zfield_infosÚpydantic_extra_infoZextra_completerQ   rQ   rR   Ú__pydantic_fields_complete__R  s    
z+ModelMetaclass.__pydantic_fields_complete__z	list[str]c                   s$   t tƒ  ¡ ƒ}d|v r | d¡ |S )NrÒ   )ÚlistrK   Ú__dir__Úremove)rM   Ú
attributesrO   rQ   rR   rÙ   e  s    
zModelMetaclass.__dir__)NTN)rS   rT   rU   rž   r   rÂ   ÚclassmethodrÃ   rÅ   ra   Ú__instancecheck__Ú__subclasscheck__Ústaticmethodrš   Úpropertyr   rÒ   r×   rÙ   rW   rQ   rQ   rO   rR   r\   R   s,      ù" Gÿr\   r;   r@   rq   c                C  st   t | ddƒdu rpi }| j ¡ D ]D\}}|jrF|jdi | j¥|¥d�}n|jdd�}|tur|||< qt| d|ƒ dS )a  This function is meant to behave like a BaseModel method to initialize private attributes.

    It takes context as an argument since that's what pydantic-core passes when calling it.

    Args:
        self: The BaseModel instance.
        context: The context.
    r—   NT)Úcall_default_factoryZvalidated_data)rá   )r¡   rx   rª   Z$default_factory_takes_validated_dataÚget_defaultrÀ   r   Úobject_setattr)rM   rr   Zpydantic_privater½   Úprivate_attrÚdefaultrQ   rQ   rR   rs   l  s    	ÿ
rs   r^   r]   zCallable[..., Any] | None)rd   rc   rC   c                 C  s2   d| v r| d S t ƒ }t|dƒ}||jur.|S dS )zaGet the `model_post_init` method from the namespace or the class bases, or `None` if not defined.rv   N)r,   r"   rv   )rd   rc   r;   rv   rQ   rQ   rR   r�   „  s    

r�   zset[str]zdict[str, ModelPrivateAttr])rd   r·   rœ   Úbase_class_varsÚbase_class_fieldsrC   c              
     s6  ddl m‰ m} tƒ }|tƒ  }i }d|v s4d| v r<tdƒ‚tƒ }	t|  ¡ ƒD �]Ú\}
}|
dksN|
dkrlqNqNt	|t
ƒr¦|j| d kr¦d| v r¦|j | d › d	�¡r¦qNqNt	||ƒs¼|jjd
krÊ|	 |
¡ qNqNt	|ˆ ƒ�r&|
 d¡ròtd|
›d	�ƒ‚n$t|
ƒ�rtdd|
 ›d|
›d	�ƒ‚|||
< | |
= qNt	||ƒ�rdt|
ƒ�sd|
 d¡�pJd}td|›d|
›d	�ƒ‚qN|
 d¡�rtqNqNt|
ƒ�r²|
|v�s–t||
 ƒ�s*tˆ ||d�ƒ||
< | |
= qN|
|v �rÀqNqN|
|vrN|
|v �rètd|
›d�dd�‚qNt	||ƒ�r
td|
›d�dd�‚qNtd|
› d|›d|
› d�dd�‚qN| ¡ D ]ü\}}t|ƒ�r4||v�r4||	v�r4t|ƒ�s4||v�r4t|ddƒd
k�r4t	|tƒ�rÚt d¡}|du�rÚz tt|ddd �|j|jd!�}W n ttf�yØ   Y n0 t  t!|ƒ¡�r$t"|ƒ^}}t#‡ fd"d#„|D ƒdƒ}|du�r$|||< �q4|ƒ ||< �q4|S )$aL  Iterate over the namespace and:
    * gather private attributes
    * check for items which look like fields but are not (e.g. have no annotation) and warn.

    Args:
        namespace: The attribute dictionary of the class to be created.
        raw_annotations: The (non-evaluated) annotations of the model.
        ignored_types: A tuple of ignore types.
        base_class_vars: A set of base class class variables.
        base_class_fields: A set of base class fields.

    Returns:
        A dict containing private attributes info.

    Raises:
        TypeError: If there is a `__root__` field in model.
        NameError: If private attribute name is invalid.
        PydanticUserError:
            - If a field does not have a type annotation.
            - If a field on base class was overridden by a non-annotated attribute.
    r   )r9   r:   Z__root__zUTo define root models, use `pydantic.RootModel` rather than a field called '__root__'rp   r–   rT   rU   r‡   Ú	functoolsÚ__zXPrivate attributes must not use dunder names; use a single underscore prefix instead of zJPrivate attributes must not use valid field names; use sunder names, e.g. Ú_z instead of Zmy_fieldz>Fields must not use names with leading underscores; e.g., use )rå   zField zŒ defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, require a type annotation.zmodel-field-overridden)Úcodez requires a type annotationzmodel-field-missing-annotationz)A non-annotated attribute was detected: `z = z3`. All model fields require a type annotation; if `z‘` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.NFT)Úis_argumentZis_class)ÚglobalnsÚlocalnsc                 3  s   | ]}t |ˆ ƒr|V  qd S r|   )rH   )r~   rB   ©r9   rQ   rR   r€     r�   z$inspect_namespace.<locals>.<genexpr>)$Úfieldsr9   r:   r-   Údefault_ignored_typesr¨   rÇ   rØ   rª   rH   ra   rT   rU   Ú
startswithrP   ÚaddÚ	NameErrorr%   Úlstripr&   r3   r   r   r¡   r>   r˜   Ú	_getframer2   r1   Ú	f_globalsÚf_localsr   Zis_annotatedr   r   Únext)rd   r·   rœ   ræ   rç   r:   r8   Zall_ignored_typesr¹   Úignored_namesÚvar_nameÚvalueZsuggested_nameZann_nameZann_typeÚframerê   Úmetadatarä   rQ   rï   rR   r›   �  sÐ    
ÿþýü

ÿÿ
ÿÿÿÿÿÿ



ýÿÿüÿþýúùø


ý

r›   ry   )rº   rc   rC   c                 C  s<   t |dƒ}t| ƒ}|d tjhv s2t|dd ƒ|jkr8|| _d S )Nr•   Ú__code__)r"   Úmake_hash_funcr?   r•   r¡   rÿ   )rº   rc   Zbase_hash_funcZnew_hash_funcrQ   rQ   rR   r´     s    
 r´   )rº   rC   c                   s6   | j rtj| j  ¡ Ž ndd„ ‰ dddœ‡ fdd„}|S )Nc                 S  s   dS )Nr   rQ   )rê   rQ   rQ   rR   Ú<lambda>'  r�   z make_hash_func.<locals>.<lambda>r	   Úint)rM   rC   c                   s:   zt ˆ | jƒƒW S  ty4   t ˆ t| jƒƒƒ Y S 0 d S r|   )ÚhashrÀ   ÚKeyErrorr6   rÑ   ©ÚgetterrQ   rR   Ú	hash_func)  s    z!make_hash_func.<locals>.hash_func)rÆ   ÚoperatorÚ
itemgetterrÊ   )rº   r  rQ   r  rR   r   &  s    
r   r   r/   )rº   r�   rŽ   rC   c           	      C  sr   t | ƒ}t| |||d�\}}}|| _|| _| j |¡ |D ]2}| j |d¡}|dur:|jt	ur:t
| ||jƒ q:dS )züCollect and set `cls.__pydantic_fields__` and `cls.__class_vars__`.

    Args:
        cls: BaseModel or dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting model annotations.
    )Útypevars_mapN)r+   r$   rÆ   rÔ   rw   rÉ   rx   rµ   rå   r   Úsetattr)	rº   r�   rŽ   r
  rð   rÖ   r¸   rA   rü   rQ   rQ   rR   r¯   6  s    ÿr¯   )r“   Úcall_on_complete_hookr”   Úis_force_rebuildr_   r`   )rº   r�   rŽ   r“   r  r”   r  rC   c             
   C  sÌ  t | ƒ}| js�zt| |||d�\| _| _W nL tyv } z4t |¡}	t| d|	j	› d�ƒ |rb|	|‚W Y d}~n
d}~0 0 |s†| js†dS | js�J ‚t
|||ƒ}
z|
 | ¡}W n@ tyê } z(|rÀ‚ t| d|j	› d�ƒ W Y d}~dS d}~0 0 |j| jd�}z|
 |¡}W n t�y&   t| ƒ Y dS 0 dd„ | jj ¡ D ƒ| _t| ƒ || _t|| |�p^| j| j|�rldnd	||j| d
�| _t||| d
�| _tdtt| j | j|j!|j"d�ƒ| _#d| _$|�rÈ|  %¡  dS )aþ  Finish building a model class.

    This logic must be called after class has been created since validation functions must be bound
    and `get_type_hints` requires a class object.

    Args:
        cls: BaseModel or dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: The namespace resolver instance to use during schema building.
        raise_errors: Whether to raise errors.
        call_on_complete_hook: Whether to call the `__pydantic_on_complete__` hook.
        create_model_module: The module of the class to be created, if created by `create_model`.
        is_force_rebuild: Whether the model is being force-rebuilt (if True, pre-built serializers and
                          validators are not used, to avoid stale references).

    Returns:
        `True` if the model is successfully completed, else `False`.

    Raises:
        PydanticUndefinedAnnotation: If PydanticUndefinedAnnotation occurs in __get_pydantic_core_schema__
            and `raise_errors=True`.
    )r�   rŽ   r
  rD   NF)Útitlec                 S  s   i | ]\}}||j “qS rQ   r�   r‘   rQ   rQ   rR   r’   ¬  r�   z(complete_model_class.<locals>.<dictcomp>Zcreate_modelr;   )Z_use_prebuiltÚ__signature__)rY   rð   Úvalidate_by_nameÚextraT)&r+   r×   r'   rÆ   rÔ   rô   r   Zfrom_name_errorr.   r½   r(   Zgenerate_schemaÚcore_configrS   Zclean_schemar)   r¤   r°   rª   r±   Úset_deprecated_descriptorsZ__pydantic_core_schema__r   rT   rU   Zplugin_settingsZ__pydantic_validator__r   Z__pydantic_serializer__r5   r   r0   r¢   r  r  r  r©   Z__pydantic_on_complete__)rº   r�   rŽ   r“   r  r”   r  r
  ÚeÚexcZ
gen_schemaZschemar  rQ   rQ   rR   r²   X  s~     ü


ý
ø
ûþr²   c                 C  sœ   | j  ¡ D ]6\}}|j }dur
t|ƒ}| | |¡ t| ||ƒ q
| j ¡ D ]J\}}|j }durLtt|j	ƒdƒsLt||j	ƒ}| | |¡ t| ||ƒ qLdS )z8Set data descriptors on the class for deprecated fields.NZ__deprecated__)
rÆ   rª   Zdeprecation_messageÚ_DeprecatedFieldDescriptorr«   r  r±   Úhasattrr#   Úwrapped_property)rº   ÚfieldrÓ   ÚmsgÚdescZcomputed_field_inforQ   rQ   rR   r  Ô  s    ÿýr  c                   @  sf   e Zd ZU dZded< dddddœdd	„Zd
dddœdd„Zdddddœdd„Zddddœdd„ZdS )r  aW  Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.

    Attributes:
        msg: The deprecation message to be emitted.
        wrapped_property: The property instance if the deprecated field is a computed field, or `None`.
        field_name: The name of the field being deprecated.
    r>   Ú
field_nameNzproperty | Noner@   )r  r  rC   c                 C  s   || _ || _d S r|   )r  r  )rM   r  r  rQ   rQ   rR   r¢   ò  s    z#_DeprecatedFieldDescriptor.__init__ry   )rº   r½   rC   c                 C  s
   || _ d S r|   )r  )rM   rº   r½   rQ   rQ   rR   r«   ö  s    z'_DeprecatedFieldDescriptor.__set_name__zBaseModel | Noneztype[BaseModel] | Noner	   )r¾   Úobj_typerC   c                 C  s`   |d u r*| j d ur | j  d |¡S t| jƒ‚tj| jtdd� | j d urT| j  ||¡S |j| j S )Nr   rE   )	r  Ú__get__rÁ   r  rI   rJ   r  ÚDeprecationWarningrÀ   )rM   r¾   r  rQ   rQ   rR   r  ù  s    


z"_DeprecatedFieldDescriptor.__get__r   )r¾   rü   rC   c                 C  s   t | jƒ‚d S r|   )rÁ   r  )rM   r¾   rü   rQ   rQ   rR   Ú__set__  s    z"_DeprecatedFieldDescriptor.__set__)N)N)	rS   rT   rU   rV   rk   r¢   r«   r  r   rQ   rQ   rQ   rR   r  ç  s   
r  c                   @  s:   e Zd ZdZddœdd„Zddœdd„Zd	dœd
d„ZdS )Ú_PydanticWeakRefaë  Wrapper for `weakref.ref` that enables `pickle` serialization.

    Cloudpickle fails to serialize weakref.ref objects due to an arcane error related to
    to abstract base classes (`abc.ABC`). This class works around the issue by wrapping
    `weakref.ref` instead of subclassing it.

    See https://github.com/pydantic/pydantic/issues/6763 for context.

    Semantics:
        - If not pickled, behaves the same as a `weakref.ref`.
        - If pickled along with the referenced object, the same `weakref.ref` behavior
          will be maintained between them after unpickling.
        - If pickled without the referenced object, after unpickling the underlying
          reference will be cleared (`__call__` will always return `None`).
    r	   )r¾   c                 C  s    |d u rd | _ nt |¡| _ d S r|   )Ú_wrÚweakrefÚref)rM   r¾   rQ   rQ   rR   r¢     s    z_PydanticWeakRef.__init__rÐ   c                 C  s   | j d u rd S |   ¡ S d S r|   )r"  rÑ   rQ   rQ   rR   Ú__call__%  s    
z_PydanticWeakRef.__call__z4tuple[Callable, tuple[weakref.ReferenceType | None]]c                 C  s   t | ƒ ffS r|   )r!  rÑ   rQ   rQ   rR   Ú
__reduce__+  s    z_PydanticWeakRef.__reduce__N)rS   rT   rU   rV   r¢   r%  r&  rQ   rQ   rQ   rR   r!    s   r!  zdict[str, Any] | None)ÚdrC   c              	   C  sR   | du rdS i }|   ¡ D ]4\}}zt|ƒ}W n tyB   |}Y n0 |||< q|S )aX  Takes an input dictionary, and produces a new value that (invertibly) replaces the values with weakrefs.

    We can't just use a WeakValueDictionary because many types (including int, str, etc.) can't be stored as values
    in a WeakValueDictionary.

    The `unpack_lenient_weakvaluedict` function can be used to reverse this operation.
    N)rª   r!  r¨   )r'  ÚresultrA   rB   ÚproxyrQ   rQ   rR   r¬   /  s    

r¬   c                 C  sP   | du rdS i }|   ¡ D ]2\}}t|tƒrB|ƒ }|durJ|||< q|||< q|S )zAInverts the transform performed by `build_lenient_weakvaluedict`.N)rª   rH   r!  )r'  r(  rA   rB   rQ   rQ   rR   r®   C  s    


r®   rÐ   c                  C  s<   ddl m}  ttttt| tg}tj	dkr4| 
tj¡ t|ƒS )Nr   )ÚComputedFieldInfo)ri   é   )rð   r*  r   rà   rÜ   rß   r!   r   r˜   r™   ÚappendÚtypingr¦   )r*  rœ   rQ   rQ   rR   rñ   S  s    ù

rñ   )mrV   Ú
__future__r   Z_annotationsr  r˜   r-  rI   r#  Úabcr   rè   r   r   r   Útypesr   r   r	   r
   r   r   r   r   r   Zpydantic_corer   r   Ztyping_extensionsr   r   r   r   r   Ztyping_inspectionr   Úerrorsr   r   Zplugin._schema_validatorr   r   r   Ú_configr   Z_decoratorsr    r!   r"   r#   Ú_fieldsr$   r%   r&   r'   Z_generate_schemar(   r)   Z	_genericsr*   r+   Z_import_utilsr,   r-   Z_mock_val_serr.   Z_namespace_utilsr/   Ú
_signaturer0   Z_typing_extrar1   r2   r3   r4   Ú_utilsr5   r6   rð   r7   ZPydanticModelFieldr8   r9   r:   ZPydanticModelPrivateAttrÚmainr;   r<   r?   Ú__setattr__rã   r­   r=   rZ   r[   r\   rs   r�   r›   r´   r   r¯   r²   r  r  r!  r¬   r®   rñ   rQ   rQ   rQ   rR   Ú<module>   s~   (þ   
'ø |%#