
    [hEG                    v   U d 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 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 erddlmZ ddlmZ e	e ef         Z!ej"        Z#de$d<    G d d e          Z% G d! d"e%          Z& G d# d$e&          Z' G d% d&e%          Z(i Z)d'e$d(<    ed)d *          Z*dKd/Z+	 dLd0d0dd1dMd:Z,e	 dLdNd>            Z-e	 dLdOd?            Z-	 dLdPdAZ-dQdBZ.dRdGZ/dSdJZ0dS )Ta*  The :class:`.Annotated` class and related routines; creates hash-equivalent
copies of SQL constructs which contain context-specific markers and
associations.

Note that the :class:`.Annotated` concept as implemented in this module is not
related in any way to the pep-593 concept of "Annotated".


    )annotationsN)Any)Callable)cast)Dict)	FrozenSet)Mapping)Optional)overload)Sequence)Tuple)Type)TYPE_CHECKING)TypeVar   )	operators)HasCacheKey)anon_map)ExternallyTraversible)InternalTraversal   )util)Literal)Self)_EntityNamespace)_TraverseInternalsTypeutil.immutabledict[str, Any]EMPTY_ANNOTATIONSc                      e Zd ZU dZeZded<   ded<   ded<   ddZe	 	 ddd            Z	e	 	 ddd            Z		 	 dd dZ	e
j        d!d            Zd"dZdS )#SupportsAnnotations r   _annotationsz*util.generic_fn_descriptor[FrozenSet[Any]]	proxy_setbool_is_immutablevalues_AnnotationDictreturnr   c                    t                      NNotImplementedErrorselfr&   s     h/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/sql/annotation.py	_annotatezSupportsAnnotations._annotate>   s    !###    .Literal[None]clonec                    d S r*   r!   r.   r&   r3   s      r/   _deannotatezSupportsAnnotations._deannotateA   	    
 sr1   Sequence[str]c                    d S r*   r!   r5   s      r/   r6   zSupportsAnnotations._deannotateH   	    
 "cr1   NFOptional[Sequence[str]]c                    t                      r*   r+   r5   s      r/   r6   zSupportsAnnotations._deannotateO   s    
 "###r1   Tuple[Any, ...]c                H    t                      }|                     |          S r*   )r   _gen_annotations_cache_key)r.   	anon_map_s     r/   _annotations_cache_keyz*SupportsAnnotations._annotations_cache_keyV   s    JJ	..y999r1   r   c                |     dt          fd fdt           j                  D             D                       fS )Nr"   c              3  |   K   | ]6\  }}|t          |t                    r|                    g           n|fV  7d S r*   )
isinstancer   _gen_cache_key).0keyvaluer   s      r/   	<genexpr>zASupportsAnnotations._gen_annotations_cache_key.<locals>.<genexpr>a   sn         C  &e[99#,,Xr:::"     r1   c                .    g | ]}|j         |         fS r!   )r"   )rF   rG   r.   s     r/   
<listcomp>zBSupportsAnnotations._gen_annotations_cache_key.<locals>.<listcomp>j   s6     # # # $+C01# # #r1   )tuplesortedr"   )r.   r   s   ``r/   r?   z.SupportsAnnotations._gen_annotations_cache_key\   st         # # # #%d&788# # #    
 	
r1   r&   r'   r(   r   ..r&   r2   r3   r$   r(   r   r&   r8   r3   r$   r(   r    NFr&   r;   r3   r$   r(   r    )r(   r=   )r   r   r(   r=   )__name__
__module____qualname__	__slots__r   r"   __annotations__r0   r   r6   r   memoized_propertyrA   r?   r!   r1   r/   r    r    5   s        I1BLBBBB9999$ $ $ $  !$    X  !$" " " " X" +/$ $ $ $ $ 
: : : :

 
 
 
 
 
r1   r    c                      e Zd ZU dZded<   erej        dd            Zdd
Z	ddZ
e	 	 ddd            Ze	 	 ddd            Z	 	 dddZdS )SupportsWrappingAnnotationsr!   z*Callable[..., SupportsWrappingAnnotations]_constructorr(   r   c                    d S r*   r!   r.   s    r/   entity_namespacez,SupportsWrappingAnnotations.entity_namespacey   s    8;r1   r&   r'   r   c                8    t                               | |          S )greturn a copy of this ClauseElement with annotations
        updated by the given dictionary.

        	Annotated_as_annotated_instancer-   s     r/   r0   z%SupportsWrappingAnnotations._annotate|       
 //f===r1   c                8    t                               | |          S )hreturn a copy of this ClauseElement with annotations
        replaced by the given dictionary.

        rb   r-   s     r/   _with_annotationsz-SupportsWrappingAnnotations._with_annotations   re   r1   .r2   r3   r$   c                    d S r*   r!   r5   s      r/   r6   z'SupportsWrappingAnnotations._deannotate   r7   r1   r8   r    c                    d S r*   r!   r5   s      r/   r6   z'SupportsWrappingAnnotations._deannotate   r:   r1   NFr;   c                6    |r|                                  }|S | S )return a copy of this :class:`_expression.ClauseElement`
        with annotations
        removed.

        :param values: optional tuple of individual values
         to remove.

        )_clone)r.   r&   r3   ss       r/   r6   z'SupportsWrappingAnnotations._deannotate   s#      	AHKr1   r(   r   rN   rO   rP   rQ   rR   rS   )rT   rU   rV   rW   rX   r   r   ro_non_memoized_propertyr_   r0   rh   r   r6   r!   r1   r/   r[   r[   r   s         I<<<< <		&;;; 
'	&;> > > >> > > >  !$    X  !$" " " " X" +/      r1   r[   c                      e Zd ZU ej        sdZdej        fgZde	d<   dd	Z
dd
Ze	 	 ddd            Ze	 	 ddd            Z	 	 dddZdS )SupportsCloneAnnotationsr!   r"   r   %_clone_annotations_traverse_internalsr&   r'   r(   r   c                    |                                  }|j                            |          |_        |j                            dd           |j                            dd           |S )ra   rA   N_generate_cache_key)rm   r"   union__dict__popr.   r&   news      r/   r0   z"SupportsCloneAnnotations._annotate   sa    
 kkmm+11&9914888.555
r1   c                    |                                  }t          j        |          |_        |j                            dd           |j                            dd           |S )rg   rA   Nru   )rm   r   immutabledictr"   rw   rx   ry   s      r/   rh   z*SupportsCloneAnnotations._with_annotations   s[    
 kkmm-f5514888.555
r1   .r2   r3   r$   c                    d S r*   r!   r5   s      r/   r6   z$SupportsCloneAnnotations._deannotate   r7   r1   r8   r    c                    d S r*   r!   r5   s      r/   r6   z$SupportsCloneAnnotations._deannotate   r:   r1   NFr;   c                    |s| j         rI|                                 }t          j                    |_         |j                            dd           |S | S )rl   rA   N)r"   rm   r   r|   rw   rx   )r.   r&   r3   rz   s       r/   r6   z$SupportsCloneAnnotations._deannotate   sY      	D% 	 ++--C#133CL5t<<<JKr1   rN   rO   rP   rQ   rR   rS   )rT   rU   rV   typingr   rW   r   dp_annotations_keyrs   rX   r0   rh   r   r6   r!   r1   r/   rr   rr      s           	 
*=>E)    	 	 	 		 	 	 	  !$    X  !$" " " " X" +/      r1   rr   c                  &   e Zd ZU dZdZed/d            Zd	ed
<   ded<   ded<   d0dZd1dZ	d2dZ
d2dZe	 	 d3d4d            Ze	 	 d3d5d            Z	 	 d6d7d"Zej        sd8d%Zed&             Zd9d'Zd:d)Zd;d*Zd<d,Zej        d=d.            ZdS )>rc   aJ  clones a SupportsAnnotations and applies an 'annotations' dictionary.

    Unlike regular clones, this clone also mimics __hash__() and
    __eq__() of the original element so that it takes its place
    in hashed collections.

    A reference to the original element is maintained, for the important
    reason of keeping its hash value current.  When GC'ed, the
    hash value may be reused, causing conflicts.

    .. note::  The rationale for Annotated producing a brand new class,
       rather than placing the functionality directly within ClauseElement,
       is **performance**.  The __hash__() method is absent on plain
       ClauseElement which leads to significantly reduced function call
       overhead, as the use of sets and dictionaries against ClauseElement
       objects is prevalent, but most are not "annotated".

    Felementr[   r&   r'   r(   c                    	 t           |j                 } n%# t          $ r t          |j        |           } Y nw xY w | ||          S r*   )annotated_classes	__class__KeyError_new_annotation_type)clsr   r&   s      r/   rd   z Annotated._as_annotated_instance  sY    	?#G$56CC 	? 	? 	?&w'8#>>CCC	?s7F###s    77r   r"   _Annotated__elementint_hashr   
Type[Self]argsr   r   c                6    t                               |           S r*   )object__new__)r   r   s     r/   r   zAnnotated.__new__  s    ~~c"""r1   c                   |j                                         | _         | j                             dd            | j                             dd            || _        t	          j        |          | _        t          |          | _        d S NrA   ru   )	rw   copyrx   r   r   r|   r"   hashr   )r.   r   r&   s      r/   __init__zAnnotated.__init__  sw      (--//2D999/666  .v66']]


r1   c                d    | j                             |          }|                     |          }|S r*   )r"   rv   rh   )r.   r&   _valuesrz   s       r/   r0   zAnnotated._annotate(  s0    #))&11$$W--
r1   c                   | j                             | j                   }| j                                        |_        |j                            dd            |j                            dd            t          j        |          |_        |S r   )r   r   rw   r   rx   r   r|   r"   r5   s      r/   rh   zAnnotated._with_annotations-  sx    &&t~66++--3T:::0$777!/77r1   .r2   r3   r$   c                    d S r*   r!   r5   s      r/   r6   zAnnotated._deannotate5  r7   r1   r8   c                    d S r*   r!   r5   s      r/   r6   zAnnotated._deannotate<  s	    
 Cr1   NTr;   r    c                    | j         S |                     t          j        fd| j                                        D                                 S )Nc                $    i | ]\  }}|v	||S r!   r!   )rF   rG   rH   r&   s      r/   
<dictcomp>z)Annotated._deannotate.<locals>.<dictcomp>M  s4       &Cf,, U,,,r1   )r   rh   r   r|   r"   itemsr5   s    ` r/   r6   zAnnotated._deannotateC  so    
 >>!))"   *.*;*A*A*C*C     r1   visitorkwc                4     | j         j        j        | |fi |S r*   )r   r   _compiler_dispatch)r.   r   r   s      r/   r   zAnnotated._compiler_dispatchW  s0    >4>+>g !#  r1   c                    | j         j        S r*   )r   r\   r^   s    r/   r\   zAnnotated._constructor\  s    >..r1   c                     | j         j        di |}|| j         u r| S |j                            | j                   |                     || j                  S )Nr!   )r   rm   rw   updater   r"   )r.   r   r3   s      r/   rm   zAnnotated._clone`  s_    %%++++DN""K N!!$-000>>%):;;;r1   'Tuple[Type[Annotated], Tuple[Any, ...]]c                ,    | j         | j        | j        ffS r*   )r   r   r"   r^   s    r/   
__reduce__zAnnotated.__reduce__k  s    ~0ABBBr1   c                    | j         S r*   )r   r^   s    r/   __hash__zAnnotated.__hash__n  s
    zr1   otherc                    | j         r | j        j                            | |          S t	          |          t	          |           k    S r*   )_is_column_operatorsr   r   __eq__r   )r.   r   s     r/   r   zAnnotated.__eq__q  s?    $ 	->+224???;;$t**,,r1   r   c                v    d| j         v r%t          t          | j         d                   j        S | j        j        S )Nr_   )r"   r   r[   r_   r   r^   s    r/   r_   zAnnotated.entity_namespacew  sC    !222+!"45  
 >22r1   )r   r[   r&   r'   r(   rc   )r   r   r   r   r(   r   )r   r[   r&   r'   rN   rO   rP   )r&   r8   r3   r$   r(   rc   )NTrS   )r   r   r   r   r(   r   )r   r   r(   r   )r(   r   )r(   r   )r   r   r(   r$   ro   )rT   rU   rV   __doc__r   classmethodrd   rX   r   r   r0   rh   r   r6   r   r   r   propertyr\   rm   r   r   r   r   rp   r_   r!   r1   r/   rc   rc      s         & !$ $ $ [$ /...****JJJ# # # ## # # #   
     !$    X  !$    X +/    $  	/	 	 	 	
 
	/ 	/ 
	/	< 	< 	< 	<C C C C   - - - - 
"3 3 3 #"3 3 3r1   rc   z8Dict[Type[SupportsWrappingAnnotations], Type[Annotated]]r   _SA)boundto_annotater   r'   r(   c                L    	 | j         } ||          S # t          $ r | cY S w xY wr*   )r0   AttributeError)r   r   r0   s      r/   _safe_annotater     sL    &)	 y%%%     	s    ##F)detect_subquery_colsind_cols_on_fromclauseannotate_callabler   exclude'Optional[Sequence[SupportsAnnotations]]r   r$   r   r   OOptional[Callable[[SupportsAnnotations, _AnnotationDict], SupportsAnnotations]]c               t    i dfd| t          t           |                     } d| S )	zDeep copy the given ClauseElement, annotating each element
    with the given annotations dictionary.

    Elements within the exclude collection will be cloned but not annotated.

    elemr    r   r   r(   c                   	|d<   t          |           }|v r|         S 
r:t          | d          r*| j                            
          r | j        ddi|}nH| j        k    r;	r| j        r | j        ddi|}n| }r |          }nt          |          }n| }|                               ||<   |S )Nr   r#   r3   )r3   r   r!   )	idhasattrr#   intersectionrm   r"   r%   r   _copy_internals)r   r   id_newelemr   r   r   r3   
cloned_idsr   r   r   s        r/   r3   z_deep_annotate.<locals>.clone  s/    &:!"hh*c?" 	k**	 ++G44	
 "dk44444GGD---# #(: #)dk<<<<<"  C++KEE(kBBG0F 	  	
 	
 	
 "
3r1   Nr   r    r   r   r(   r    r   r   )r   r   r   r   r   r   r3   r   s    `````@@r/   _deep_annotater     sv    * 24J' ' ' ' ' ' ' ' ' ' ' 'R sEE'NN++ENr1   r2   r&   r;   c                    d S r*   r!   r   r&   s     r/   _deep_deannotater     s	     Cr1   c                    d S r*   r!   r   s     r/   r   r     s	     #r1   Optional[_SA]c                d    i dfd| t          t           |                     } d| S )	z2Deep copy the given element, removing annotations.r   r    r   r   r(   c                    rt          |           }n| }|vr4|                     d          }|                               ||<   |S |         S )NT)r&   r3   )r3   )r   r6   r   )r   r   rG   r   r3   clonedr&   s       r/   r3   z_deep_deannotate.<locals>.clone  so     	T((CCCf&&fD&AAG##%#000!F3KN#;r1   Nr   r   )r   r&   r3   r   s    `@@r/   r   r     s]    
 .0F        sEE'NN++ENr1   c                X    |                      |          } |                                  | S )a  Annotate the given ClauseElement and copy its internals so that
    internal objects refer to the new annotated object.

    Basically used to apply a "don't traverse" annotation to a
    selectable, without digging throughout the whole
    structure wasting time.
    )r0   r   )r   r   s     r/   _shallow_annotater     s.     ,,GNr1   r   !Type[SupportsWrappingAnnotations]base_clsType[Annotated]c                   t          | t                    r| S | t          v rt          |          S | j        D ]}|t          v rt          |         } nt	          t
          t                   t          d| j        z  || fi                     xt          | <   }|t                      d| j        z  <   d| j	        v r*t          | j                  dt          j        fgz   |_        nD| j	                            dd          r)t          | j                  dt          j        fgz   |_        | j	                            dd          rd|_        nd| j	        v r| j	        d         |_        t          | t           j                  |_        |S )z[Generates a new class that subclasses Annotated and proxies a given
    element type.

    zAnnotated%s_traverse_internalsr"   inherit_cacheFT)
issubclassrc   r   __mro__r   r   typerT   globalsrw   listr   r   r   getr   r   ColumnOperatorsr   )r   r   super_anno_clss       r/   r   r     s    #y!! &
	!	!	! %%+   &&&(0HE ' )-Y]S\)Hc?B??) ) cX /7GIImcl*+,,'+C,C'D'D.ABH
 (
$$ 
		/5	1	1 
'+C,C'D'D.ABH
 (
$ |// ?!%	CL	(	(!$o!>$.sI4M$N$NH!Or1   target_hierarchyNonec                T    t          j        |           D ]}t          ||           d S r*   )r   walk_subclassesr   )r   r   r   s      r/   _prepare_annotationsr   D  s<     #$455 , ,S(++++, ,r1   )r   r   r   r'   r(   r   r*   )r   r   r   r'   r   r   r   r$   r   r$   r   r   r(   r   )r   r2   r&   r;   r(   r2   )r   r   r&   r;   r(   r   )r   r   r&   r;   r(   r   )r   r   r   r'   r(   r   )r   r   r   r   r(   r   )r   r   r   r   r(   r   )1r   
__future__r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r    r   	cache_keyr   visitorsr   r   r   r   util.typingr   r   baser   r   strr'   
EMPTY_DICTr   rX   r    r[   rr   rc   r   r   r   r   r   r   r   r   r!   r1   r/   <module>r      s     # " " " " "                                                                                            " " " " " "       + + + + + + ' ' ' ' ' '       ! ! ! ! ! !       1&&&&&&000000#s(#26/  A A A A:
 :
 :
 :
 :
/ :
 :
 :
z7 7 7 7 7"5 7 7 7tH H H H H: H H HVH3 H3 H3 H3 H3# H3 H3 H3b       ge0111	& 	& 	& 	& 8<C
 "'#( 	C C C C C CL 
>B    

 
48    
 ?C    8
 
 
 
, , , ,^, , , , , ,r1   