o
    Ú­j˜  ã                   @  sè  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#œdgd(d)„Z]ed*ƒZ^ed+ePeTe]fd,�G d-d.„ d.e
ƒƒZ_dhd3d4„Z`did:d;„ZadjdBdC„ZbdkdFdG„ZcdldHdI„ZddmdNdO„Zed+d+dd"dPœdndWdX„ZfdodYdZ„ZgG d[d\„ d\ƒZhG d]d^„ d^ƒZidpdadb„Zjdpdcdd„Zkedqdedf„ƒZldS )rz"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
‡ fdd	„Z‡  ZS )Ú_ModelNamespaceDictz{A dictionary subclass that intercepts attribute setting on model classes and
    warns about overriding of decorators.
    ÚkÚstrÚvÚobjectÚreturnÚNonec                   sP   |   |d ¡}|r!||ur!t|tƒr!tjd|› d|jj› d�dd� tƒ  ||¡S )Nú`z"` overrides an existing Pydantic `z` decoratorr   ©Ú
stacklevel)	ÚgetÚ
isinstancer!   ÚwarningsÚwarnÚdecorator_infoÚdecorator_reprÚsuperÚ__setitem__)Úselfr>   r@   Úexisting©Ú	__class__© úc/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.pyrN   9   s   þz_ModelNamespaceDict.__setitem__)r>   r?   r@   rA   rB   rC   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rN   Ú__classcell__rS   rS   rQ   rT   r=   4   s    r=   F©Úinitr[   úLiteral[False]rB   r	   c                 C  ó   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.
    NrS   rZ   rS   rS   rT   ÚNoInitFieldD   ó    r^   Ú_TT)Úkw_only_defaultÚfield_specifiersc                      s    e Zd Z			d-d.‡ fdd„Zesd/dd„Zed0dd„ƒZd1‡ fdd„Ze	j
Z
e	jZed2d!d"„ƒZeed#dd$�d3d&d'„ƒƒZed4d(d)„ƒZd5‡ fd+d,„Z‡  ZS )6ÚModelMetaclassNTÚcls_namer?   Úbasesútuple[type[Any], ...]Ú	namespaceúdict[str, Any]Ú__pydantic_generic_metadata__úPydanticGenericMetadata | NoneÚ#__pydantic_reset_parent_namespace__ÚboolÚ_create_model_moduleú
str | NoneÚkwargsr	   rB   Útypec           "        s  |�ræt jdkr,d|v r|d }n!ddlm}	m}
m} ||ƒ }r)|
||	jd�}n	i }n| di ¡}|  |¡\}}}t	 
||||¡}|j|d< t|||j||ƒ}|sT|rqt||ƒ‰ ˆ durmtˆ ƒ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æˆ‰ˆ�rnˆ�rnt&‡fdd „ˆD ƒƒ�sndd!l'm(} t)‡fd"d „ˆD ƒƒ}|ˆv �r2|ˆv�r2d# *d$d%„ |D ƒ¡}|j+› d&|› d'|j+› d(|› d)�}t,|ƒ‚ˆ| }d# *d*d%„ |D ƒ¡}d+|› d,�}d-|› d.�}t|v�rjd# *d/d%„ |D ƒ|g ¡}|d0|j+› d1|› d2�7 }t,|ƒ‚ddˆd3œ|_%d|_-| .¡ D ]\}}| /||¡ �q||�r‘t0t1ƒ ƒ|_2t|d4dƒ}t3|t4ƒ�r¡t5|ƒ}t6|d5�} t7||| d6� d7d8„ |j#j8 .¡ D ƒ|_9|j:�rÂt;|ƒ n	t<||| d|d9� |j=�rÙd:|v�rÙt>||ƒ t||ƒj?di |¤Ž |S d;D ]	}!| @|!d¡ �qè| di ¡ A¡  tƒ j| |||fi |¤Ž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_configNrO   r;   Úcontextr	   rB   rC   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)rO   ry   )Úoriginal_model_post_initrS   rT   Ú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   Ú__pydantic_base_init__FT)Úreplace_wrapped_methodsri   Ú
parametersrS   Ú__parameters__c                 3  s   � | ]}|ˆ v V  qd S ©NrS   ©Ú.0Úx)rƒ   rS   rT   Ú	<genexpr>¹   s   € z)ModelMetaclass.__new__.<locals>.<genexpr>)ÚRootModelRootTypec                 3  s   � | ]	}|ˆ vr|V  qd S r…   rS   r†   )Úparent_parametersrS   rT   r‰   ¼   s   € z, c                 S  ó   g | ]}|j ‘qS rS   ©rU   r†   rS   rS   rT   Ú
<listcomp>Å   ó    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 rS   )r?   r†   rS   rS   rT   rŽ   Í   s    ztyping.Generic[ú]zJAll parameters must be present on typing.Generic; you should inherit from Ú.c                 S  rŒ   rS   r�   r†   rS   rS   rT   rŽ   Ø   r�   z- Note: `typing.Generic` must go last: `class ú(z): ...`))ÚoriginÚargsrƒ   Ú__pydantic_parent_namespace__)Úparent_namespace)Úconfig_wrapperÚns_resolverc                 S  ó   i | ]\}}||j “qS rS   ©Úinfo©r‡   r>   r@   rS   rS   rT   Ú
<dictcomp>÷   s    ÿz*ModelMetaclass.__new__.<locals>.<dictcomp>)Úraise_errorsÚcreate_model_moduleÚ__hash__)Ú__pydantic_fields_set__Ú__pydantic_extra__Ú__pydantic_private__©rO   r;   ry   r	   rB   rC   )BÚsysÚversion_infoÚannotationlibrt   ru   rv   Ú
FORWARDREFrG   Ú_collect_bases_datar   Ú	for_modelÚconfig_dictÚinspect_namespaceÚignored_typesÚget_model_post_initr   rz   r   rM   Ú__new__r,   Ú__mro__r   ÚindexrI   rJ   r   ÚgetattrÚ__init__Ú__pydantic_custom_init__r}   Ú__pydantic_post_init__Ú__pydantic_setattr_handlers__r    ÚbuildÚ__pydantic_decorators__Úupdate_from_configri   ÚallÚ
root_modelrŠ   ÚtupleÚjoinrU   Ú	TypeErrorÚ__pydantic_complete__ÚitemsÚ__set_name__Úbuild_lenient_weakvaluedictr4   r•   rH   ÚdictÚunpack_lenient_weakvaluedictr/   Úset_model_fieldsÚcomputed_fieldsÚ__pydantic_computed_fields__Údefer_buildr.   Úcomplete_model_classÚfrozenÚset_default_hash_funcÚ__pydantic_init_subclass__ÚpopÚclear)"Úmcsrd   re   rg   ri   rk   rm   ro   Úraw_annotationsrt   ru   rv   ÚannotateÚbase_field_namesÚ
class_varsÚbase_private_attributesr—   Úprivate_attributesr|   ÚclsÚ
BaseModel_ÚmrorŠ   Úmissing_parametersÚparameters_strÚerror_messageÚcombined_parametersÚgeneric_type_labelÚ	bases_strÚnameÚobjr–   r˜   Úinstance_slotrQ   )r{   rƒ   r‹   rT   r¯   T   sØ   


ÿ

 ÿûÿ$ÿþþÿðÿÿ
ÿý

ÿ
û
þzModelMetaclass.__new__Úitemc                 C  s(   | j  d¡}|r||v r|| S t|ƒ‚)zNThis is necessary to keep attribute access working for class attribute access.r   )Ú__dict__rG   ÚAttributeError)rO   râ   rÕ   rS   rS   rT   Ú__getattr__  s   zModelMetaclass.__getattr__r”   údict[str, object]c                 O  s   t ƒ S r…   )r=   )rÖ   r”   ro   rS   rS   rT   Ú__prepare__$  s   zModelMetaclass.__prepare__Úsubclassútype[_T]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   rW   rM   Úregister)rO   rè   rQ   rS   rT   rê   ,  s
   ýzModelMetaclass.registerú6tuple[set[str], set[str], dict[str, ModelPrivateAttr]]c                 C  sj   t ƒ }tƒ }tƒ }i }| D ]"}t||ƒr/||ur/| t|di ƒ ¡ ¡ | |j¡ | |j¡ q|||fS )NÚ__pydantic_fields__)r,   ÚsetÚ
issubclassÚupdater²   Úkeysr~   r   )re   r;   Úfield_namesrÓ   rÕ   ÚbaserS   rS   rT   r©   7  s   €
z"ModelMetaclass._collect_bases_dataúXThe `__fields__` attribute is deprecated, use the `model_fields` class property instead.)Úcategoryúdict[str, FieldInfo]c                 C  s   t jdtdd� t| di ƒS )Nró   r   rE   rì   )rI   rJ   r   r²   ©rO   rS   rS   rT   Ú
__fields__F  s   ýzModelMetaclass.__fields__c                 C  sT   d| j vrdS td| jƒ}td| jƒ}|dur|j}nd}tdd„ | ¡ D ƒƒo)|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…   )Ú	_complete)r‡   Ú
field_inforS   rS   rT   r‰   c  s   € z>ModelMetaclass.__pydantic_fields_complete__.<locals>.<genexpr>)rã   r   rì   Ú__pydantic_extra_info__Úcompleterº   Úvalues)rO   Úfield_infosÚpydantic_extra_infoÚextra_completerS   rS   rT   Ú__pydantic_fields_complete__R  s   
z+ModelMetaclass.__pydantic_fields_complete__ú	list[str]c                   s$   t tƒ  ¡ ƒ}d|v r| d¡ |S )Nr÷   )ÚlistrM   Ú__dir__Úremove)rO   Ú
attributesrQ   rS   rT   r  e  s   
zModelMetaclass.__dir__)NTN)rd   r?   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   r	   rB   rp   )râ   r?   rB   r	   )r”   r	   ro   r	   rB   ræ   )rè   ré   rB   ré   )re   rf   rB   rë   )rB   rõ   )rB   rl   )rB   r  )rU   rV   rW   r¯   r   rå   Úclassmethodrç   rê   rp   Ú__instancecheck__Ú__subclasscheck__Ústaticmethodr©   Úpropertyr   r÷   r   r  rY   rS   rS   rQ   rT   rc   R   s.    ù G
ÿrc   rO   r;   ry   rC   c                C  sx   t | ddƒdu r:i }| j ¡ D ]"\}}|jr#|jdi | j¥|¥d�}n|jdd�}|tur1|||< qt| d|ƒ dS 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_factoryÚvalidated_data)r  )r²   r   rÀ   Ú$default_factory_takes_validated_dataÚget_defaultrã   r   Úobject_setattr)rO   ry   Úpydantic_privaterß   Úprivate_attrÚdefaultrS   rS   rT   rz   l  s   	ÿ€ôrz   rg   rh   re   rf   úCallable[..., Any] | Nonec                 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.r}   N)r,   r"   r}   )rg   re   r;   r}   rS   rS   rT   r®   „  s   

ÿr®   rÐ   r­   Úbase_class_varsúset[str]Úbase_class_fieldsúdict[str, ModelPrivateAttr]c              
     s
  ddl m‰ m} tƒ }|tƒ  }i }d|v sd| v rtdƒ‚tƒ }	t|  ¡ ƒD ]Ø\}
}|
dks3|
dkr4q't	|t
ƒrP|j| d krPd| v rP|j | d › d	�¡rPq't	||ƒs[|jjd
kra|	 |
¡ q't	|ˆ ƒrŒ|
 d¡rstd|
›d	�ƒ‚t|
ƒr„tdd|
 ›d|
›d	�ƒ‚|||
< | |
= q't	||ƒr§t|
ƒs§|
 d¡p›d}td|›d|
›d	�ƒ‚|
 d¡r­q't|
ƒrÉ|
|vs»t||
 ƒsÈtˆ ||d�ƒ||
< | |
= q'|
|v rÎq'|
|vrÿ|
|v ràtd|
›d�dd�‚t	||ƒrïtd|
›d�dd�‚td|
› d|›d|
› d�dd�‚q'| ¡ D ]~\}}t|ƒ�r�||v�r�||	v�r�t|ƒ�s�||v�r�t|ddƒd
k�r�t	|tƒ�rWt d¡}|du�rWztt|ddd �|j|jd!�}W n ttf�yV   Y nw t  t!|ƒ¡�r|t"|ƒ^}}t#‡ fd"d#„|D ƒdƒ}|du�r||||< �q|ƒ ||< �q|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:   Ú__root__zUTo define root models, use `pydantic.RootModel` rather than a field called '__root__'rx   r¢   rV   rW   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 Ú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_argumentÚis_class)ÚglobalnsÚlocalnsc                 3  s   � | ]
}t |ˆ ƒr|V  qd S r…   )rH   )r‡   r@   ©r9   rS   rT   r‰     s   € z$inspect_namespace.<locals>.<genexpr>)$Úfieldsr9   r:   r-   Údefault_ignored_typesr¾   rí   r  rÀ   rH   rp   rV   rW   Ú
startswithrR   ÚaddÚ	NameErrorr%   Úlstripr&   r3   r   r   r²   r?   r¥   Ú	_getframer2   r1   Ú	f_globalsÚf_localsr   Úis_annotatedr   r   Únext)rg   rÐ   r­   r  r  r:   r8   Úall_ignored_typesrÕ   Úignored_namesÚvar_nameÚvalueÚsuggested_nameÚann_nameÚann_typeÚframer  Úmetadatar  rS   r"  rT   r¬   �  sÌ   
ÿÿ


ÿÿÿÿÿÿÿÿ
€
ý
ÿÿüôÿ

ý



ýÿ

€r¬   rÖ   r€   c                 C  s@   t |dƒ}t| ƒ}|d tjhv st|dd ƒ|jkr|| _d S d S )Nr    Ú__code__)r"   Úmake_hash_funcrA   r    r²   r7  )rÖ   re   Úbase_hash_funcÚnew_hash_funcrS   rS   rT   rË     s
   
 
ùrË   c                   s0   | j rtj| j  ¡ Ž ndd„ ‰ d	‡ fdd„}|S )
Nc                 S  r]   )Nr   rS   )r  rS   rS   rT   Ú<lambda>'  r_   z make_hash_func.<locals>.<lambda>rO   r	   rB   Úintc                   s6   zt ˆ | jƒƒW S  ty   t ˆ t| jƒƒƒ Y S w r…   )Úhashrã   ÚKeyErrorr6   rö   ©ÚgetterrS   rT   Ú	hash_func)  s
   ûz!make_hash_func.<locals>.hash_func)rO   r	   rB   r<  )rì   ÚoperatorÚ
itemgetterrð   )rÖ   rA  rS   r?  rT   r8  &  s   
r8  r—   r   r˜   r/   c           	      C  sr   t | ƒ}t| |||d�\}}}|| _|| _| j |¡ |D ]}| j |d¡}|dur6|jt	ur6t
| ||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ú   r~   rï   r   rÍ   r  r   Úsetattr)	rÖ   r—   r˜   rD  r#  rþ   rÓ   r>   r1  rS   rS   rT   rÅ   6  s   ÿ€örÅ   )rž   Úcall_on_complete_hookrŸ   Úis_force_rebuildrž   rl   rF  rŸ   rn   rG  c             
   C  sÄ  t | ƒ}| jsHzt| |||d�\| _| _W n& ty; } zt |¡}	t| d|	j	› d�ƒ |r1|	|‚W Y d}~nd}~ww |sC| jsCdS | jsHJ ‚t
|||ƒ}
z|
 | ¡}W n  tyu } z|r`‚ t| d|j	› d�ƒ W Y d}~dS d}~ww |j| jd�}z|
 |¡}W n ty’   t| ƒ Y dS w dd„ | jj ¡ D ƒ| _t| ƒ || _t|| |p­| j| j|r³d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˜   rD  rD   NF)Útitlec                 S  r™   rS   rš   rœ   rS   rS   rT   r�   ¬  s    z(complete_model_class.<locals>.<dictcomp>Úcreate_modelr;   )Ú_use_prebuiltÚ__signature__)r[   r#  Úvalidate_by_nameÚextraT)&r+   r   r'   rì   rú   r'  r   Úfrom_name_errorr.   rß   r(   Úgenerate_schemaÚcore_configrU   Úclean_schemar)   r¸   rÆ   rÀ   rÇ   Úset_deprecated_descriptorsÚ__pydantic_core_schema__r   rV   rW   Úplugin_settingsÚ__pydantic_validator__r   Ú__pydantic_serializer__r5   r   r0   r³   rL  rM  rK  r¿   Ú__pydantic_on_complete__)rÖ   r—   r˜   rž   rF  rŸ   rG  rD  ÚeÚexcÚ
gen_schemaÚschemarP  rS   rS   rT   rÉ   X  sŠ    ü
ÿ€ý

ý€üþ
ø
ûþrÉ   c                 C  sœ   | j  ¡ D ]\}}|j }dur t|ƒ}| | |¡ t| ||ƒ q| j ¡ D ]%\}}|j }durKtt|j	ƒdƒsKt||j	ƒ}| | |¡ t| ||ƒ q&dS )z8Set data descriptors on the class for deprecated fields.NÚ__deprecated__)
rì   rÀ   Údeprecation_messageÚ_DeprecatedFieldDescriptorrÁ   rE  rÇ   Úhasattrr#   Úwrapped_property)rÖ   Úfieldrù   ÚmsgÚdescÚcomputed_field_inforS   rS   rT   rR  Ô  s   €þ€ørR  c                   @  sF   e Zd ZU dZded< ddd
d„Zddd„Zdddd„Z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_nameNrb  r`  úproperty | NonerB   rC   c                 C  s   || _ || _d S r…   )rb  r`  )rO   rb  r`  rS   rS   rT   r³   ò  s   
z#_DeprecatedFieldDescriptor.__init__rÖ   r€   rß   c                 C  s
   || _ d S r…   )re  )rO   rÖ   rß   rS   rS   rT   rÁ   ö  ó   
z'_DeprecatedFieldDescriptor.__set_name__rà   úBaseModel | NoneÚobj_typeútype[BaseModel] | Noner	   c                 C  s`   |d u r| j d ur| j  d |¡S t| jƒ‚tj| jtdd� | j d ur*| j  ||¡S |j| j S )Nr   rE   )	r`  Ú__get__rä   re  rI   rJ   rb  ÚDeprecationWarningrã   )rO   rà   ri  rS   rS   rT   rk  ù  s   


z"_DeprecatedFieldDescriptor.__get__r1  r   c                 C  s
   t | jƒ‚r…   )rä   re  )rO   rà   r1  rS   rS   rT   Ú__set__  rg  z"_DeprecatedFieldDescriptor.__set__r…   )rb  r?   r`  rf  rB   rC   )rÖ   r€   rß   r?   rB   rC   )rà   rh  ri  rj  rB   r	   )rà   r	   r1  r	   rB   r   )	rU   rV   rW   rX   rs   r³   rÁ   rk  rm  rS   rS   rS   rT   r^  ç  s   
 
r^  c                   @  s.   e Zd ZdZddd„Zddd„Z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 | _ d S t |¡| _ d S r…   )Ú_wrÚweakrefÚref)rO   rà   rS   rS   rT   r³     s   
z_PydanticWeakRef.__init__rB   c                 C  s   | j d u rd S |   ¡ S r…   )ro  rö   rS   rS   rT   Ú__call__%  s   
z_PydanticWeakRef.__call__ú4tuple[Callable, tuple[weakref.ReferenceType | None]]c                 C  s   t | ƒ ffS r…   )rn  rö   rS   rS   rT   Ú
__reduce__+  s   z_PydanticWeakRef.__reduce__N)rà   r	   )rB   r	   )rB   rs  )rU   rV   rW   rX   r³   rr  rt  rS   rS   rS   rT   rn    s
    

rn  Údúdict[str, Any] | Nonec              	   C  sR   | du rdS i }|   ¡ D ]\}}zt|ƒ}W n ty!   |}Y nw |||< 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À   rn  r¾   )ru  Úresultr>   r@   ÚproxyrS   rS   rT   rÂ   /  s   ÿ
rÂ   c                 C  sP   | du rdS i }|   ¡ D ]\}}t|tƒr!|ƒ }|dur |||< q|||< q|S )zAInverts the transform performed by `build_lenient_weakvaluedict`.N)rÀ   rH   rn  )ru  rw  r>   r@   rS   rS   rT   rÄ   C  s   
€
rÄ   c                  C  s<   ddl m}  ttttt| tg}tj	dkr| 
tj¡ t|ƒS )Nr   )ÚComputedFieldInfo)rq   é   )r#  ry  r   r
  r  r	  r!   r   r¥   r¦   ÚappendÚtypingr¼   )ry  r­   rS   rS   rT   r$  S  s   ù

r$  )r[   r\   rB   r	   r¤   )rg   rh   re   rf   rB   r  )rg   rh   rÐ   rh   r­   rf   r  r  r  r  rB   r  )rÖ   r€   re   rf   rB   rC   )rÖ   r€   rB   r	   )rÖ   r€   r—   r   r˜   r/   rB   rC   )rÖ   r€   r—   r   r˜   r/   rž   rl   rF  rl   rŸ   rn   rG  rl   rB   rl   )rÖ   r€   rB   rC   )ru  rv  rB   rv  )rB   rf   )mrX   Ú
__future__r   Ú_annotationsrB  r¥   r|  rI   rp  Úabcr   r  r   r   r   Útypesr   r   r	   r
   r   r   r   r   r   Úpydantic_corer   r   Útyping_extensionsr   r   r   r   r   Útyping_inspectionr   Úerrorsr   r   Úplugin._schema_validatorr   r   r   Ú_configr   Ú_decoratorsr    r!   r"   r#   Ú_fieldsr$   r%   r&   r'   Ú_generate_schemar(   r)   Ú	_genericsr*   r+   Ú_import_utilsr,   r-   Ú_mock_val_serr.   Ú_namespace_utilsr/   Ú
_signaturer0   Ú_typing_extrar1   r2   r3   r4   Ú_utilsr5   r6   r#  r7   ÚPydanticModelFieldr8   r9   r:   ÚPydanticModelPrivateAttrÚmainr;   r<   rA   Ú__setattr__r  rÃ   r=   r^   r`   rc   rz   r®   r¬   rË   r8  rÅ   rÉ   rR  r^  rn  rÂ   rÄ   r$  rS   rS   rS   rT   Ú<module>   s€    (þ  


 



'ø
|%
#
