
    g                    n   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	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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 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*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZF ddlGmHZHmIZI ej                  rd
dlKmLZLmMZMmNZN d
dlKmOZP d
dlKmQZR d
dlSmTZT ne%ZU eV       ZP eV       ZReVj                  ZX G d d eY      ZZd!d"	 	 	 d9d#Z[ ed$ePeRe[f%       G d& d'e             Z\d:d(Z]d;d)Z^	 	 	 	 	 	 	 	 	 	 d<d*Z_d=d+Z`d>d,Za	 	 	 	 	 	 	 	 	 	 d?d-Zbd$ddd.	 	 	 	 	 	 	 	 	 	 	 	 	 d@d/ZcdAd0Zd G d1 d2      Ze G d3 d4      ZfdBd5ZgdBd6Zh ed7      dCd8       Ziy)Dz"Private logic for creating models.    )annotationsN)ABCMeta)	lru_cachepartial)FunctionType)AnyCallableGenericLiteralNoReturncast)PydanticUndefinedSchemaSerializer)TypeAliasTypedataclass_transform
deprecatedget_args   )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)GenerateSchema)PydanticGenericMetadataget_model_typevars_map)import_cached_base_modelimport_cached_field_info)set_model_mocks)
NsResolver)CallbackGetCoreSchemaHandler)generate_pydantic_signature)_make_forward_refeval_type_backportis_annotatedis_classvar_annotationparent_frame_namespace)LazyClassAttributeSafeGetItemProxy)ComputedFieldInfo	FieldInfoModelPrivateAttr)Field)PrivateAttr)	BaseModelc                  $     e Zd ZdZd fdZ xZS )_ModelNamespaceDictz{A dictionary subclass that intercepts attribute setting on model classes and
    warns about overriding of decorators.
    c                    | j                  |d       }|rD||ur@t        |t              r0t        j                  d| d|j
                  j                   d       t        | !  ||      S )N`z"` overrides an existing Pydantic `z` decorator)	get
isinstancer   warningswarndecorator_infodecorator_reprsuper__setitem__)selfkvexisting	__class__s       [/var/www/openai/venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.pyrD   z_ModelNamespaceDict.__setitem__=   sc    D))jCZ.[MMAaS B8CZCZCiCiBjjuvww"1a((    )rF   strrG   objectreturnNone)__name__
__module____qualname____doc__rD   __classcell__rI   s   @rJ   r:   r:   8   s    ) )rK   r:   Finitc                     y)zOnly 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.
    N rV   s    rJ   NoInitFieldrZ   E   s    rK   T)kw_only_defaultfield_specifiersc                       e Zd Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZej
                  sddZedd       Zd fdZ	e
dd       Ze edd      dd	              Zedd
       Zedd       Zd fdZ xZS )ModelMetaclassNc           	        !" |r| j                  |      \  }}	}
t        j                  |||      }|j                  |d<   t	        ||j
                  |	|      }|s|
r#t        ||        d' fd}||d<   n	t        |d<   |	|d<   i |
||d<   t        dt        #| (  | |||fi |      }t               }|j                  }t        |v rG|j                  t              |j                  |      k  r t        j                   t#        d      d	
       t%        |j&                  dd       |_        |j*                  |j*                  u rdnd|_        t/        j0                  |      |_        |r	||_        n[t%        |di       j7                  dd      "t%        |dd      xs "!!r"rt9        !fd"D              sd	dlm} t?        "fd!D              }|"v rZ|!vrVdjA                  |D cg c]  }|jB                   c}      }|jB                   d| d|jB                   d| d}tG        |      "|z   }djA                  |D cg c]  }tE        |       c}      }d| d}d| d}t        |vrCdjA                  |D cg c]  }|jB                   c}|gz         }|d|jB                   d| dz  }tG        |      dd!d |_        d|_$        |jK                         D ]  \  }}|jM                  ||        |rtO        tQ                     |_)        t%        |d!d      }tU        |tV              rtY        |      }t[        |"      }t]        ||||       |j^                  rd#|vrta        ||       tc        |||d||$       |j2                  jd                  jK                         D ci c]  \  }}||jf                   c}}|_4        tk        |       t        ||  di | |S d%D ]  }|jo                  |d        |j7                  d&i       jq                          t        #| (  | |||fi |S c c}w c c}w c c}w c c}}w )(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.
        model_configNc               0    t        | |        | |       y)zWe need to both initialize private attributes and call the user-defined model_post_init
                        method.
                        N)init_private_attributes)rE   contextoriginal_model_post_inits     rJ   wrapped_model_post_initz7ModelMetaclass.__new__.<locals>.wrapped_model_post_inity   s     0g>0w?rK   model_post_init__class_vars____private_attributes__type[BaseModel]zClasses should inherit from `BaseModel` before generic classes (e.g. `typing.Generic[T]`) for pydantic generics to work properly.r   
stacklevel__pydantic_base_init__F__pydantic_generic_metadata__
parametersrY   __parameters__c              3  &   K   | ]  }|v  
 y wNrY   ).0xrn   s     rJ   	<genexpr>z)ModelMetaclass.__new__.<locals>.<genexpr>   s     ?kYjTUZYjs   )RootModelRootTypec              3  ,   K   | ]  }|vs|  y wrq   rY   )rr   rs   parent_parameterss     rJ   rt   z)ModelMetaclass.__new__.<locals>.<genexpr>   s     .c*QQbHbq*s   	z, 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	]): ...`.ztyping.Generic[]zJAll parameters must be present on typing.Generic; you should inherit from .z- Note: `typing.Generic` must go last: `class (z): ...`))originargsrn   __pydantic_parent_namespace__)parent_namespace__hash__raise_errorsns_resolvercreate_model_module)__pydantic_fields_set____pydantic_extra____pydantic_private____annotations__rE   r8   rc   r   rN   rO   )9_collect_bases_datar   	for_modelconfig_dictinspect_namespaceignored_typesget_model_post_initrb   r   rC   __new__r&   __mro__r
   indexr?   r@   r   getattr__init____pydantic_custom_init__rf   __pydantic_post_init__r   build__pydantic_decorators__rm   r=   all
root_modelru   tuplejoinrP   rL   	TypeError__pydantic_complete__items__set_name__build_lenient_weakvaluedictr0   r}   r>   dictunpack_lenient_weakvaluedictr)   set_model_fieldsfrozenset_default_hash_funccomplete_model_classcomputed_fieldsinfo__pydantic_computed_fields__set_deprecated_descriptors__pydantic_init_subclass__popclear)$mcscls_namebases	namespacerm   #__pydantic_reset_parent_namespace___create_model_modulekwargsbase_field_names
class_varsbase_private_attributesconfig_wrapperprivate_attributesre   cls
BaseModel_mroru   missing_parametersrs   parameters_strerror_messagecombined_parametersgeneric_type_label	bases_strnameobjr~   r   rF   rG   instance_slotrd   rn   rw   rI   s$                                   @@@rJ   r   zModelMetaclass.__new__Q   s   6 DGD[D[\aDbAj*A*44UIvNN(6(B(BIn%!2>77EU" "%<+>y%+P(+7@ 4KI/03JI/0*4I&'2c5L2cPb2cI./(%'/#xPY*d]c*deC13J++C#~#))G"4syy7L"L1B  ! 07s||E]_d/e+eC(++z/I/IIO` & +9*>*>s*CC' -4Q1$+C1PRT$U$Y$YZfhj$k!$S*:DAVEV
"3C?kYj?k<k>)..c*.c)c&(,==BS[eBe *.HZ3[HZ1AJJHZ3[)\"||n,-. /WWZWcWcVddop~o  @IJ &, $M22! /@BT.T+)-DW3XDWqCFDW3X)Y/>~>Na-P*88J7K1N & #%/
 )-		u2Mu!1::u2MQcPd2d(eI)"OPSP\P\~]^_h^iiq rM $M22 #",51 ).C% 0557	c  d+ 8 34OPfPh4i16=cCbdh6i*D1#?@P#Q $6FGKS%E$$9)D%c51 "'$8 '*&A&A&Q&Q&W&W&Y0&Yda166	&Y0C, 's+
 #s6@@J "i! "i
 MM+R06687?3%MfMMc 4\ 4Y 3NV0s   /P9
P>Q1Qc                d    | j                   j                  d      }|r	||v r||   S t        |      )zNThis is necessary to keep attribute access working for class attribute access.rh   )__dict__r=   AttributeError)rE   itemr   s      rJ   __getattr__zModelMetaclass.__getattr__  s9    !%!2!23K!L!d.@&@)$// &&rK   c                    t               S rq   )r:   )r   r|   r   s      rJ   __prepare__zModelMetaclass.__prepare__
  s    "$$rK   c                >    t        |d      xr t        | 	  |      S )zsAvoid calling ABC _abc_subclasscheck unless we're pretty sure.

        See #3829 and python/cpython#92810
        __pydantic_validator__)hasattrrC   __instancecheck__)rE   instancerI   s     rJ   r   z ModelMetaclass.__instancecheck__  s#    
 x!9:buw?XYa?bbrK   c                >   t               }t               }t               }i }| D ]t  }t        ||      s||us|j                  t	        |di       j                                |j                  |j                         |j                  |j                         v |||fS )N__pydantic_fields__)r&   set
issubclassupdater   keysrg   rh   )r   r8   field_namesr   r   bases         rJ   r   z"ModelMetaclass._collect_bases_data  s    ,.	 #"u
:<D$	*t9/D""741F#K#P#P#RS!!$"5"56"))$*E*EF  J(:::rK   EThe `__fields__` attribute is deprecated, use `model_fields` instead.)categoryc                R    t        j                  dt        d       | j                  S )Nr   r   rj   )r?   r@   r   model_fieldsrE   s    rJ   
__fields__zModelMetaclass.__fields__$  s'     	S%	

    rK   c                    t        | di       S )zGet metadata about the fields defined on the model.

        Returns:
            A mapping of field names to [`FieldInfo`][pydantic.fields.FieldInfo] objects.
        r   r   r   s    rJ   r   zModelMetaclass.model_fields.  s     t2B77rK   c                    t        | di       S )zGet metadata about the computed fields defined on the model.

        Returns:
            A mapping of computed field names to [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.
        r   r   r   s    rJ   model_computed_fieldsz$ModelMetaclass.model_computed_fields7  s     t;R@@rK   c                `    t        t        | 	               }d|v r|j                  d       |S )Nr   )listrC   __dir__remove)rE   
attributesrI   s     rJ   r   zModelMetaclass.__dir__@  s0    %'/+,
:%l+rK   )NTN)r   rL   r   tuple[type[Any], ...]r   dict[str, Any]rm   zPydanticGenericMetadata | Noner   boolr   
str | Noner   r   rN   type)r   rL   rN   r   )r|   r   r   r   rN   zdict[str, object])r   r   rN   r   )r   r   rN   z6tuple[set[str], set[str], dict[str, ModelPrivateAttr]])rN   zdict[str, FieldInfo])rN   zdict[str, ComputedFieldInfo])rN   z	list[str])rP   rQ   rR   r   typingTYPE_CHECKINGr   classmethodr   r   staticmethodr   propertyr   r   r   r   r   rT   rU   s   @rJ   r^   r^   O   s    IM48+/mNmN %mN "	mN
 (FmN .2mN )mN mN 
mN^ 	' % %c ; ; Wbfg! h ! 8 8 A A rK   r^   c                   t        | dd      Pi }| j                  j                         D ]#  \  }}|j                         }|t        us|||<   % t        | d|       yy)a  This function is meant to behave like a BaseModel method to initialise 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   N)r   rh   r   get_defaultr   object_setattr)rE   rc   pydantic_privater   private_attrdefaults         rJ   rb   rb   G  sp     t+T2:"&"="="C"C"ED,"..0G//)0 & #F 	t35EF ;rK   c                b    d| v r| d   S t               }t        |d      }||j                  ur|S y)zaGet the `model_post_init` method from the namespace or the class bases, or `None` if not defined.rf   N)r&   r   rf   )r   r   r8   rf   s       rJ   r   r   Y  sD    I%*++(*I.u6GHOi777 8rK   c           
     V   ddl mm} t               }|t	               z   }i }| j                  di       }d|v sd| v rt        d      t               }	t        | j                               D ]  \  }
}|
dk(  s|
dk(  rt        |t              r5|j                  | d   k(  r#d	| v r|j                  j                  | d	         rWt        ||      s|j                  j                  d
k(  r|	j!                  |
       t        |      rI|
j                  d      rt#        d|
d      t%        |
      rt#        dd|
z   d|
d      |||
<   | |
= t        ||      r2t%        |
      s'|
j'                  d      xs d}t#        d|d|
d      |
j                  d      r4t)        |
      r/|
|vst+        ||
         rSt-         ||            ||
<   | |
= n|
|v rt|
|vsz|
|v rt/        d|
dd      t        ||      rt/        d|
dd      t/        d|
 d|d|
 dd       |j                         D ]  \  }}t)        |      s||vs||	vst+        |      r(||vs-t1        |dd      d
k7  s>t        |t2              rFt5        j6                  d      }|/	 t9        t;        |dd !      |j<                  |j>                  "      }tA        |      r*tC        |      ^}}tE        fd#|D        d      }||||<    |       ||<    |S # t"        t        f$ r Y Tw xY w)$a  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.
        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 contains 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   )r5   r7   r   __root__zUTo define root models, use `pydantic.RootModel` rather than a field called '__root__'r`   r   rQ   rR   	functools__zXPrivate attributes must not use dunder names; use a single underscore prefix instead of ry   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  <   K   | ]  }t        |      s|  y wrq   )r>   )rr   rG   r5   s     rJ   rt   z$inspect_namespace.<locals>.<genexpr>  s     $\1JqJZ<[Qs   )#fieldsr5   r7   r'   default_ignored_typesr=   r   r   r   r   r>   r   rQ   rR   
startswithrI   add	NameErrorr!   lstripr"   r/   r   r   r   rL   sys	_getframer-   r,   	f_globalsf_localsr.   r   next)r   r   base_class_varsbase_class_fieldsr7   r4   all_ignored_typesr   raw_annotationsignored_namesvar_namevaluesuggested_nameann_nameann_typeframer   metadatar   r5   s                      @rJ   r   r   e  s   4 7(*I%(=(??68mm$5r:O_$
i(?opp!eM	 12%~%5I)Iud#  Il$;;)+""--i.GH 01U__5O5OS^5^h'/0""4(BBJQP  %X.//2X~.@XLXY[  ,1x((#y)2Eh2O%__S1?ZN,/|H<qJ 
   &&x0.6L_]eMf6g/34DkZ_F`/a"8,h'(_,,,'XL )] ^1 
 E9-'XL(CDKk  (?zUI V,,4: 6jk :	 m 3z .335(%h/ 22- +84 11,5D(C( a($#5-hETXY%*__$)NN$ H%'1H#$\$\^bc+3?&x0+6=x(? 6B  &y1 s   %.LL('L(c                    t        |d      }t        |       }|d t        j                  hv st	        |dd       |j
                  k(  r|| _        y y )Nr   __code__)r   make_hash_funcrM   r   r   r  )r   r   base_hash_funcnew_hash_funcs       rJ   r   r     sP    -eZ@N"3'M$00GNJX\4]anawaw4w % 5xrK   c                    | j                   r*t        j                  | j                   j                          nd dfd}|S )Nc                     y)Nr   rY   )r   s    rJ   <lambda>z make_hash_func.<locals>.<lambda>  s    lmrK   c                    	 t         | j                              S # t        $ r' t         t        | j                                    cY S w xY wrq   )hashr   KeyErrorr2   )rE   getters    rJ   	hash_funcz!make_hash_func.<locals>.hash_func  sJ    	At}}-.. 	A
 />?@@	As    -AA)rE   r   rN   int)r   operator
itemgetterr   )r   r)  r(  s     @rJ   r  r    s;    EHE\E\X  #"9"9">">"@AbmFA rK   c                $   t        |       }t        | ||||      \  }}|| _        | j                  j	                  |       |D ]K  }| j
                  j                  |d      }|"|j                  t        us5t        | ||j                         M y)a<  Collect and set `cls.__pydantic_fields__` and `cls.__class_vars__`.

    Args:
        cls: BaseModel or dataclass.
        bases: Parents of the class, generally `cls.__bases__`.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting model annotations.
    )typevars_mapN)
r%   r    r   rg   r   rh   r   r   r   setattr)	r   r   r   r   r.  r  r   rF   r  s	            rJ   r   r   
  s     *#.L-c5.+dpqFJ$Cj) **..q$76G!GCEMM* rK   r   c          
     $   |j                   rt        | |       yt        |       }t        |||      }t	        t        |j                  d      |d      }	 | j                  | |      }	|j                  | j                        }	 |j                  |	      }	|	| _        t        |	| |xs | j                   | j"                  |rdnd	||j$                        | _        t)        |	|      | _        d
| _        t/        dt        t0        | j2                  | j4                  |j6                  |j8                              | _        y
# t        $ r(}
|r t        | |d|
j                   d       Y d}
~
yd}
~
ww xY w# |j                  $ r t        | |       Y yw xY w)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.
        cls_name: The model or dataclass name.
        config_wrapper: The config wrapper instance.
        raise_errors: Whether to raise errors.
        ns_resolver: The namespace resolver instance to use during schema building.
        create_model_module: The module of the class to be created, if created by `create_model`.

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

    Raises:
        PydanticUndefinedAnnotation: If `PydanticUndefinedAnnotation` occurs in`__get_pydantic_core_schema__`
            and `raise_errors=True`.
    F)from_dunder_get_core_schemaunpack)ref_moder<   N)titlecreate_modelr8   T__signature__)rW   r  populate_by_nameextra)defer_buildr(   r%   r#   r*   r   generate_schema__get_pydantic_core_schema__r   r   core_configrP   clean_schemaCollectedInvalid__pydantic_core_schema__r   rQ   rR   plugin_settingsr   r   __pydantic_serializer__r   r1   r+   r   r   r7  r8  r6  )r   r   r   r   r   r   r.  
gen_schemahandlerschemaer<  s               rJ   r   r   +  s   : !!X&)#.LJ +
**NG11#w? !,,3<<,@K((0 $*C !8-s~~-;&&"C #36;"GC $C
 +'**+<< &&	
	C U ' X166(!}5	 && X&s*   D= E1 =	E.E))E.1FFc                   | j                   j                         D ]>  \  }}|j                  x}t        |      }|j	                  | |       t        | ||       @ | j                  j                         D ]i  \  }}|j                  x}t        t        |j                        d      r5t        ||j                        }|j	                  | |       t        | ||       k y)z8Set data descriptors on the class for deprecated fields.N__deprecated__)
r   r   deprecation_message_DeprecatedFieldDescriptorr   r/  r   r   r   wrapped_property)r   field
field_infomsgdesccomputed_field_infos         rJ   r   r     s     44::<z111C>-c2Dc5)C%	 = '*&F&F&L&L&N""';;;SH34G4X4XY[kl-c3F3W3WXDc5)C% 'OrK   c                  @    e Zd ZU dZded<   d	d
dZddZd	ddZddZy)rI  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.
    rL   
field_nameNc                     || _         || _        y rq   )rM  rJ  )rE   rM  rJ  s      rJ   r   z#_DeprecatedFieldDescriptor.__init__  s     0rK   c                    || _         y rq   )rQ  )rE   r   r   s      rJ   r   z'_DeprecatedFieldDescriptor.__set_name__  s	    rK   c                b   |=| j                   | j                   j                  d |      S t        | j                        t	        j
                  | j                  t        j                  d       | j                   | j                   j                  ||      S |j                  | j                     S )Nr   rj   )
rJ  __get__r   rQ  r?   r@   rM  builtinsDeprecationWarningr   )rE   r   obj_types      rJ   rU  z"_DeprecatedFieldDescriptor.__get__  s    ;$$0,,44T8DD 11dhh ; ;J  ,((00h??||DOO,,rK   c                ,    t        | j                        rq   )r   rQ  )rE   r   r  s      rJ   __set__z"_DeprecatedFieldDescriptor.__set__  s    T__--rK   rq   )rM  rL   rJ  zproperty | NonerN   rO   )r   ri   r   rL   rN   rO   )r   zBaseModel | NonerX  ztype[BaseModel] | NonerN   r   )r   r   r  r   rN   r   )	rP   rQ   rR   rS   r   r   r   rU  rZ  rY   rK   rJ   rI  rI    s"     O1
-.rK   rI  c                  (    e Zd ZdZddZddZddZy)	_PydanticWeakRefa  Wrapper for `weakref.ref` that enables `pickle` serialization.

    Cloudpickle fails to serialize `weakref.ref` objects due to an arcane error related
    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`).
    c                L    |d | _         y t        j                  |      | _         y rq   )_wrweakrefref)rE   r   s     rJ   r   z_PydanticWeakRef.__init__  s     ; DH{{3'DHrK   c                <    | j                   y | j                         S rq   )r^  r   s    rJ   __call__z_PydanticWeakRef.__call__  s    8888:rK   c                    t          |        ffS rq   )r\  r   s    rJ   
__reduce__z_PydanticWeakRef.__reduce__  s    $&**rK   N)r   r   )rN   r   )rN   z4tuple[Callable, tuple[weakref.ReferenceType | None]])rP   rQ   rR   rS   r   rb  rd  rY   rK   rJ   r\  r\    s     (+rK   r\  c                    | yi }| j                         D ]  \  }}	 t        |      }|||<    |S # t        $ r |}Y w xY w)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   )dresultrF   rG   proxys        rJ   r   r     s\     	yF	1	$Q'E q	  M  	E	s   1??c                    | yi }| j                         D ]*  \  }}t        |t              r |       }| |||<   &|||<   , |S )zAInverts the transform performed by `build_lenient_weakvaluedict`.N)r   r>   r\  )rf  rg  rF   rG   s       rJ   r   r     sS    yF	1a)*A}q	F1I  MrK   )maxsizec                     ddl m}  t        t        t        t
        t        | t        g}t        j                  dk\  r|j                  t        j                         t        |      S )Nr   )r3   )      )r  r3   r   r   r   r   r   r   r  version_infoappendr   r   )r3   r   s     rJ   r  r    sR    * 	M 7"V112rK   )rW   zLiteral[False]rN   r   r   )r   r   r   r   rN   zCallable[..., Any] | None)
r   r   r   r   r  set[str]r  rp  rN   zdict[str, ModelPrivateAttr])r   ri   r   r   rN   rO   )r   ri   rN   r   )
r   ri   r   r   r   r   r   NsResolver | NonerN   rO   )r   ri   r   rL   r   r   r   r   r   rq  r   r   rN   r   )r   ri   rN   rO   )rf  dict[str, Any] | NonerN   rr  )rN   r   )jrS   
__future__r   _annotationsrV  r+  r  r   r?   r_  abcr   r   r   r   typesr   r   r	   r
   r   r   r   pydantic_corer   r   typing_extensionsr   r   r   r   errorsr   r   plugin._schema_validatorr   r   r   _configr   _decoratorsr   r   r   r   _fieldsr    r!   r"   _generate_schemar#   	_genericsr$   r%   _import_utilsr&   r'   _mock_val_serr(   _namespace_utilsr)   _schema_generation_sharedr*   
_signaturer+   _typing_extrar,   r-   r.   r/   r0   _utilsr1   r2   r   r  r3   r4   r5   r6   PydanticModelFieldr7   PydanticModelPrivateAttrmainr8   rW  rM   __setattr__r   r   r:   rZ   r^   rb   r   r   r   r  r   r   r   rI  r\  r   r   r  rY   rK   rJ   <module>r     s!   ( 2   
     (  B B = V V C > O " s s Y Y , F M * ( C 3  9	GG4@  3%x##
)$ 
) !
 	 T=OQikv<wxtW t ytnG$	EE(E E  	E
 !EP
% +	+ + "+ #	+
 
+L %)&*Z	ZZ "Z
 Z #Z $Z 
Zz&&". ".J +  +F(  4   rK   