
    ,hN                       % S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJ r   \RB                  (       d  \(       d%  SSK"J#r#  SSK"J$r$  SSK"J%r%  SS K"J&r&  SS!K"J'r'  SS"K"J(r(  O$SSK)J%r%  SS K)J&r&  SSK)J#r#  SSK*J$r$  SS!K*J'r'  SS"K*J(r(  \" S#\S$9r+\" S%\S$9r,\" S&\S$9r-\" S'S(S)9r.\/" 5       r0S*\1S+'   \/" S/5      r2S*\1S,'   SXS- jr3SYS. jr4\#" 5       r5S/\1S0'    " S1 S2\&\,\-4   5      r6\" S3\S$9r7\" S4\S$9r8 " S5 S6\\+   5      r9 " S7 S8\9\+   5      r: " S9 S:\%\9\+   5      r;SZS; jr<\=r>\<r? " S< S=\\+   5      r@ " S> S?\$5      rA " S@ SA\\,\-4   5      rB " SB SC\\,\-4   5      rC\DrE\=rF\'rG " SD SE\\+   5      rHS[SF jrISZS\SG jjrJS]SH jrKSI rLS^SJ jrM SZ       S_SK jjrNS`SL jrO " SM SN\R                  \,\-4   5      rQ " SO SP\ \.   5      rR " SQ SR\ 5      rS " SS ST\\+   5      rT " SU SV\T\+   5      rUSW rVg)azCollection classes and helpers.    )annotationsN)Any)Callable)cast)	Container)Dict)	FrozenSet)Generic)Iterable)Iterator)List)Mapping)NoReturn)Optional)overload)Sequence)Set)Tuple)TypeVar)Union)
ValuesView   )HAS_CYEXTENSION)is_non_string_iterable)Literal)Protocol)immutabledict)IdentitySet)ReadOnlyContainer)ImmutableDictBase)
OrderedSet)unique_list_T)bound_KT_VT_T_coT)	covariantzFrozenSet[Any]	EMPTY_SETNONE_SETc                    [        U 5      R                  U5      n/ n[        U 5      [        U5      pT U H.  nXb;   a  UR                  U5        XEpE  O)UR	                  U5        M0     UR                  U5         U$ MJ  )a
  merge two lists, maintaining ordering as much as possible.

this is to reconcile vars(cls) with cls.__annotations__.

Example::

    >>> a = ["__tablename__", "id", "x", "created_at"]
    >>> b = ["id", "name", "data", "y", "created_at"]
    >>> merge_lists_w_ordering(a, b)
    ['__tablename__', 'id', 'name', 'data', 'y', 'x', 'created_at']

This is not necessarily the ordering that things had on the class,
in this case the class is::

    class User(Base):
        __tablename__ = "users"

        id: Mapped[int] = mapped_column(primary_key=True)
        name: Mapped[str]
        data: Mapped[Optional[str]]
        x = Column(Integer)
        y: Mapped[int]
        created_at: Mapped[datetime.datetime] = mapped_column()

But things are *mostly* ordered.

The algorithm could also be done by creating a partial ordering for
all items in both lists and then using topological_sort(), but that
is too much overhead.

Background on how I came up with this is at:
https://gist.github.com/zzzeek/89de958cf0803d148e74861bd682ebae

)setintersectioniterdiscardappendextend)aboverlapresultcurrentotherelements          T/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/util/_collections.pymerge_lists_w_orderingr:   L   s{    F !f!!!$GF!Wd1gU
G!(!(wMM'"  MM% M     c                `    U (       d  [         $ [        U [        5      (       a  U $ [        U 5      $ N)
EMPTY_DICT
isinstancer   )ds    r9   coerce_to_immutabledictrA      s(    	A}	%	%Qr;   zimmutabledict[Any, Any]r>   c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)
FacadeDict   z*A dictionary that is not publicly mutable.c                2    [         R                  " U 5      nU$ r=   )r    __new__)clsargsnews      r9   rF   FacadeDict.__new__   s    '',
r;   c                    [        S5      e)Nz\an immutabledict shouldn't need to be copied.  use dict(d) if you need a mutable dictionary.)NotImplementedErrorselfs    r9   copyFacadeDict.copy   s    !0
 	
r;   c                &    [         [        U 5      44$ r=   )rC   dictrM   s    r9   
__reduce__FacadeDict.__reduce__   s    DJ=((r;   c                0    [         R                  XU5        g)z,insert an item into the dictionary directly.N)rR   __setitem__rN   keyvalues      r9   _insert_itemFacadeDict._insert_item   s    E*r;   c                2    S[         R                  U 5      -  $ )NzFacadeDict(%s))rR   __repr__rM   s    r9   r]   FacadeDict.__repr__   s    $--"555r;    N)rH   r   returnzFacadeDict[Any, Any])r`   r   r`   r   rX   r%   rY   r&   r`   None)r`   str)__name__
__module____qualname____firstlineno____doc__rF   rO   rS   rZ   r]   __static_attributes__r_   r;   r9   rC   rC      s    4
)+6r;   rC   _DT_Fc                  @  ^  \ rS rSr% SrSrS\S'   SS jrSS jrS S jr	S!U 4S	 jjr
S"S
 jrS#S jrS$S jrS%S jrS#S jrS&S jrS'S jrS$S jrS(S jrS)S jrS*S jr\S+S j5       r\S,S j5       r S-     S.S jjrS!S jrS/S jrS0S jrS(S jrS1S jrSrU =r$ )2
Properties   z8Provide a __getattr__/__setattr__ interface over a dict._dataDict[str, _T]rq   c                2    [         R                  U SU5        g Nrq   object__setattr__)rN   datas     r9   __init__Properties.__init__   s    4$/r;   c                ,    [        U R                  5      $ r=   lenrq   rM   s    r9   __len__Properties.__len__       4::r;   c                Z    [        [        U R                  R                  5       5      5      $ r=   )r.   listrq   valuesrM   s    r9   __iter__Properties.__iter__   s    D**,-..r;   c                   > [        [        5       5      U R                  R                  5        Vs/ s H  n[	        U5      PM     sn-   $ s  snf r=   )dirsuperrq   keysrd   )rN   k	__class__s     r9   __dir__Properties.__dir__   s7    57|tzz/@A/@!s1v/@AAAAs   A
c                0    [        U 5      [        U5      -   $ r=   )r   )rN   r7   s     r9   __add__Properties.__add__   s    DzDK''r;   c                     X R                   U'   g r=   rp   rN   rX   objs      r9   rV   Properties.__setitem__       

3r;   c                     U R                   U   $ r=   rp   rN   rX   s     r9   __getitem__Properties.__getitem__   s    zz#r;   c                    U R                   U	 g r=   rp   r   s     r9   __delitem__Properties.__delitem__       JJsOr;   c                     X R                   U'   g r=   rp   r   s      r9   rw   Properties.__setattr__   r   r;   c                    SU R                   0$ rt   rp   rM   s    r9   __getstate__Properties.__getstate__   s    $$r;   c                8    [         R                  U SUS   5        g rt   ru   )rN   states     r9   __setstate__Properties.__setstate__   s    4%.9r;   c                T     U R                   U   $ ! [         a    [        U5      ef = fr=   )rq   KeyErrorAttributeErrorr   s     r9   __getattr__Properties.__getattr__   s/    	&::c?" 	& %%	&s    'c                    XR                   ;   $ r=   rp   r   s     r9   __contains__Properties.__contains__       jj  r;   c                ,    [        U R                  5      $ )z8Return an immutable proxy for this :class:`.Properties`.)ReadOnlyPropertiesrq   rM   s    r9   as_readonlyProperties.as_readonly   s     "$**--r;   c                :    U R                   R                  U5        g r=   )rq   update)rN   rY   s     r9   r   Properties.update   s    

% r;   c                    g r=   r_   r   s     r9   getProperties.get   s    -0r;   c                    g r=   r_   rN   rX   defaults      r9   r   r          HKr;   c                    X;   a  X   $ U$ r=   r_   r   s      r9   r   r      s     ;9Nr;   c                ,    [        U R                  5      $ r=   )r   rq   rM   s    r9   r   Properties.keys       DJJr;   c                H    [        U R                  R                  5       5      $ r=   )r   rq   r   rM   s    r9   r   Properties.values   s    DJJ%%'((r;   c                H    [        U R                  R                  5       5      $ r=   )r   rq   itemsrM   s    r9   r   Properties.items   s    DJJ$$&''r;   c                    XR                   ;   $ r=   rp   r   s     r9   has_keyProperties.has_key   r   r;   c                8    U R                   R                  5         g r=   )rq   clearrM   s    r9   r   Properties.clear   s    

r;   r_   )rx   rr   r`   intr`   Iterator[_T])r`   z	List[str])r7   zProperties[_F]r`   zList[Union[_T, _F]])rX   rd   r   r#   r`   rc   )rX   rd   r`   r#   )rX   rd   r`   rc   )r`   Dict[str, Any])r   r   r`   rc   )rX   rd   r`   bool)r`   zReadOnlyProperties[_T])rY   rr   r`   rc   )rX   rd   r`   zOptional[_T])rX   rd   r   Union[_DT, _T]r`   r   r=   )rX   rd   r   zOptional[Union[_DT, _T]]r`   zOptional[Union[_T, _DT]])r`   List[_T])r`   zList[Tuple[str, _T]]r`   rc   )re   rf   rg   rh   ri   	__slots____annotations__ry   r~   r   r   r   rV   r   r   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   __classcell__)r   s   @r9   rn   rn      s    BI0/B(%:&!.
! 0 0K K =A!9	! )(! r;   rn   c                  "    \ rS rSrSrSrS rSrg)OrderedPropertiesi  zQProvide a __getattr__/__setattr__ interface with an OrderedDict
as backing store.r_   c                @    [         R                  U [        5       5        g r=   )rn   ry   OrderedDictrM   s    r9   ry   OrderedProperties.__init__
  s    D+-0r;   N)re   rf   rg   rh   ri   r   ry   rj   r_   r;   r9   r   r     s     I1r;   r   c                      \ rS rSrSrSrSrg)r   i  zDProvide immutable dict/object attribute to an underlying dictionary.r_   N)re   rf   rg   rh   ri   r   rj   r_   r;   r9   r   r     s
    NIr;   r   c                    [        XS9 Vs/ s H  o"X   4PM
     nnU R                  5         U R                  U5        gs  snf )zSort an OrderedDict in-place.)rX   N)sortedr   r   )r@   rX   r   r   s       r9   _ordered_dictionary_sortr     s<     !'q 23 21Y 2E3GGIHHUO	 4s   ?c                  :    \ rS rSrS	S
S jjrS rS rS rS rSr	g)WeakSequencei"  c                    [         R                  " U 5      4S jnX l        U Vs/ s H  n[         R                  " X25      PM     snU l        g s  snf )Nc                P    U" 5       nUb  UR                   R                  U 5        g g r=   )_storageremove)itemselfrefrN   s      r9   _remove&WeakSequence.__init__.<locals>._remove&  s&    9D$$T*  r;   )weakrefrefr   r   )rN   _WeakSequence__elementsr   r8   s       r9   ry   WeakSequence.__init__#  sE     #*++d"3 	+
 9C
9CgGKK)
 
s    Ac                v    U R                   R                  [        R                  " XR                  5      5        g r=   )r   r0   r   r   r   )rN   r   s     r9   r0   WeakSequence.append0  s!    W[[||<=r;   c                ,    [        U R                  5      $ r=   )r}   r   rM   s    r9   r~   WeakSequence.__len__3  s    4==!!r;   c                6    S S U R                    5        5       $ )Nc              3  .   #    U  H  oc  M  Uv   M     g 7fr=   r_   ).0r   s     r9   	<genexpr>(WeakSequence.__iter__.<locals>.<genexpr>7  s      
;CCC;s   	c              3  .   #    U  H  o" 5       v   M     g 7fr=   r_   )r   r   s     r9   r   r   8  s     ;]cCEE]s   )r   rM   s    r9   r   WeakSequence.__iter__6  s    
;T]];
 	
r;   c                h     U R                   U   nU" 5       $ ! [         a    [        SU-  5      ef = f)NzIndex %s out of range)r   r   
IndexError)rN   indexr   s      r9   r   WeakSequence.__getitem__;  s@    	--&C 5L  	>4u<==	>s    1)r   r   N)r_   )r   zSequence[_T])
re   rf   rg   rh   ry   r0   r~   r   r   rj   r_   r;   r9   r   r   "  s    
>"

r;   r   c                  "    \ rS rSrSSS jjrSrg)OrderedIdentitySetiD  Nc                    [         R                  " U 5        [        5       U l        U(       a  U H  nU R	                  U5        M     g g r=   )r   ry   r   _membersadd)rN   iterableos      r9   ry   OrderedIdentitySet.__init__E  s6    T"#  r;   )r  r=   )r  zOptional[Iterable[Any]])re   rf   rg   rh   ry   rj   r_   r;   r9   r   r   D  s     r;   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	PopulateDictiM  zA dict which populates missing values via a creation function.

Note the creation function takes a key, unlike
collections.defaultdict.

c                    Xl         g r=   creator)rN   r  s     r9   ry   PopulateDict.__init__U  s    r;   c                0    U R                  U5      =X'   nU$ r=   r
  rN   rX   vals      r9   __missing__PopulateDict.__missing__X  s    ,,s++	C
r;   r
  N)r  zCallable[[_KT], _VT]rX   r   r`   r   re   rf   rg   rh   ri   ry   r  rj   r_   r;   r9   r  r  M  s    r;   r  c                  ,    \ rS rSrSrSS jrSS jrSrg)	WeakPopulateDicti]  zYLike PopulateDict, but assumes a self + a method and does not create
a reference cycle.

c                t    UR                   U l        UR                  n[        R                  " U5      U l        g r=   )__func__r  __self__r   r   weakself)rN   creator_methodr  s      r9   ry   WeakPopulateDict.__init__c  s*    %..!**H-r;   c                N    U R                  U R                  5       U5      =X'   nU$ r=   r  r  r  s      r9   r  WeakPopulateDict.__missing__h  s$    ,,t}}<<	C
r;   r  N)r  ztypes.MethodTyper  r  r_   r;   r9   r  r  ]  s    
.
r;   r  c                  f    \ rS rSr% SrSrS\S'   S\S'   S\S	'    S   SS jjrSS jrSS jr	Sr
g
)UniqueAppenderiv  zAppends items to a collection ensuring uniqueness.

Additional appends() of the same object are ignored.  Membership is
determined by identity (``is a``) not equality (``==``).
)rx   _data_appender_unique&Union[Iterable[_T], Set[_T], List[_T]]rx   zCallable[[_T], None]r!  zDict[int, Literal[True]]r"  Nc                   Xl         0 U l        U(       a  [        X5      U l        g [	        US5      (       a  [        SU5      R                  U l        g [	        US5      (       a  [        SU5      R                  U l        g g )Nr0   r   r  zSet[_T])rx   r"  getattrr!  hasattrr   r0   r  )rN   rx   vias      r9   ry   UniqueAppender.__init__  si    
 	")$"4DT8$$"&z4"8"?"?DT5!!"&y$"7";";D "r;   c                z    [        U5      nX R                  ;  a!  U R                  U5        SU R                  U'   g g )NT)idr"  r!  )rN   r   id_s      r9   r0   UniqueAppender.append  s6    hll"% $DLL #r;   c                ,    [        U R                  5      $ r=   )r.   rx   rM   s    r9   r   UniqueAppender.__iter__  s    DIIr;   )r!  r"  rx   r=   )rx   r#  r'  zOptional[str])r   r#   r`   rc   r   )re   rf   rg   rh   ri   r   r   ry   r0   r   rj   r_   r;   r9   r   r   v  sF     4I
00((%%
 "<4< <%r;   r   c                    [        U 5      S:X  a0  [        U S   [        R                  5      (       a  [	        U S   5      $ [        SU 5      $ )Nr   r   	List[Any])r}   r?   typesGeneratorTyper   r   )args    r9   coerce_generator_argr4    s>    
3x1}CFE,?,?@@CF|K%%r;   c                v    U c  U$ [        U 5      (       d  U /$ [        U [        5      (       a  U $ [        U 5      $ r=   )r   r?   r   )xr   s     r9   to_listr7    s9    y!!$$s
	At		Awr;   c                .   ^  [        U 4S jU 5       5      $ )zreturn True if any items of set\_ are present in iterable.

Goes through special effort to ensure __hash__ is not called
on items in iterable that don't support it.

c              3  R   >#    U  H  oR                   (       d  M  UT;   v   M     g 7fr=   )__hash__)r   iset_s     r9   r   #has_intersection.<locals>.<genexpr>  s     9(QjjyqDy(s   '')any)r<  r  s   ` r9   has_intersectionr?    s     9(999r;   c                r    U c
  [        5       $ [        U [         5      (       d  [        [        U 5      5      $ U $ r=   )r,   r?   r7  r6  s    r9   to_setrB    s.    yua71:r;   c                r    U c
  [        5       $ [        U [         5      (       d  [        [        U 5      5      $ U $ r=   )
column_setr?   r7  rA  s    r9   to_column_setrE    s0    y|a$$'!*%%r;   c                z    U R                  5       n U(       a  U R                  U5        U R                  " S0 UD6  U $ )z5Copy the given dict and update with the given values.r_   )rO   r   )r@   _newkws      r9   update_copyrI    s/    
 	
A	HHNrNHr;   c              #     #    U  HB  n[        U[        5      (       d&  [        US5      (       a  [        U5       Sh  vN   M>  Uv   MD     g N7f)zyGiven an iterator of which further sub-elements may also be
iterators, flatten the sub-elements into a single iterator.

r   N)r?   rd   r&  flatten_iterator)r6  elems     r9   rK  rK    s@      $$$z)B)B'---J	 -s   :AAAc                      \ rS rSr% SrSrS\S'   S\S'   S\S	'      S     SS jjrS r\	SS j5       r
\	SS j5       r
 S     SS jjr
SS jrS S jrS!S jrS"S jrS#S jrS$S jr\S%S j5       rS&S jrSrg
)'LRUCachei  zDictionary with 'squishy' removal of least
recently used items.

Note that either get() or [] should be used here, but
generally its not safe to do an "in" check first as the dictionary
can change subsequent to that call.

)capacity	threshold
size_alertrq   _counter_mutexr   rO  floatrP  z.Optional[Callable[[LRUCache[_KT, _VT]], None]]rQ  Nc                x    Xl         X l        X0l        SU l        [        R
                  " 5       U l        0 U l        g )Nr   )rO  rP  rQ  rR  	threadingLockrS  rq   )rN   rO  rP  rQ  s       r9   ry   LRUCache.__init__  s/     !"$nn&<>
r;   c                D    U =R                   S-  sl         U R                   $ Nr   )rR  rM   s    r9   _inc_counterLRUCache._inc_counter  s    }}r;   c                    g r=   r_   r   s     r9   r   LRUCache.get
  s    .1r;   c                    g r=   r_   r   s      r9   r   r^    r   r;   c                x    U R                   R                  U5      nUb  U R                  5       US   S'   US   $ U$ N   r   r   )rq   r   r[  )rN   rX   r   r   s       r9   r   r^    s@     zz~~c"**,DGAJ7NNr;   c                V    U R                   U   nU R                  5       US   S'   US   $ ra  )rq   r[  )rN   rX   r   s      r9   r   LRUCache.__getitem__  s.    zz#&&(Q
Awr;   c                ,    [        U R                  5      $ r=   )r.   rq   rM   s    r9   r   LRUCache.__iter__  r   r;   c                ,    [        U R                  5      $ r=   r|   rM   s    r9   r~   LRUCache.__len__"  r   r;   c           	         [         R                  " U R                  R                  5        VVs0 s H
  u  pXS   _M     snn5      $ s  snnf rZ  )typingr   rq   r   )rN   r   r;  s      r9   r   LRUCache.values%  s<      djj6F6F6H!I6Hda!qT'6H!IJJ!Is   A
c                d    XU R                  5       /4U R                  U'   U R                  5         g r=   )r[  rq   _manage_sizerW   s      r9   rV   LRUCache.__setitem__(  s,    (9(9(;'<=

3r;   c                    U R                   U	 g r=   rp   )rN   _LRUCache__vs     r9   r   LRUCache.__delitem__,  r   r;   c                N    U R                   U R                   U R                  -  -   $ r=   )rO  rP  rM   s    r9   size_thresholdLRUCache.size_threshold/  s    }}t}}t~~===r;   c                   U R                   R                  S5      (       d  g  [        U R                  5      n[	        U 5      U R
                  U R
                  U R                  -  -   :  a  U(       a  SnU R                  U 5        [        U R                  R                  5       [        R                  " S5      SS9nX R
                  S   H  n U R                  US   	 M     [	        U 5      U R
                  U R
                  U R                  -  -   :  a  M  U R                   R                  5         g ! [         a     Mu  f = f! U R                   R                  5         f = f)NFrb  T)rX   reverser   )rS  acquirer   rQ  r}   rO  rP  r   rq   r   operator
itemgetterr   release)rN   rQ  
by_counterr   s       r9   rm  LRUCache._manage_size3  s   {{""5))	"doo.Jd)dmmdmmdnn.LLL!&JOOD)#JJ%%' ++A. 

 '}}7D! JJtAw/ 8 d)dmmdmmdnn.LLL  KK!	 $ ! ! KK!s0   B*E D27E 2
E <E ?E  E E)rR  rq   rS  rO  rQ  rP  )d   g      ?N)rO  r   rP  rT  rQ  zOptional[Callable[..., None]])rX   r%   r`   zOptional[_VT])rX   r%   r   Union[_VT, _T]r`   r~  r=   )rX   r%   r   Optional[Union[_VT, _T]]r`   r  )rX   r%   r`   r&   )r`   zIterator[_KT]r   )r`   zValuesView[_VT]rb   )rp  r%   r`   rc   )r`   rT  r   )re   rf   rg   rh   ri   r   r   ry   r[  r   r   r   r   r~   r   rV   r   propertyrs  rm  rj   r_   r;   r9   rN  rN    s    I M>> 48	?? ? 2	? 1 1K K =A!9	!
 K > >"r;   rN  c                      \ rS rSrSS jrSrg)_CreateFuncTypeiK  c                    g r=   r_   rM   s    r9   __call___CreateFuncType.__call__L  s    r;   r_   N)r`   r'   re   rf   rg   rh   r  rj   r_   r;   r9   r  r  K  s    $r;   r  c                      \ rS rSrSS jrSrg)_ScopeFuncTypeiO  c                    g r=   r_   rM   s    r9   r  _ScopeFuncType.__call__P  s    sr;   r_   Nra   r  r_   r;   r9   r  r  O  s    "r;   r  c                  v    \ rS rSr% SrSrS\S'   S\S'   S\S	'       SS
 jrSS jrSS jr	SS jr
SS jrSrg)ScopedRegistryiS  a  A Registry that can store one or multiple instances of a single
class on the basis of a "scope" function.

The object implements ``__call__`` as the "getter", so by
calling ``myregistry()`` the contained object is returned
for the current scope.

:param createfunc:
  a callable that returns a new object to be placed in the registry

:param scopefunc:
  a callable that will return a key to store/retrieve an object.

createfunc	scopefuncregistryz_CreateFuncType[_T]r  r  r  r   r  c                *    Xl         X l        0 U l        g)a&  Construct a new :class:`.ScopedRegistry`.

:param createfunc:  A creation function that will generate
  a new value for the current scope, if none is present.

:param scopefunc:  A function that returns a hashable
  token representing the current scope (such as, current
  thread identifier).

Nr  )rN   r  r  s      r9   ry   ScopedRegistry.__init__h  s     %"r;   c                    U R                  5       n U R                  U   $ ! [         a,    U R                  R                  XR	                  5       5      s $ f = fr=   )r  r  r   
setdefaultr  r   s     r9   r  ScopedRegistry.__call__y  sP    nn	D==%% 	D==++C1BCC	Ds   ! 3AAc                <    U R                  5       U R                  ;   $ )z9Return True if an object is present in the current scope.)r  r  rM   s    r9   hasScopedRegistry.has  s     ~~4==00r;   c                <    XR                   U R                  5       '   g)z$Set the value for the current scope.N)r  r  rN   r   s     r9   r,   ScopedRegistry.set  s     +.dnn&'r;   c                \     U R                   U R                  5       	 g! [         a     gf = f)z Clear the current scope, if any.N)r  r  r   rM   s    r9   r   ScopedRegistry.clear  s,    	dnn./ 		s    
++)r  r  r  N)r  Callable[[], _T]r  zCallable[[], Any]r`   r#   r`   r   r   r#   r`   rc   r   )re   rf   rg   rh   ri   r   r   ry   r  r  r,   r   rj   r_   r;   r9   r  r  S  sI     6I##M*7H"D1
.
r;   r  c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)ThreadLocalRegistryi  zTA :class:`.ScopedRegistry` that uses a ``threading.local()``
variable for storage.

c                D    Xl         [        R                  " 5       U l        g r=   )r  rV  localr  )rN   r  s     r9   ry   ThreadLocalRegistry.__init__  s    $!)r;   c                     U R                   R                  $ ! [         a%    U R                  5       =oR                   l        Us $ f = fr=   )r  rY   r   r  )rN   r  s     r9   r  ThreadLocalRegistry.__call__  sA    	==&&& 	(,(99C--%J	s    ,AAc                .    [        U R                  S5      $ )NrY   )r&  r  rM   s    r9   r  ThreadLocalRegistry.has  s    t}}g..r;   c                $    XR                   l        g r=   )r  rY   r  s     r9   r,   ThreadLocalRegistry.set  s    !r;   c                >     U R                   ?g ! [         a     g f = fr=   )r  rY   r   rM   s    r9   r   ThreadLocalRegistry.clear  s#    	# 		s    
)r  r  N)r  r  r  r  r  r   )re   rf   rg   rh   ri   ry   r  r  r,   r   rj   r_   r;   r9   r  r    s     
*/"r;   r  c                @    SnU  H  nX1L d  M	  US-  nUS:  d  M    g   g)zjGiven a sequence and search object, return True if there's more
than one, False if zero or one of them.


r   r   TFr_   )sequencetargetcr   s       r9   	has_dupesr    s0     	
A>FA1u	 
 r;   )r2   r0  r3   r0  r`   r0  )r@   zMapping[_KT, _VT]r`   zimmutabledict[_KT, _VT]r=   )r3  r   r`   r0  )r6  r   r   zOptional[List[Any]]r`   r0  )r<  zContainer[Any]r  zIterable[Any]r`   r   )r6  r   r`   zSet[Any])r@   Dict[Any, Any]rG  zOptional[Dict[Any, Any]]rH  r   r`   r  )r6  zIterable[_T]r`   r   )Wri   
__future__r   rx  rV  r1  rj  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _has_cyr   r   r   r   TYPE_CHECKING_py_collectionsr   r   r   r    r!   r"   $sqlalchemy.cyextension.immutabledict"sqlalchemy.cyextension.collectionsr#   r%   r&   r'   	frozensetr)   r   r*   r:   rA   r>   rC   rk   rl   rn   r   r   r   rR   r   sort_dictionaryr   r   r  r  r,   rD  column_dictordered_column_setr   r4  r7  r?  rB  rE  rI  rK  MutableMappingrN  r  r  r  r  r  r_   r;   r9   <module>r     s   & "                          $ *  	?;GG9; NK
 Te3e34(%K	> '$dV,. ,5p  '4o
# 56"38, 60 e3TT Tn1
2 1*JrN  *8B< D 4S>  tCH~ ( 
 "WR[ "J&: 9=		5	DG		
f"v$$S#X. f"R%huo %#X #=WR[ =@., <r;   