Ë
    /æj<  ã                  ó†  — U 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 ddlmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZmZmZm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 e#r*ee6e$f   ee7e$f   z  Z8de9d<   ee6   ee7   z  Z:de9d<   ddl;m<Z< e6e=e>e7e?e@eAe!eeeej„                  ee eCjˆ                  eEjˆ                  hZFde9d<   eGeHeIeJeKe	e
ehZLde9d<   d:d„ZMd;d„ZNd<d„ZOd=d„ZPd>d„ZQd?d „ZR e(d!«      ZSd@d"„ZTdAd#„ZU e(d$«      ZVe7d%œ	 	 	 	 	 dBd&„ZW G d'„ d(e2j°                  «      ZYe#rdCd)„ZZn
 G d*„ d+«      ZZ e(d,«      Z[dDd-„Z\ e]«       Z^dEd.„Z_dFd/„Z` ejÂ                  d0d0¬1«       G d2„ d3«      «       Zb e(d4d5¬6«      Zc e(d7«      Zd G d8„ d9e%ecedf   «      Zey)Gz�Bucket of reusable internal utilities.

This should be reduced as much as possible with functions only used in one place, moved to that place.
é    )ÚannotationsN)ÚOrderedDictÚdefaultdictÚdeque)ÚCallableÚIterableÚMapping)ÚSet)Údeepcopy)Úcached_property)Ú	Parameter)Úzip_longest)ÚBuiltinFunctionTypeÚCodeTypeÚFunctionTypeÚGeneratorTypeÚ
LambdaTypeÚ
ModuleTypeÚNoneType)ÚTYPE_CHECKINGÚAnyÚGenericÚ	TypeAliasÚ	TypeGuardÚTypeVarÚoverload)ÚMISSINGÚPydanticUndefined)Ú
deprecated)ÚPydanticDeprecatedSince211é   )Ú_reprÚ_typing_extra)Úimport_cached_base_modelr   ÚMappingIntStrAnyÚAbstractSetIntStré   )Ú	BaseModelzset[type[Any]]ÚIMMUTABLE_NON_COLLECTIONS_TYPESÚBUILTIN_COLLECTIONSc                óZ   — | j                   t        j                  t        j                  fv S )aZ  Return whether the parameter accepts a positional argument.

    ```python {test="skip" lint="skip"}
    def func(a, /, b, *, c):
        pass

    params = inspect.signature(func).parameters
    can_be_positional(params['a'])
    #> True
    can_be_positional(params['b'])
    #> True
    can_be_positional(params['c'])
    #> False
    ```
    )Úkindr   ÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORD)Úparams    ú\/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/pydantic/_internal/_utils.pyÚcan_be_positionalr1   H   s$   € ð  �:‰:œ)×3Ñ3´Y×5TÑ5TÐUÐUÐUó    c           	     óV   — t        | t        t        t        t        t
        t        f«      S ©N)Ú
isinstanceÚlistÚtupleÚsetÚ	frozensetr   r   ©Úvs    r0   Úsequence_liker<   [   s   € Ü�aœ$¤¤s¬I´}ÄeÐLÓMÐMr2   c                ó:   — 	 t        | |«      S # t        $ r Y yw xY w©NF)r5   Ú	TypeError)ÚoÚclass_or_tuples     r0   Úlenient_isinstancerB   _   s&   € ðÜ˜!˜^Ó,Ð,øÜò Ùðús   ‚ Ž	™c                ó”   — 	 t        | t        «      xr t        | |«      S # t        $ r t        | t        j
                  «      rY y‚ w xY wr>   )r5   ÚtypeÚ
issubclassr?   r#   ÚWithArgsTypes)ÚclsrA   s     r0   Úlenient_issubclassrH   f   sE   € ðÜ˜#œtÓ$ÒH¬°C¸Ó)HÐHøÜò Ü�cœ=×6Ñ6Ô7ÙØðús   ‚   #AÁAc                ó:   — t        «       }t        | |«      xr | |uS )zŒReturns true if cls is a _proper_ subclass of BaseModel, and provides proper type-checking,
    unlike raw calls to lenient_issubclass.
    )r$   rH   )rG   r(   s     r0   Úis_model_classrJ   o   s#   € ô )Ó*€Iä˜c 9Ó-ÒF°#¸YÐ2FÐFr2   c                óR   — | j                  «       xr t        j                  | «       S )z¦Checks that a string is a valid identifier and not a Python keyword.
    :param identifier: The identifier to test.
    :return: True if the identifier is valid.
    )ÚisidentifierÚkeywordÚ	iskeyword)Ú
identifiers    r0   Úis_valid_identifierrP   x   s&   € ð
 ×"Ñ"Ó$ÒJ¬W×->Ñ->¸zÓ-JÐ)JÐJr2   ÚKeyTypec                óâ   — | j                  «       }|D ]Y  }|j                  «       D ]D  \  }}||v r6t        ||   t        «      r#t        |t        «      rt	        ||   |«      ||<   Œ@|||<   ŒF Œ[ |S r4   )ÚcopyÚitemsr5   ÚdictÚdeep_update)ÚmappingÚupdating_mappingsÚupdated_mappingÚupdating_mappingÚkr;   s         r0   rV   rV   ƒ   sƒ   € Ø—l‘l“n€OØ-ò 'ÐØ$×*Ñ*Ó,ò 	'‰DˆAˆqØ�OÑ#¬
°?À1Ñ3EÄtÔ(LÔQ[Ð\]Ô_cÔQdÜ%0°ÀÑ1CÀQÓ%G� Ò"à%&� Ò"ñ		'ð'ð Ðr2   c                ó|   — | j                  |j                  «       D ��ci c]  \  }}|€Œ	||“Œ c}}«       y c c}}w r4   )ÚupdaterT   )rW   r]   r[   r;   s       r0   Úupdate_not_noner^   Ž   s.   € Ø‡N�N V§\¡\£^×E™T˜Q °q±}�A�q‘DÓEÕFùÓEs   Ÿ
8
ª8
ÚT)Úname_factoryc               ó¢   — g }g }| D ]E  } ||«      }||vr#|j                  |«       |j                  |«       Œ2|||j                  |«      <   ŒG |S )z£Make a list unique while maintaining order.
    We update the list if another one with the same name is set
    (e.g. model validator overridden in subclass).
    )ÚappendÚindex)Ú
input_listr`   ÚresultÚresult_namesr;   Úv_names         r0   Úunique_listrh   •   sd   € ð €FØ €LØò 3ˆÙ˜a“ˆØ˜Ñ%Ø×Ñ Ô'Ø�M‰M˜!Õà12ˆF�<×%Ñ% fÓ-Ò.ð3ð €Mr2   c                  óŽ   — e Zd ZdZdZdd„Zdd„Zdd„Zdd„Zdd„Z	e
ddd„«       Zedd	„«       Ze
dd
„«       Zedd„«       Zdd„Zy)Ú
ValueItemszOClass for more convenient calculation of excluded or included fields on values.©Ú_itemsc                ó–   — | j                  |«      }t        |t        t        f«      r| j	                  |t        |«      «      }|| _        y r4   )Ú_coerce_itemsr5   r6   r7   Ú_normalize_indexesÚlenrl   )ÚselfÚvaluerT   s      r0   Ú__init__zValueItems.__init__°   s=   € Ø×"Ñ" 5Ó)ˆä�eœd¤E˜]Ô+Ø×+Ñ+¨E´3°u³:Ó>ˆEà(-ˆ�r2   c                óV   — | j                  | j                  j                  |«      «      S )zWCheck if item is fully excluded.

        :param item: key or index of a value
        )Úis_truerl   Úget©rq   Úitems     r0   Úis_excludedzValueItems.is_excluded¸   s    € ð
 �|‰|˜DŸK™KŸO™O¨DÓ1Ó2Ð2r2   c                ó   — || j                   v S )z`Check if value is contained in self._items.

        :param item: key or index of value
        rk   rw   s     r0   Úis_includedzValueItems.is_included¿   s   € ð
 �t—{‘{Ð"Ð"r2   c                ób   — | j                   j                  |«      }| j                  |«      s|S dS )z�:param e: key or index of element on value
        :return: raw values for element if self._items is dict and contain needed element
        N)rl   rv   ru   )rq   Úerx   s      r0   Úfor_elementzValueItems.for_elementÆ   s,   € ð �{‰{�‰˜qÓ!ˆØŸ<™<¨Ô-ˆtÐ7°4Ð7r2   c                óž  — i }d}|j                  «       D ]³  \  }}t        |t        «      s<t        |t        «      s,| j	                  |«      st        d|› d|j                  › �«      ‚|dk(  r| j                  |«      }Œit        |t        «      st        d«      ‚|dk  r||z   n|}| j                  ||j                  |«      «      ||<   Œµ |s|S | j	                  |«      r$t        |«      D ]  }|j                  |d«       Œ |S t        |«      D ];  }|j                  |i «      }| j	                  |«      rŒ'| j                  ||«      ||<   Œ= |S )a]  :param items: dict or set of indexes which will be normalized
        :param v_length: length of sequence indexes of which will be

        >>> self._normalize_indexes({0: True, -2: True, -1: True}, 4)
        {0: True, 2: True, 3: True}
        >>> self._normalize_indexes({'__all__': True}, 4)
        {0: True, 1: True, 2: True, 3: True}
        Nz,Unexpected type of exclude value for index "z" Ú__all__z€Excluding fields from a sequence of sub-models or dicts must be performed index-wise: expected integer keys or keyword "__all__"r   .)rT   r5   r	   ÚAbstractSetru   r?   Ú	__class__Ú_coerce_valueÚintÚmergerv   ÚrangeÚ
setdefault)	rq   rT   Úv_lengthÚnormalized_itemsÚ	all_itemsÚir;   Únormalized_iÚnormalized_items	            r0   ro   zValueItems._normalize_indexesÍ   sh  € ð 24ÐØˆ	Ø—K‘K“Mò 	_‰DˆAˆqÜ˜q¤'Ô*¬j¸¼KÔ.HÈDÏLÉLÐYZÌOÜÐ"NÈqÈcÐQSÐTU×T_ÑT_ÐS`Ð aÓbÐbØ�IŠ~Ø ×.Ñ.¨qÓ1�	ØÜ˜a¤Ô%ÜðAóð ð ,-¨qª5˜8 aš<°aˆLØ-1¯Z©Z¸Ð;K×;OÑ;OÐP\Ó;]Ó-^Ð˜\Ò*ð	_ñ Ø#Ð#Ø�<‰<˜	Ô"Ü˜8“_ò 4�Ø ×+Ñ+¨A¨sÕ3ð4à#Ð#Ü�x“ò 	MˆAØ.×9Ñ9¸!¸RÓ@ˆOØ—<‘< Õ0Ø&*§j¡j°¸OÓ&LÐ  Ò#ð	Mð  Ðr2   c                óì  — | j                  |«      }| j                  |«      }|€|S | j                  |«      s|€|S | j                  |«      r|r|S |S |r,|D �cg c]	  }||v sŒ|‘Œ c}|D �cg c]	  }||v sŒ|‘Œ c}z   }n!t        |«      |D �cg c]	  }||vsŒ|‘Œ c}z   }i }|D ]<  }| j                  |j	                  |«      |j	                  |«      |¬«      }|€Œ8|||<   Œ> |S c c}w c c}w c c}w )aH  Merge a `base` item with an `override` item.

        Both `base` and `override` are converted to dictionaries if possible.
        Sets are converted to dictionaries with the sets entries as keys and
        Ellipsis as values.

        Each key-value pair existing in `base` is merged with `override`,
        while the rest of the key-value pairs are updated recursively with this function.

        Merging takes place based on the "union" of keys if `intersect` is
        set to `False` (default) and on the intersection of keys if
        `intersect` is set to `True`.
        )Ú	intersect)rƒ   ru   r6   r…   rv   )rG   ÚbaseÚoverrider�   r[   Ú
merge_keysÚmergedÚmerged_items           r0   r…   zValueItems.mergeò   s	  € ð ×$Ñ$ XÓ.ˆØ× Ñ  Ó&ˆØÐØˆKØ�;‰;�tÔ  ØˆOØ�;‰;�xÔ Ù$�4Ð2¨(Ð2ñ Ø%)Ö; ¨Q°(ª]š!Ò;È(Ö>`ÀQÐVWÐ[_ÒV_ºqÒ>`Ñ`‰Jä˜d›°(Ö&L¨Q¸aÀtºm¢qÒ&LÑLˆJà')ˆØò 	(ˆAØŸ)™) D§H¡H¨Q£K°·±¸a³ÈI˜)ÓVˆKØÑ&Ø'��q’	ð	(ð
 ˆùò <ùÒ>`ùâ&Ls$   Á	C'Á#C'Á-	C,Á7C,Â	C1ÂC1c                ó®   — t        | t        «      r	 | S t        | t        «      rt        j	                  | d«      } | S t        | dd«      }t        d|› �«      ‚)N.r‚   z???z!Unexpected type of exclude value )r5   r	   r�   rU   ÚfromkeysÚgetattrr?   )rT   Ú
class_names     r0   rn   zValueItems._coerce_items  s\   € ä�eœWÔ%Øð ˆô ˜œ{Ô+Ü—M‘M %¨Ó-ˆEð ˆô ! ¨°UÓ;ˆJÜÐ?À
¸|ÐLÓMÐMr2   c                óN   — |�| j                  |«      r|S | j                  |«      S r4   )ru   rn   )rG   rr   s     r0   rƒ   zValueItems._coerce_value#  s(   € àˆ=˜CŸK™K¨Ô.ØˆLØ× Ñ  Ó'Ð'r2   c                ó   — | du xs | du S )NT.© r:   s    r0   ru   zValueItems.is_true)  s   € à�DˆyÒ$˜A ˜HÐ$r2   c                ó    — d | j                   fgS r4   rk   ©rq   s    r0   Ú__repr_args__zValueItems.__repr_args__-  s   € Ø�t—{‘{Ð#Ð$Ð$r2   N)rr   r   rT   ú$AbstractSetIntStr | MappingIntStrAnyÚreturnÚNone)rx   r   r    Úbool)r}   z	int | strr    z+AbstractSetIntStr | MappingIntStrAny | None)rT   r%   rˆ   r„   r    zdict[int | str, Any])F)r�   r   r‘   r   r�   r¢   r    r   )rT   rŸ   r    r%   )rr   r   r    r   ©r;   r   r    r¢   )r    z_repr.ReprArgs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rs   ry   r{   r~   ro   Úclassmethodr…   Ústaticmethodrn   rƒ   ru   rž   r›   r2   r0   rj   rj   «   sz   „ ÙYà€Ió.ó3ó#ó8ó# ðJ ó#ó ð#ðJ òó ðð ò(ó ð(ð
 ò%ó ð%ô%r2   rj   c                 ó   — y r4   r›   ©ÚnameÚ	get_values     r0   ÚLazyClassAttributer¯   3  s   � r2   c                  ó2   — e Zd ZdZdd„Zedd„«       Zdd„Zy)	r¯   z­A descriptor exposing an attribute only accessible on a class (hidden from instances).

        The attribute is lazily computed and cached during the first access.
        c                ó    — || _         || _        y r4   r¬   )rq   r­   r®   s      r0   rs   zLazyClassAttribute.__init__=  s   € ØˆDŒIØ&ˆD�Nr2   c                ó"   — | j                  «       S r4   )r®   r�   s    r0   rr   zLazyClassAttribute.valueA  s   € à—>‘>Ó#Ð#r2   c                óh   — |€| j                   S t        | j                  ›d|j                  ›d�«      ‚)Nz attribute of z is class-only)rr   ÚAttributeErrorr­   r¤   )rq   ÚinstanceÚowners      r0   Ú__get__zLazyClassAttribute.__get__E  s4   € ØÐØ—z‘zÐ!Ü  D§I¡I =°¸u¿~¹~Ð>PÐP^Ð!_Ó`Ð`r2   N)r­   Ústrr®   zCallable[[], Any]r    r¡   )r    r   )rµ   r   r¶   z	type[Any]r    r   )r¤   r¥   r¦   r§   rs   r   rr   r·   r›   r2   r0   r¯   r¯   7  s&   „ ñ	ó
	'ð 
ò	$ó 
ð	$ô	ar2   r¯   ÚObjc                óú   — | t         u s| t        u r| S | j                  }|t        v r| S 	 | s"|t        v r|t
        u r| S | j                  «       S t        | «      S # t        t        t        f$ r Y t        | «      S w xY w)z¬Return type as is for immutable built-in types
    Use obj.copy() for built-in empty collections
    Use copy.deepcopy() for non-empty collections and unknown objects.
    )r   r   r‚   r)   r*   r7   rS   r?   Ú
ValueErrorÚRuntimeErrorr   )ÚobjÚobj_types     r0   Úsmart_deepcopyr¿   N  sˆ   € ð
 Œg�~˜Ô 1Ñ1Øˆ
Ø�}‰}€HØÔ2Ñ2Øˆ
ðÙ�xÔ#6Ñ6à"¤eÑ+�3Ð;°·±³Ð;ô
 �C‹=Ðøô	 ”z¤<Ð0ò àä�C‹=Ðð	ús   ªA ¾A ÁA:Á9A:c                óD   — t        | |t        ¬«      D ]  \  }}||usŒ y y)a  Check that the items of `left` are the same objects as those in `right`.

    >>> a, b = object(), object()
    >>> all_identical([a, b, a], [a, b, a])
    True
    >>> all_identical([a, b, [a]], [a, b, [a]])  # new list object, while "equal" is not "identical"
    False
    )Ú	fillvalueFT)r   Ú	_SENTINEL)ÚleftÚrightÚ	left_itemÚ
right_items       r0   Úall_identicalrÇ   f  s1   € ô "-¨T°5ÄIÔ!Nò Ñˆ	�:Ø˜JÒ&Ùðð r2   c                ó   — | �| S |S )zTReturn the first argument if it is not `None`, otherwise return the second argument.r›   )ÚaÚbs     r0   Úget_first_not_nonerË   u  s   € à�ˆ1Ð$ 1Ð$r2   T)ÚfrozenÚslotsc                  ó2   — e Zd ZU dZded<   dd„Zerdd„Zyy)	ÚSafeGetItemProxyz¦Wrapper redirecting `__getitem__` to `get` with a sentinel value as default

    This makes it safe to use in `operator.itemgetter` when some keys may be missing
    zMapping[str, Any]Úwrappedc               óB   — | j                   j                  |t        «      S r4   )rÐ   rv   rÂ   ©rq   Úkeys     r0   Ú__getitem__zSafeGetItemProxy.__getitem__ƒ  s   € Ø�|‰|×Ñ ¤YÓ/Ð/r2   c               ó8   — | j                   j                  |«      S r4   )rÐ   Ú__contains__rÒ   s     r0   rÖ   zSafeGetItemProxy.__contains__Œ  s   € Ø—<‘<×,Ñ,¨SÓ1Ð1r2   N)rÓ   r¸   r    r   )rÓ   r¸   r    r¢   )r¤   r¥   r¦   r§   Ú__annotations__rÔ   r   rÖ   r›   r2   r0   rÏ   rÏ   z  s#   … ñð
 Óó0ñ ô	2ð r2   rÏ   Ú_ModelTr(   )ÚboundÚ_RTc                  ó^   — e Zd ZdZd	d„Zed
d„«       Ze edd¬«      dd„«       «       Zdd„Zy)Údeprecated_instance_propertya›  A decorator exposing the decorated class method as a property, with a warning on instance access.

    This decorator takes a class method defined on the `BaseModel` class and transforms it into
    an attribute. The attribute can be accessed on both the class and instances of the class. If accessed
    via an instance, a deprecation warning is emitted stating that instance access will be removed in V3.
    c               ó   — || _         y r4   )Úfget)rq   rÞ   s     r0   rs   z%deprecated_instance_property.__init__œ  s	   € àˆ�	r2   c                 ó   — y r4   r›   ©rq   rµ   Úobjtypes      r0   r·   z$deprecated_instance_property.__get__   s   € ØFIr2   z›Accessing this attribute on the instance is deprecated, and will be removed in Pydantic V3. Instead, you should access this attribute from the model class.N)Úcategoryc                 ó   — y r4   r›   rà   s      r0   r·   z$deprecated_instance_property.__get__¢  s	   € ð JMr2   c                ó°   — |�4t        j                  d| j                  j                  ›d�t        d¬«        | j                  j                  ||«      «       S )NzAccessing the zi attribute on the instance is deprecated. Instead, you should access this attribute from the model class.r'   )râ   Ú
stacklevel)ÚwarningsÚwarnrÞ   r¤   r    r·   rà   s      r0   r·   z$deprecated_instance_property.__get__©  sV   € ØÐÜ�M‰MØ  §¡×!3Ñ!3Ð 6ð 7Rð Rä3Øõ	ð 4ˆt�y‰y× Ñ  ¨7Ó3Ó5Ð5r2   )rÞ   zCallable[[type[_ModelT]], _RT]r    r¡   )rµ   r¡   rá   útype[_ModelT]r    rÚ   )rµ   rØ   rá   rè   r    rÚ   )rµ   z_ModelT | Nonerá   rè   r    rÚ   )r¤   r¥   r¦   r§   rs   r   r·   r   r›   r2   r0   rÜ   rÜ   ”  sK   „ ñóð ÚIó ØIØÙð	Jàôò
 Móó ð Mô6r2   rÜ   )r/   r   r    r¢   r£   )r@   r   rA   z(type[Any] | tuple[type[Any], ...] | Noner    r¢   )rG   r   rA   r   r    r¢   )rG   r   r    zTypeGuard[type[BaseModel]])rO   r¸   r    r¢   )rW   údict[KeyType, Any]rX   ré   r    ré   )rW   zdict[Any, Any]r]   r   r    r¡   )rd   zlist[T] | tuple[T, ...]r`   zCallable[[T], str]r    zlist[T])r­   r¸   r®   zCallable[[], T]r    r_   )r½   r¹   r    r¹   )rÃ   úIterable[Any]rÄ   rê   r    r¢   )rÉ   r   rÊ   r   r    r   )fr§   Ú
__future__r   Ú_annotationsÚdataclassesrM   ræ   ÚweakrefÚcollectionsr   r   r   Úcollections.abcr   r   r	   r
   r�   rS   r   Ú	functoolsr   Úinspectr   Ú	itertoolsr   Útypesr   r   r   r   r   r   r   Útypingr   r   r   r   r   r   r   Úpydantic_corer   r   Útyping_extensionsr   Úpydanticr    Ú r"   r#   Ú_import_utilsr$   r„   r¸   r%   r×   r&   Úmainr(   ÚfloatÚcomplexr¢   ÚbytesrD   ÚrefÚNotImplementedr‚   ÚEllipsisr)   r6   r8   r7   r9   rU   r*   r1   r<   rB   rH   rJ   rP   rQ   rV   r^   r_   rh   ÚRepresentationrj   r¯   r¹   r¿   ÚobjectrÂ   rÇ   rË   Ú	dataclassrÏ   rØ   rÚ   rÜ   r›   r2   r0   ú<module>r     s  ðòõ
 3ã Û Û Û ß 7Ñ 7ß 7Ñ 7Ý .Ý Ý %Ý Ý !ß n× nÑ nß W× WÑ Wç 4Ý (å /ç "Ý 3áØ")¨#¨s¨(Ñ"3°g¸cÀ3¸hÑ6GÑ"GÐ�iÓGØ#.¨sÑ#3°kÀ#Ñ6FÑ#FÐ�yÓFÝ ð
 Ø	ØØØØ	ØØØØØØ‡K�KØð Ø×ÑØ×Ñð'3Ð  ó ð0 	ØØ	ØØØØØ	ð	'Ð �^ó 	óVó&NóóóGóKñ �)Ó
€óóGñ ˆCƒL€ð (+ñØ'ðð %ðð ó	ô,C%�×%Ñ%ô C%ñL äK÷añ añ( ˆeƒn€óñ* ‹H€	óó%ð
 €×Ñ˜d¨$Ô/÷2ð 2ó 0ð2ñ* �) ;Ô
/€Ùˆeƒn€ô6 7¨7°C¨<Ñ#8õ 6r2   