
    \fnN                       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 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 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 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 ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlm Z  ejB                  ses%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( n$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(  ed#e$      Z+ ed%e$      Z, ed&e$      Z- ed'd()      Z. e/       Z0d*e1d+<    e/dg      Z2d*e1d,<   dXd-Z3dYd.Z4 e#       Z5d/e1d0<    G d1 d2e&e,e-f         Z6 ed3e$      Z7 ed4e$      Z8 G d5 d6ee+         Z9 G d7 d8e9e+         Z: G d9 d:e%e9e+         Z;dZd;Z<e=Z>e<Z? G d< d=ee+         Z@ G d> d?e$      ZA G d@ dAee,e-f         ZB G dB dCee,e-f         ZCeDZEe=ZFe'ZG G dD dEee+         ZHd[dFZIdZd\dGZJd]dHZKdI ZLd^dJZMdZdKZNd_dLZO G dM dNej                  e,e-f         ZQ G dO dPe e.         ZR G dQ dRe       ZS G dS dTee+         ZT G dU dVeTe+         ZUdW ZVy)`z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                    t        |       j                  |      }g }t        |       t        |      }}	 |D ].  }||v r|j                  |       ||}} n'|j	                  |       0 |j                  |       	 |S H)af  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          U/var/www/highground/venv/lib/python3.12/site-packages/sqlalchemy/util/_collections.pymerge_lists_w_orderingr:   L   s    F !f!!!$GF!Wd1gUG
 		G'!(!(%wMM'"		 MM% M     c                L    | st         S t        | t              r| S t        |       S N)
EMPTY_DICT
isinstancer   )ds    r9   coerce_to_immutabledictrA      s%    	A}	%Qr;   zimmutabledict[Any, Any]r>   c                  8    e Zd ZdZddZd	dZd
dZddZddZy)
FacadeDictz*A dictionary that is not publicly mutable.c                0    t        j                  |       }|S r=   )r    __new__)clsargsnews      r9   rE   zFacadeDict.__new__   s    '',
r;   c                    t        d      )Nz\an immutabledict shouldn't need to be copied.  use dict(d) if you need a mutable dictionary.)NotImplementedErrorselfs    r9   copyzFacadeDict.copy   s    !0
 	
r;   c                &    t         t        |       ffS r=   )rC   dictrK   s    r9   
__reduce__zFacadeDict.__reduce__   s    DJ=((r;   c                2    t         j                  | ||       y)z,insert an item into the dictionary directly.N)rO   __setitem__rL   keyvalues      r9   _insert_itemzFacadeDict._insert_item   s    sE*r;   c                2    dt         j                  |       z  S )NzFacadeDict(%s))rO   __repr__rK   s    r9   rX   zFacadeDict.__repr__   s    $--"555r;   N)rG   r   returnzFacadeDict[Any, Any])rY   r   rY   r   rT   r%   rU   r&   rY   None)rY   str)	__name__
__module____qualname____doc__rE   rM   rP   rV   rX    r;   r9   rC   rC      s    4
)+6r;   rC   _DT_Fc                      e Zd ZU dZdZded<   ddZddZddZd fdZ	d d	Z
d!d
Zd"dZd#dZd!dZd$dZd%dZd"dZd&dZd'dZd(dZed)d       Zed*d       Z	 d+	 	 	 	 	 d,dZddZd-dZd.dZd&dZd/dZ xZS )0
Propertiesz8Provide a __getattr__/__setattr__ interface over a dict._dataDict[str, _T]rh   c                2    t         j                  | d|       y Nrh   object__setattr__)rL   datas     r9   __init__zProperties.__init__   s    4$/r;   c                ,    t        | j                        S r=   lenrh   rK   s    r9   __len__zProperties.__len__       4::r;   c                Z    t        t        | j                  j                                     S r=   )r.   listrh   valuesrK   s    r9   __iter__zProperties.__iter__   s    D**,-..r;   c                    t        t                     | j                  j                         D cg c]  }t	        |       c}z   S c c}w r=   )dirsuperrh   keysr]   )rL   k	__class__s     r9   __dir__zProperties.__dir__   s1    57|tzz/@A!s1vAAAAs   Ac                0    t        |       t        |      z   S r=   )rw   )rL   r7   s     r9   __add__zProperties.__add__   s    DzDK''r;   c                "    || j                   |<   y r=   rg   rL   rT   objs      r9   rR   zProperties.__setitem__       

3r;   c                     | j                   |   S r=   rg   rL   rT   s     r9   __getitem__zProperties.__getitem__   s    zz#r;   c                    | j                   |= y r=   rg   r   s     r9   __delitem__zProperties.__delitem__       JJsOr;   c                "    || j                   |<   y r=   rg   r   s      r9   rn   zProperties.__setattr__   r   r;   c                    d| j                   iS rk   rg   rK   s    r9   __getstate__zProperties.__getstate__   s    $$r;   c                8    t         j                  | d|d          y rk   rl   )rL   states     r9   __setstate__zProperties.__setstate__   s    4%.9r;   c                R    	 | j                   |   S # t        $ r t        |      w xY wr=   )rh   KeyErrorAttributeErrorr   s     r9   __getattr__zProperties.__getattr__   s/    	&::c?" 	& %%	&s    &c                    || j                   v S r=   rg   r   s     r9   __contains__zProperties.__contains__       djj  r;   c                ,    t        | j                        S )z8Return an immutable proxy for this :class:`.Properties`.)ReadOnlyPropertiesrh   rK   s    r9   as_readonlyzProperties.as_readonly   s     "$**--r;   c                :    | j                   j                  |       y r=   )rh   update)rL   rU   s     r9   r   zProperties.update   s    

% r;   c                     y r=   rb   r   s     r9   getzProperties.get   s    -0r;   c                     y r=   rb   rL   rT   defaults      r9   r   zProperties.get       HKr;   c                    || v r| |   S |S r=   rb   r   s      r9   r   zProperties.get   s     $;9Nr;   c                ,    t        | j                        S r=   )rw   rh   rK   s    r9   r}   zProperties.keys       DJJr;   c                H    t        | j                  j                               S r=   )rw   rh   rx   rK   s    r9   rx   zProperties.values   s    DJJ%%'((r;   c                H    t        | j                  j                               S r=   )rw   rh   itemsrK   s    r9   r   zProperties.items   s    DJJ$$&''r;   c                    || j                   v S r=   rg   r   s     r9   has_keyzProperties.has_key   r   r;   c                8    | j                   j                          y r=   )rh   clearrK   s    r9   r   zProperties.clear   s    

r;   )ro   ri   rY   intrY   Iterator[_T])rY   z	List[str])r7   zProperties[_F]rY   zList[Union[_T, _F]])rT   r]   r   r#   rY   r\   )rT   r]   rY   r#   )rT   r]   rY   r\   )rY   Dict[str, Any])r   r   rY   r\   )rT   r]   rY   bool)rY   zReadOnlyProperties[_T])rU   ri   rY   r\   )rT   r]   rY   zOptional[_T])rT   r]   r   Union[_DT, _T]rY   r   r=   )rT   r]   r   zOptional[Union[_DT, _T]]rY   zOptional[Union[_T, _DT]])rY   List[_T])rY   zList[Tuple[str, _T]]rY   r\   )r^   r_   r`   ra   	__slots____annotations__rp   rt   ry   r   r   rR   r   r   rn   r   r   r   r   r   r   r   r   r}   rx   r   r   r   __classcell__)r   s   @r9   rf   rf      s    BI0/B(%:&!.
! 0 0K K =A!9	! )(!r;   rf   c                      e Zd ZdZdZd Zy)OrderedPropertieszUProvide a __getattr__/__setattr__ interface with an OrderedDict
    as backing store.rb   c                @    t         j                  | t                      y r=   )rf   rp   OrderedDictrK   s    r9   rp   zOrderedProperties.__init__
  s    D+-0r;   N)r^   r_   r`   ra   r   rp   rb   r;   r9   r   r     s     I1r;   r   c                      e Zd ZdZdZy)r   zDProvide immutable dict/object attribute to an underlying dictionary.rb   N)r^   r_   r`   ra   r   rb   r;   r9   r   r     s
    NIr;   r   c                    t        | |      D cg c]	  }|| |   f }}| j                          | j                  |       yc c}w )zSort an OrderedDict in-place.)rT   N)sortedr   r   )r@   rT   r~   r   s       r9   _ordered_dictionary_sortr     s?     !'qc 231a1Y3E3GGIHHUO	 4s   Ac                  .    e Zd ZdddZd Zd Zd Zd Zy)	WeakSequencec                    t        j                  |       fd}|| _        |D cg c]  }t        j                  ||       c}| _        y c c}w )Nc                N     |       }||j                   j                  |        y y r=   )_storageremove)itemselfrefrL   s      r9   _removez&WeakSequence.__init__.<locals>._remove&  s&    9D$$T*  r;   )weakrefrefr   r   )rL   _WeakSequence__elementsr   r8   s       r9   rp   zWeakSequence.__init__#  sE     #*++d"3 	+
 9C
.5GKK)
 
s   A
c                v    | j                   j                  t        j                  || j                               y r=   )r   r0   r   r   r   )rL   r   s     r9   r0   zWeakSequence.append0  s#    W[[t||<=r;   c                ,    t        | j                        S r=   )rs   r   rK   s    r9   rt   zWeakSequence.__len__3  s    4==!!r;   c                6    d d | j                   D        D        S )Nc              3  &   K   | ]	  }||  y wr=   rb   ).0r   s     r9   	<genexpr>z(WeakSequence.__iter__.<locals>.<genexpr>7  s      
sC
s   c              3  *   K   | ]  } |         y wr=   rb   )r   r   s     r9   r   z(WeakSequence.__iter__.<locals>.<genexpr>8  s     ;cCE;s   )r   rK   s    r9   ry   zWeakSequence.__iter__6  s    
;T]];
 	
r;   c                f    	 | j                   |   } |       S # t        $ r t        d|z        w xY w)NzIndex %s out of range)r   r   
IndexError)rL   indexr   s      r9   r   zWeakSequence.__getitem__;  s@    	--&C 5L  	>4u<==	>s    0N)rb   )r   zSequence[_T])r^   r_   r`   rp   r0   rt   ry   r   rb   r;   r9   r   r   "  s    
>"

r;   r   c                      e Zd ZdddZy)OrderedIdentitySetNc                    t        j                  |        t               | _        |r|D ]  }| j	                  |        y y r=   )r   rp   r   _membersadd)rL   iterableos      r9   rp   zOrderedIdentitySet.__init__E  s;    T"#  r;   r=   )r   zOptional[Iterable[Any]])r^   r_   r`   rp   rb   r;   r9   r   r   D  s    r;   r   c                       e Zd ZdZddZddZy)PopulateDictzA dict which populates missing values via a creation function.

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

    c                    || _         y r=   creator)rL   r   s     r9   rp   zPopulateDict.__init__U  s	    r;   c                2    | j                  |      x| |<   }|S r=   r   rL   rT   vals      r9   __missing__zPopulateDict.__missing__X  s    ,,s++S	C
r;   N)r   zCallable[[_KT], _VT]rT   r   rY   r   r^   r_   r`   ra   rp   r   rb   r;   r9   r   r   M  s    r;   r   c                       e Zd ZdZddZddZy)WeakPopulateDictzaLike PopulateDict, but assumes a self + a method and does not create
    a reference cycle.

    c                r    |j                   | _        |j                  }t        j                  |      | _        y r=   )__func__r   __self__r   r   weakself)rL   creator_methodr   s      r9   rp   zWeakPopulateDict.__init__c  s*    %..!**H-r;   c                P    | j                  | j                         |      x| |<   }|S r=   )r   r   r   s      r9   r   zWeakPopulateDict.__missing__h  s&    ,,t}}<<S	C
r;   N)r   ztypes.MethodTyper   r   rb   r;   r9   r   r   ]  s    
.
r;   r   c                  V    e Zd ZU dZdZded<   ded<   ded<   	 d	 	 	 dd
ZddZddZy	)UniqueAppenderzAppends items to a collection ensuring uniqueness.

    Additional appends() of the same object are ignored.  Membership is
    determined by identity (``is a``) not equality (``==``).
    )ro   _data_appender_unique&Union[Iterable[_T], Set[_T], List[_T]]ro   zCallable[[_T], None]r   zDict[int, Literal[True]]r   Nc                    || _         i | _        |rt        ||      | _        y t	        |d      rt        d|      j                  | _        y t	        |d      rt        d|      j                  | _        y y )Nr0   r   r   zSet[_T])ro   r   getattrr   hasattrr   r0   r   )rL   ro   vias      r9   rp   zUniqueAppender.__init__  sg    
 	")$"4DT8$"&z4"8"?"?DT5!"&y$"7";";D "r;   c                x    t        |      }|| j                  vr!| j                  |       d| j                  |<   y y )NT)idr   r   )rL   r   id_s      r9   r0   zUniqueAppender.append  s8    hdll"% $DLL #r;   c                ,    t        | j                        S r=   )r.   ro   rK   s    r9   ry   zUniqueAppender.__iter__  s    DIIr;   r=   )ro   r   r   zOptional[str])r   r#   rY   r\   r   )	r^   r_   r`   ra   r   r   rp   r0   ry   rb   r;   r9   r   r   v  sF     4I
00((%%
 "<4< <%r;   r   c                    t        |       dk(  r+t        | d   t        j                        rt	        | d         S t        d|       S )Nr   r   	List[Any])rs   r?   typesGeneratorTyperw   r   )args    r9   coerce_generator_argr    s;    
3x1}CFE,?,?@CF|K%%r;   c                `    | |S t        |       s| gS t        | t              r| S t        |       S r=   )r   r?   rw   )xr   s     r9   to_listr    s3    y!!$s
	At	Awr;   c                ,     t         fd|D              S )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  @   K   | ]  }|j                   s|v   y wr=   )__hash__)r   iset_s     r9   r   z#has_intersection.<locals>.<genexpr>  s     9QajjqDy9s   	)any)r  r   s   ` r9   has_intersectionr    s     9(999r;   c                f    | 
t               S t        | t               st        t        |             S | S r=   )r,   r?   r  r  s    r9   to_setr    s+    yua71:r;   c                f    | 
t               S t        | t               st        t        |             S | S r=   )
column_setr?   r  r  s    r9   to_column_setr    s-    y|a$'!*%%r;   c                p    | j                         } |r| j                  |        | j                  di | | S )z5Copy the given dict and update with the given values.rb   )rM   r   )r@   _newkws      r9   update_copyr    s1     	
A	AHHNrNHr;   c              #     K   | D ]6  }t        |t              s t        |d      rt        |      E d{    3| 8 y7 w)zGiven an iterator of which further sub-elements may also be
    iterators, flatten the sub-elements into a single iterator.

    ry   N)r?   r]   r   flatten_iterator)r  elems     r9   r  r    s@       $$z)B'---J	-s   0A?Ac                      e Zd ZU dZdZded<   ded<   ded<   	 	 	 d	 	 	 	 	 dd
Zd Zedd       Z	edd       Z		 d	 	 	 	 	 ddZ	ddZ
ddZddZd dZd!dZd"dZed#d       Zd$dZy	)%LRUCachezDictionary 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_alertrh   _counter_mutexr   r  floatr   z.Optional[Callable[[LRUCache[_KT, _VT]], None]]r!  Nc                |    || _         || _        || _        d| _        t	        j
                         | _        i | _        y )Nr   )r  r   r!  r"  	threadingLockr#  rh   )rL   r  r   r!  s       r9   rp   zLRUCache.__init__  s5     !"$nn&<>
r;   c                D    | xj                   dz  c_         | j                   S Nr   )r"  rK   s    r9   _inc_counterzLRUCache._inc_counter  s    }}r;   c                     y r=   rb   r   s     r9   r   zLRUCache.get  s    .1r;   c                     y r=   rb   r   s      r9   r   zLRUCache.get  r   r;   c                v    | j                   j                  |      }|| j                         |d   d<   |d   S |S N   r   r   )rh   r   r*  )rL   rT   r   r   s       r9   r   zLRUCache.get  s@     zz~~c"**,DGAJ7NNr;   c                V    | j                   |   }| j                         |d   d<   |d   S r.  )rh   r*  )rL   rT   r   s      r9   r   zLRUCache.__getitem__  s.    zz#&&(Q
Awr;   c                ,    t        | j                        S r=   )r.   rh   rK   s    r9   ry   zLRUCache.__iter__  r   r;   c                ,    t        | j                        S r=   rr   rK   s    r9   rt   zLRUCache.__len__   ru   r;   c           	         t        j                  | j                  j                         D ci c]  \  }}||d    c}}      S c c}}w r)  )typingr   rh   r   )rL   r~   r  s      r9   rx   zLRUCache.values#  s:      djj6F6F6H!Ida!QqT'!IJJ!Is   A
c                f    ||| j                         gf| j                  |<   | j                          y r=   )r*  rh   _manage_sizerS   s      r9   rR   zLRUCache.__setitem__&  s.    (9(9(;'<=

3r;   c                    | j                   |= y r=   rg   )rL   _LRUCache__vs     r9   r   zLRUCache.__delitem__*  r   r;   c                N    | j                   | j                   | j                  z  z   S r=   )r  r   rK   s    r9   size_thresholdzLRUCache.size_threshold-  s    }}t}}t~~===r;   c                   | j                   j                  d      sy 	 t        | j                        }t	        |       | j
                  | j
                  | j                  z  z   kD  r|rd}| j                  |        t        | j                  j                         t        j                  d      d      }|| j
                  d  D ]  }	 | j                  |d   =  t	        |       | j
                  | j
                  | j                  z  z   kD  r| j                   j                          y # t        $ r Y ow xY w# | j                   j                          w xY w)NFr/  T)rT   reverser   )r#  acquirer   r!  rs   r  r   r   rh   rx   operator
itemgetterr   release)rL   r!  
by_counterr   s       r9   r6  zLRUCache._manage_size1  s   {{""5)	"doo.Jd)dmmdmmdnn.LLL!&JOOD)#JJ%%' ++A. 

 't}}7 !D! JJtAw/! d)dmmdmmdnn.LLL  KK!	 $ ! ! KK!s0   B'D5 D&4D5 &	D2/D5 1D22D5 5E)d   g      ?N)r  r   r   r$  r!  zOptional[Callable[..., None]])rT   r%   rY   zOptional[_VT])rT   r%   r   Union[_VT, _T]rY   rC  r=   )rT   r%   r   Optional[Union[_VT, _T]]rY   rD  )rT   r%   rY   r&   )rY   zIterator[_KT]r   )rY   zValuesView[_VT]r[   )r8  r%   rY   r\   )rY   r$  r   )r^   r_   r`   ra   r   r   rp   r*  r   r   r   ry   rt   rx   rR   r   propertyr:  r6  rb   r;   r9   r  r    s    I M>> 48	?? ? 2	? 1 1K K =A!9	!
 K > >"r;   r  c                      e Zd ZddZy)_CreateFuncTypec                     y r=   rb   rK   s    r9   __call__z_CreateFuncType.__call__J      r;   N)rY   r'   r^   r_   r`   rI  rb   r;   r9   rG  rG  I  s    $r;   rG  c                      e Zd ZddZy)_ScopeFuncTypec                     y r=   rb   rK   s    r9   rI  z_ScopeFuncType.__call__N  rJ  r;   NrZ   rK  rb   r;   r9   rM  rM  M  s    "r;   rM  c                  d    e Zd ZU dZdZded<   ded<   ded<   	 	 	 	 dd	Zdd
ZddZddZ	ddZ
y)ScopedRegistrya  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]rR  rM  rS  r   rT  c                .    || _         || _        i | _        y)aV  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).

        NrQ  )rL   rR  rS  s      r9   rp   zScopedRegistry.__init__f  s     %"r;   c                    | j                         }	 | j                  |   S # t        $ r- | j                  j                  || j	                               cY S w xY wr=   )rS  rT  r   
setdefaultrR  r   s     r9   rI  zScopedRegistry.__call__w  sR    nn	D==%% 	D==++C1BCC	Ds   ! 3AAc                :    | j                         | j                  v S )z9Return True if an object is present in the current scope.)rS  rT  rK   s    r9   haszScopedRegistry.has~  s     ~~4==00r;   c                >    || j                   | j                         <   y)z$Set the value for the current scope.N)rT  rS  rL   r   s     r9   r,   zScopedRegistry.set  s     +.dnn&'r;   c                Z    	 | j                   | j                         = y# t        $ r Y yw xY w)z Clear the current scope, if any.N)rT  rS  r   rK   s    r9   r   zScopedRegistry.clear  s,    	dnn./ 		s    	**N)rR  Callable[[], _T]rS  zCallable[[], Any]rY   r#   rY   r   r   r#   rY   r\   r   )r^   r_   r`   ra   r   r   rp   rI  rY  r,   r   rb   r;   r9   rP  rP  Q  sI     6I##M*7H"D1
.
r;   rP  c                  8    e Zd ZdZddZd	dZd
dZddZddZy)ThreadLocalRegistryz\A :class:`.ScopedRegistry` that uses a ``threading.local()``
    variable for storage.

    c                D    || _         t        j                         | _        y r=   )rR  r&  localrT  )rL   rR  s     r9   rp   zThreadLocalRegistry.__init__  s    $!)r;   c                    	 | j                   j                  S # t        $ r& | j                         x}| j                   _        |cY S w xY wr=   )rT  rU   r   rR  )rL   r   s     r9   rI  zThreadLocalRegistry.__call__  sC    	==&&& 	(,(99C$--%J	s    ,AAc                .    t        | j                  d      S )NrU   )r   rT  rK   s    r9   rY  zThreadLocalRegistry.has  s    t}}g..r;   c                &    || j                   _        y r=   )rT  rU   r[  s     r9   r,   zThreadLocalRegistry.set  s    !r;   c                <    	 | j                   `y # t        $ r Y y w xY wr=   )rT  rU   r   rK   s    r9   r   zThreadLocalRegistry.clear  s#    	# 		s    	N)rR  r]  r^  r_  r`  r   )	r^   r_   r`   ra   rp   rI  rY  r,   r   rb   r;   r9   rb  rb    s     
*/"r;   rb  c                8    d}| D ]  }||u s|dz  }|dkD  s y y)zrGiven a sequence and search object, return True if there's more
    than one, False if zero or one of them.


    r   r   TFrb   )sequencetargetcr   s       r9   	has_dupesrm    s7     	
A 6>FA1u	
 r;   )r2   r  r3   r  rY   r  )r@   zMapping[_KT, _VT]rY   zimmutabledict[_KT, _VT]r=   )r  r   rY   r  )r  r   r   zOptional[List[Any]]rY   r  )r  zContainer[Any]r   zIterable[Any]rY   r   )r  r   rY   zSet[Any])r  zIterable[_T]rY   r   )Wra   
__future__r   r>  r&  r  r4  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   rc   rd   rf   r   r   r   rO   r   sort_dictionaryr   r   r   r   r,   r  column_dictordered_column_setr   r  r  r  r  r  r  r  MutableMappingr  rG  rM  rP  rb  rm  rb   r;   r9   <module>ry     sj   & "                          $ *  	?;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&:
f"v$$S#X. f"R%huo %#X #=WR[ =@., <r;   