
    eN                       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ZddlmZ ddlmZ ddlmZ ddlmZ ej         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.            Z/d)e0d*<    e.dg          Z1d)e0d+<   dfd0Z2dgd4Z3 e"            Z4d5e0d6<    G d7 d8e%e+e,f                   Z5 ed9e#          Z6 ed:e#          Z7 G d; d<ee*                   Z8 G d= d>e8e*                   Z9 G d? d@e$e8e*                   Z:dhdAZ;e<Z=e;Z> G dB dCee*                   Z? G dD dEe#          Z@ G dF dGe
e+e,f                   ZA G dH dIe
e+e,f                   ZBeCZDe<ZEe&ZF G dJ dKee*                   ZGdidNZHdhdjdRZIdS ZJdT ZKdkdVZLdhdWZMdldZZN G d[ d\ejO        e+e,f                   ZP G d] d^ee-                   ZQ G d_ d`e          ZR G da dbee*                   ZS G dc ddeSe*                   ZTde ZUdS )mzCollection classes and helpers.    )annotationsN)Any)Callable)cast)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_SETa	List[Any]breturnc                ,   t          |                               |          }g }t          |           t          |          }}	 |D ]6}||v r|                    |           ||}} n,|                    |           7|                    |           nP|S )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)r*   r,   overlapresultcurrentotherelements          <lib/python3.11/site-packages/sqlalchemy/util/_collections.pymerge_lists_w_orderingr;   K   s    F !ff!!!$$GF!WWd1ggUG
 		 		G'!!(((!(%wMM'""""MM%   
 M    dMapping[_KT, _VT]immutabledict[_KT, _VT]c                `    | st           S t          | t                    r| S t          |           S N)
EMPTY_DICT
isinstancer   )r=   s    r:   coerce_to_immutabledictrD      s5      	A}	%	%  Qr<   zimmutabledict[Any, Any]rB   c                  :    e Zd ZdZddZddZdd	ZddZddZdS )
FacadeDictz*A dictionary that is not publicly mutable.argsr   r-   FacadeDict[Any, Any]c                .    t          j        |           }|S rA   )r   __new__)clsrG   news      r:   rJ   zFacadeDict.__new__   s    ',,
r<   r   c                     t          d          )Nz\an immutabledict shouldn't need to be copied.  use dict(d) if you need a mutable dictionary.)NotImplementedErrorselfs    r:   copyzFacadeDict.copy   s    !0
 
 	
r<   c                0    t           t          |           ffS rA   )rF   dictrO   s    r:   
__reduce__zFacadeDict.__reduce__   s    DJJ=((r<   keyr$   valuer%   Nonec                >    t                               | ||           dS )z,insert an item into the dictionary directly.N)rS   __setitem__rP   rU   rV   s      r:   _insert_itemzFacadeDict._insert_item   s     sE*****r<   strc                <    dt                               |           z  S )NzFacadeDict(%s))rS   __repr__rO   s    r:   r^   zFacadeDict.__repr__   s    $--"5"555r<   N)rG   r   r-   rH   )r-   r   r-   r   rU   r$   rV   r%   r-   rW   )r-   r\   )	__name__
__module____qualname____doc__rJ   rQ   rT   r[   r^    r<   r:   rF   rF      s~        44   
 
 
 
) ) ) )+ + + +6 6 6 6 6 6r<   rF   _DT_Fc                      e Zd ZU dZdZded<   d6dZd7d	Zd8dZd9 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dAd#ZdBd%ZedCd'            ZedDd*            Z	 dEdFd.Zd9d/ZdGd1ZdHd3Zd@d4ZdId5Z xZS )J
Propertiesz8Provide a __getattr__/__setattr__ interface over a dict._dataDict[str, _T]rk   datac                >    t                               | d|           d S Nrk   object__setattr__)rP   rm   s     r:   __init__zProperties.__init__   s     4$/////r<   r-   intc                *    t          | j                  S rA   lenrk   rO   s    r:   __len__zProperties.__len__       4:r<   Iterator[_T]c                h    t          t          | j                                                            S rA   )r1   listrk   valuesrO   s    r:   __iter__zProperties.__iter__   s&    D**,,--...r<   	List[str]c                    t          t                                d | j                                        D             z   S )Nc                ,    g | ]}t          |          S re   )r\   ).0ks     r:   
<listcomp>z&Properties.__dir__.<locals>.<listcomp>   s    AAA!s1vvAAAr<   )dirsuperrk   keys)rP   	__class__s    r:   __dir__zProperties.__dir__   s3    577||AAtz/@/@AAAAAr<   r8   Properties[_F]List[Union[_T, _F]]c                @    t          |           t          |          z   S rA   )r|   )rP   r8   s     r:   __add__zProperties.__add__   s    DzzDKK''r<   rU   r\   objr"   rW   c                    || j         |<   d S rA   rj   rP   rU   r   s      r:   rY   zProperties.__setitem__       
3r<   c                    | j         |         S rA   rj   rP   rU   s     r:   __getitem__zProperties.__getitem__   s    z#r<   c                    | j         |= d S rA   rj   r   s     r:   __delitem__zProperties.__delitem__       JsOOOr<   c                    || j         |<   d S rA   rj   r   s      r:   rr   zProperties.__setattr__   r   r<   Dict[str, Any]c                    d| j         iS ro   rj   rO   s    r:   __getstate__zProperties.__getstate__   s    $$r<   statec                J    t                               | d|d                    d S ro   rp   )rP   r   s     r:   __setstate__zProperties.__setstate__   s$    4%.99999r<   c                X    	 | j         |         S # t          $ r t          |          w xY wrA   )rk   KeyErrorAttributeErrorr   s     r:   __getattr__zProperties.__getattr__   s<    	&:c?" 	& 	& 	& %%%	&s    )boolc                    || j         v S rA   rj   r   s     r:   __contains__zProperties.__contains__       dj  r<   ReadOnlyProperties[_T]c                *    t          | j                  S )z8Return an immutable proxy for this :class:`.Properties`.)ReadOnlyPropertiesrk   rO   s    r:   as_readonlyzProperties.as_readonly   s     "$*---r<   rV   c                :    | j                             |           d S rA   )rk   update)rP   rV   s     r:   r   zProperties.update   s    
%     r<   Optional[_T]c                    d S rA   re   r   s     r:   getzProperties.get       r<   defaultUnion[_DT, _T]c                    d S rA   re   rP   rU   r   s      r:   r   zProperties.get   r   r<   NOptional[Union[_DT, _T]]Optional[Union[_T, _DT]]c                    || v r| |         S |S rA   re   r   s      r:   r   zProperties.get   s     $;;9Nr<   c                *    t          | j                  S rA   )r|   rk   rO   s    r:   r   zProperties.keys       DJr<   List[_T]c                N    t          | j                                                  S rA   )r|   rk   r}   rO   s    r:   r}   zProperties.values   s    DJ%%''(((r<   List[Tuple[str, _T]]c                N    t          | j                                                  S rA   )r|   rk   itemsrO   s    r:   r   zProperties.items   s    DJ$$&&'''r<   c                    || j         v S rA   rj   r   s     r:   has_keyzProperties.has_key   r   r<   c                8    | j                                          d S rA   )rk   clearrO   s    r:   r   zProperties.clear  s    
r<   )rm   rl   r-   rt   r-   rz   )r-   r   )r8   r   r-   r   )rU   r\   r   r"   r-   rW   )rU   r\   r-   r"   )rU   r\   r-   rW   )r-   r   )r   r   r-   rW   )rU   r\   r-   r   )r-   r   )rV   rl   r-   rW   )rU   r\   r-   r   )rU   r\   r   r   r-   r   rA   )rU   r\   r   r   r-   r   )r-   r   )r-   r   r-   rW   )ra   rb   rc   rd   	__slots____annotations__rs   rx   r~   r   r   rY   r   r   rr   r   r   r   r   r   r   r   r   r   r}   r   r   r   __classcell__)r   s   @r:   ri   ri      s7        BBI0 0 0 0   / / / /B B B B B B( ( ( (            % % % %: : : :& & & &! ! ! !. . . .
! ! ! !    X    X =A           ) ) ) )( ( ( (! ! ! !       r<   ri   c                      e Zd ZdZdZd ZdS )OrderedPropertieszUProvide a __getattr__/__setattr__ interface with an OrderedDict
    as backing store.re   c                T    t                               | t                                 d S rA   )ri   rs   OrderedDictrO   s    r:   rs   zOrderedProperties.__init__  s"    D+--00000r<   N)ra   rb   rc   rd   r   rs   re   r<   r:   r   r     s4          I1 1 1 1 1r<   r   c                      e Zd ZdZdZdS )r   zDProvide immutable dict/object attribute to an underlying dictionary.re   N)ra   rb   rc   rd   r   re   r<   r:   r   r     s        NNIIIr<   r   c                      fdt           |          D             }                                                       |           dS )zSort an OrderedDict in-place.c                $    g | ]}||         fS re   re   )r   r   r=   s     r:   r   z,_ordered_dictionary_sort.<locals>.<listcomp>  s!    3331a1Y333r<   )rU   N)sortedr   r   )r=   rU   r   s   `  r:   _ordered_dictionary_sortr     sK     4333qc 2 2 2333EGGIIIHHUOOOOOr<   c                  0    e Zd Zd
ddZd Zd Zd Zd Zd	S )WeakSequencere   _WeakSequence__elementsSequence[_T]c                j    t          j        |           fd| _        fd|D             | _        d S )Nc                V     |            }||j                             |            d S d S rA   )_storageremove)itemselfrefrP   s      r:   _removez&WeakSequence.__init__.<locals>._remove'  s7    799D$$T*****  r<   c                :    g | ]}t          j        |          S re   )weakrefref)r   r9   r   s     r:   r   z)WeakSequence.__init__.<locals>.<listcomp>-  s2     
 
 
.5GK))
 
 
r<   )r   r   r   r   )rP   r   r   s     @r:   rs   zWeakSequence.__init__$  s]     #*+d"3"3 	+ 	+ 	+ 	+
 
 
 
 
9C
 
 
r<   c                j    | j                             t          j        || j                             d S rA   )r   r3   r   r   r   )rP   r   s     r:   r3   zWeakSequence.append1  s,    W[t|<<=====r<   c                *    t          | j                  S rA   )rw   r   rO   s    r:   rx   zWeakSequence.__len__4  s    4=!!!r<   c                8    d d | j         D             D             S )Nc              3     K   | ]}||V  	d S rA   re   )r   r   s     r:   	<genexpr>z(WeakSequence.__iter__.<locals>.<genexpr>8  s+       
 
sC
 
r<   c              3  *   K   | ]} |            V  d S rA   re   )r   r   s     r:   r   z(WeakSequence.__iter__.<locals>.<genexpr>9  s(      ;;cCCEE;;;;;;r<   )r   rO   s    r:   r~   zWeakSequence.__iter__7  s3    
 
;;T];;;
 
 
 	
r<   c                r    	 | j         |         } |            S # t          $ r t          d|z            w xY w)NzIndex %s out of range)r   r   
IndexError)rP   indexr   s      r:   r   zWeakSequence.__getitem__<  sQ    	-&C 355L  	> 	> 	>4u<===	>s    6N)re   )r   r   )ra   rb   rc   rs   r3   rx   r~   r   re   r<   r:   r   r   #  si        
 
 
 
 
> > >" " "
 
 

    r<   r   c                      e Zd ZdddZdS )OrderedIdentitySetNiterableOptional[Iterable[Any]]c                    t          j        |            t                      | _        |r|D ]}|                     |           d S d S rA   )r   rs   r   _membersadd)rP   r   os      r:   rs   zOrderedIdentitySet.__init__F  sZ    T"""# 	  	 	 r<   rA   )r   r   )ra   rb   rc   rs   re   r<   r:   r   r   E  s-              r<   r   c                  "    e Zd ZdZd
dZddZd	S )PopulateDictzA dict which populates missing values via a creation function.

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

    creatorCallable[[_KT], _VT]c                    || _         d S rA   r   )rP   r   s     r:   rs   zPopulateDict.__init__V  s    r<   rU   r   r-   c                :    |                      |          x| |<   }|S rA   r   rP   rU   vals      r:   __missing__zPopulateDict.__missing__Y  s!    ,,s+++S	C
r<   N)r   r   rU   r   r-   r   ra   rb   rc   rd   rs   r   re   r<   r:   r   r   N  sF                 r<   r   c                  "    e Zd ZdZd
dZddZd	S )WeakPopulateDictzaLike PopulateDict, but assumes a self + a method and does not create
    a reference cycle.

    creator_methodtypes.MethodTypec                ^    |j         | _        |j        }t          j        |          | _        d S rA   )__func__r   __self__r   r   weakself)rP   r   r  s      r:   rs   zWeakPopulateDict.__init__d  s)    %.!*H--r<   rU   r   r-   c                `    |                      |                                 |          x| |<   }|S rA   )r   r  r   s      r:   r   zWeakPopulateDict.__missing__i  s+    ,,t}}<<<S	C
r<   N)r   r   r   r   re   r<   r:   r   r   ^  sF         
. . . .
     r<   r   c                  R    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d	S )UniqueAppenderzAppends items to a collection ensuring uniqueness.

    Additional appends() of the same object are ignored.  Membership is
    determined by identity (``is a``) not equality (``==``).
    )rm   _data_appender_unique&Union[Iterable[_T], Set[_T], List[_T]]rm   zCallable[[_T], None]r  zDict[int, Literal[True]]r	  NviaOptional[str]c                   || _         i | _        |rt          ||          | _        d S t	          |d          rt          d|          j        | _        d S t	          |d          rt          d|          j        | _        d S d S )Nr3   r   r   zSet[_T])rm   r	  getattrr  hasattrr   r3   r   )rP   rm   r  s      r:   rs   zUniqueAppender.__init__  s    
 	 	<")$"4"4DT8$$ 	<"&z4"8"8"?DT5!! 	<"&y$"7"7";D	< 	<r<   r   r"   r-   rW   c                x    t          |          }|| j        vr!|                     |           d| j        |<   d S d S )NT)idr	  r  )rP   r   id_s      r:   r3   zUniqueAppender.append  sH    hhdl""%%% $DL #"r<   rz   c                *    t          | j                  S rA   )r1   rm   rO   s    r:   r~   zUniqueAppender.__iter__  s    DIr<   rA   )rm   r
  r  r  )r   r"   r-   rW   r   )	ra   rb   rc   rd   r   r   rs   r3   r~   re   r<   r:   r  r  w  s           4I0000((((%%%%
 "< < < < <% % % %     r<   r  argr   c                    t          |           dk    r5t          | d         t          j                  rt	          | d                   S t          d|           S )Nr   r   r+   )rw   rC   typesGeneratorTyper|   r   )r  s    r:   coerce_generator_argr    sF    
3xx1}}CFE,?@@}CF||K%%%r<   xr   Optional[List[Any]]c                z    | |S t          |           s| gS t          | t                    r| S t          |           S rA   )r   rC   r|   )r  r   s     r:   to_listr    sE    y!!$$ s
	At		 Awwr<   c                Z    t          |                     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                     g | ]}|j         	|S re   )__hash__)r   is     r:   r   z$has_intersection.<locals>.<listcomp>  s    "E"E"E!*"E1"E"E"Er<   )r   r0   )set_r   s     r:   has_intersectionr"    s/     !!"E"Eh"E"E"EFFGGGr<   c                    | t                      S t          | t                     st          t          |                     S | S rA   )r/   rC   r  r  s    r:   to_setr%    s9    yuua 71::r<   Set[Any]c                    | t                      S t          | t                     st          t          |                     S | S rA   )
column_setrC   r  r$  s    r:   to_column_setr)    s<    y||a$$ '!**%%%r<   c                v    |                                  } |r|                     |            | j        di | | S )z5Copy the given dict and update with the given values.re   )rQ   r   )r=   _newkws      r:   update_copyr-    s@     	
A 	AHNNrNNNHr<   Iterable[_T]rz   c              #     K   | D ]A}t          |t                    s&t          |d          rt          |          E d{V  =|V  BdS )zGiven an iterator of which further sub-elements may also be
    iterators, flatten the sub-elements into a single iterator.

    r~   N)rC   r\   r  flatten_iterator)r  elems     r:   r0  r0    sr         $$$ 	z)B)B 	'----------JJJJ	 r<   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d0dZd1d"Zd2d$Zed3d%            Zd4d&ZdS )5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_alertrk   _counter_mutexrt   r4  floatr5  z.Optional[Callable[[LRUCache[_KT, _VT]], None]]r6  d         ?NOptional[Callable[..., None]]c                |    || _         || _        || _        d| _        t	          j                    | _        i | _        d S )Nr   )r4  r5  r6  r7  	threadingLockr8  rk   )rP   r4  r5  r6  s       r:   rs   zLRUCache.__init__  s:     !"$n&&<>


r<   c                0    | xj         dz  c_         | j         S )Nr   )r7  rO   s    r:   _inc_counterzLRUCache._inc_counter  s    }r<   rU   r$   r-   Optional[_VT]c                    d S rA   re   r   s     r:   r   zLRUCache.get
  r   r<   r   Union[_VT, _T]c                    d S rA   re   r   s      r:   r   zLRUCache.get  r   r<   Optional[Union[_VT, _T]]c                    | j                             |          }|%|                                 |d         d<   |d         S |S N   r   r   )rk   r   rA  )rP   rU   r   r   s       r:   r   zLRUCache.get  sD     z~~c""**,,DGAJ7NNr<   r%   c                f    | j         |         }|                                 |d         d<   |d         S rH  )rk   rA  )rP   rU   r   s      r:   r   zLRUCache.__getitem__  s/    z#&&((Q
Awr<   Iterator[_KT]c                *    t          | j                  S rA   )r1   rk   rO   s    r:   r~   zLRUCache.__iter__!  r   r<   c                *    t          | j                  S rA   rv   rO   s    r:   rx   zLRUCache.__len__$  ry   r<   ValuesView[_VT]c                l    t          j        d | j                                        D                       S )Nc                &    i | ]\  }}||d          S )r   re   )r   r   r   s      r:   
<dictcomp>z#LRUCache.values.<locals>.<dictcomp>(  s"    !I!I!Ida!QqT!I!I!Ir<   )typingr   rk   r   rO   s    r:   r}   zLRUCache.values'  s0     !I!Idj6F6F6H6H!I!I!IJJJr<   rV   rW   c                n    |||                                  gf| j        |<   |                                  d S rA   )rA  rk   _manage_sizerZ   s      r:   rY   zLRUCache.__setitem__*  s;    (9(9(;(;'<=
3r<   _LRUCache__vc                    | j         |= d S rA   rj   )rP   rU  s     r:   r   zLRUCache.__delitem__.  r   r<   c                0    | j         | j         | j        z  z   S rA   )r4  r5  rO   s    r:   size_thresholdzLRUCache.size_threshold1  s    }t}t~===r<   c                   | j                             d          sd S 	 t          | j                  }t	          |           | j        | j        | j        z  z   k    r|rd}|                     |            t          | j        	                                t          j        d          d          }|| j        d          D ]!}	 | j        |d         = # t          $ r Y w xY wt	          |           | j        | j        | j        z  z   k    | j                                          d S # | j                                          w xY w)NFrI  T)rU   reverser   )r8  acquirer   r6  rw   r4  r5  r   rk   r}   operator
itemgetterr   release)rP   r6  
by_counterr   s       r:   rT  zLRUCache._manage_size5  sT   {""5)) 	F	"do..Jd))dmdmdn.LLLL *!&JOOD)))#J%%'' +A..   

 't}7 ! !D! JtAw//# ! ! ! ! d))dmdmdn.LLLL  K!!!!!DK!!!!s0   B!D"  CD" 
CD" C+D" "D=)r:  r;  N)r4  rt   r5  r9  r6  r<  )rU   r$   r-   rB  )rU   r$   r   rD  r-   rD  rA   )rU   r$   r   rF  r-   rF  )rU   r$   r-   r%   )r-   rK  r   )r-   rN  r`   )rU  r$   r-   rW   )r-   r9  r   )ra   rb   rc   rd   r   r   rs   rA  r   r   r   r~   rx   r}   rY   r   propertyrX  rT  re   r<   r:   r3  r3    s         I MMM>>>> 48	? ? ? ? ?      X    X =A       
          K K K K       > > > X>" " " " " "r<   r3  c                      e Zd ZddZdS )_CreateFuncTyper-   r&   c                    d S rA   re   rO   s    r:   __call__z_CreateFuncType.__call__N      r<   N)r-   r&   ra   rb   rc   rd  re   r<   r:   rb  rb  M  (             r<   rb  c                      e Zd ZddZdS )_ScopeFuncTyper-   r   c                    d S rA   re   rO   s    r:   rd  z_ScopeFuncType.__call__S  re  r<   Nr_   rf  re   r<   r:   ri  ri  R  rg  r<   ri  c                  ^    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
dS )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]rn  ri  ro  r   rp  Callable[[], _T]Callable[[], Any]c                0    || _         || _        i | _        dS )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).

        Nrm  )rP   rn  ro  s      r:   rs   zScopedRegistry.__init__l  s     %"r<   r-   r"   c                    |                                  }	 | j        |         S # t          $ r0 | j                            ||                                           cY S w xY wrA   )ro  rp  r   
setdefaultrn  r   s     r:   rd  zScopedRegistry.__call__}  sk    nn	D=%% 	D 	D 	D=++C1B1BCCCCC	Ds   # 7AAr   c                8    |                                  | j        v S )z9Return True if an object is present in the current scope.)ro  rp  rO   s    r:   haszScopedRegistry.has  s     ~~4=00r<   r   rW   c                >    || j         |                                 <   dS )z$Set the value for the current scope.N)rp  ro  rP   r   s     r:   r/   zScopedRegistry.set  s      +.dnn&&'''r<   c                ^    	 | j         |                                 = dS # t          $ r Y dS w xY w)z Clear the current scope, if any.N)rp  ro  r   rO   s    r:   r   zScopedRegistry.clear  sC    	dnn../// 	 	 	DD	s    
,,N)rn  rq  ro  rr  r-   r"   r-   r   r   r"   r-   rW   r   )ra   rb   rc   rd   r   r   rs   rd  rw  r/   r   re   r<   r:   rl  rl  W  s           6I####MMM   "D D D D1 1 1 1
. . . .
     r<   rl  c                  :    e Zd ZdZddZddZdd	ZddZddZdS )ThreadLocalRegistryz\A :class:`.ScopedRegistry` that uses a ``threading.local()``
    variable for storage.

    rn  rq  c                D    || _         t          j                    | _        d S rA   )rn  r>  localrp  )rP   rn  s     r:   rs   zThreadLocalRegistry.__init__  s    $!))r<   r-   r"   c                    	 | j         j        S # t          $ r% |                                 x}| j         _        |cY S w xY wrA   )rp  rV   r   rn  )rP   r   s     r:   rd  zThreadLocalRegistry.__call__  sO    	=&& 	 	 	(,(9(99C$-%JJJ	s    ,==r   c                ,    t          | j        d          S )NrV   )r  rp  rO   s    r:   rw  zThreadLocalRegistry.has  s    t}g...r<   r   rW   c                    || j         _        d S rA   )rp  rV   ry  s     r:   r/   zThreadLocalRegistry.set  s    !r<   c                8    	 | j         `d S # t          $ r Y d S w xY wrA   )rp  rV   r   rO   s    r:   r   zThreadLocalRegistry.clear  s7    	### 	 	 	DD	s    
N)rn  rq  r{  r|  r}  r   )	ra   rb   rc   rd   rs   rd  rw  r/   r   re   r<   r:   r  r    s         
* * * *   / / / /" " " "     r<   r  c                8    d}| D ]}||u r|dz  }|dk    r dS dS )zrGiven a sequence and search object, return True if there's more
    than one, False if zero or one of them.


    r   r   TFre   )sequencetargetcr   s       r:   	has_dupesr    s@     	
A  6>>FA1uutt5r<   )r*   r+   r,   r+   r-   r+   )r=   r>   r-   r?   rA   )r  r   r-   r+   )r  r   r   r  r-   r+   )r  r   r-   r&  )r  r.  r-   rz   )Vrd   
__future__r   r\  r>  r  rR  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;   rD   rB   rF   rf   rg   ri   r   r   r   rS   r   sort_dictionaryr   r   r   r   r/   r(  column_dictordered_column_setr  r  r  r"  r%  r)  r-  r0  MutableMappingr3  rb  ri  rl  r  r  re   r<   r:   <module>r     s   & % % " " " " " "                                                                                                                           $ $ $ $ $ $ * * * * * *            	  ??????;;;;;;GGGGGGGGGGGG999999;;;;;;;                NMMMMMKKKKKK     
 WTge3ge34(((%IKK	 ' ' ' '$9dV,, , , , ,5 5 5 5p        '4moo
 5 5 5 56 6 6 6 6"38, 6 6 60 ge3WTV V V V V V V Vr1 1 1 1 1
2 1 1 1    *JrN       *    8B<   D           4S>        tCH~   ( 
 " " " " "WR[ " " "J& & & &    H H H        
 
 
 
h" h" h" h" h"v$S#X. h" h" h"V    huo   
    X   
= = = = =WR[ = = =@    .,   <    r<   