
    [hqW                    F   d dl mZ d dlZd dlmZ d dlm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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m0Z0 d d*lm1Z1 d d+lm2Z2  ed,e-          Z3 ed.          Z4 ed/d0          Z5 ed1d2          Z6 ed3          Z7 ed4d0          Z8ej9        rd d5l:m;Z; n e<d          Z; ed6          Z=eee         e>eee0d7f         Z? G d8 d9e*          Z@ G d: d;e*e3                   ZA G d< d=e*e4e8f                   ZBe'd>         ZCdd?dd@ddPZDddRZEddWZFdddXdd_ZGdd`ddbZHddcZIddeZJddhZKddiZLddlZMddnZNddpZOddrZPddtZQ	 	 dddxZReddy            ZSeddz            ZSedd{            ZSdd|ZSedd            ZTedd            ZTddZTddZUddZVddZWddZXddZYddddZZddZ[ G d de*          Z\ ede\-          Z] G d dee]                   Z^ ede\d          Z_ G d dee_                   Z` edeedef                  -          Za G d deea                   Zb G d d          Zc ec            ZdereZenedZeedj'        ZfdS )    )annotationsN)deque)Any)Callable)cast)Dict
ForwardRef)Generic)Iterable)Mapping)NewType)NoReturn)Optional)overload)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )compatT)	Annotated)Concatenate)dataclass_transform)Final)final)get_args)
get_origin)Literal)NotRequired)	ParamSpec)Protocol)SupportsIndex)	TypeAlias)	TypedDict)	TypeGuard)Self)TypeAliasType)Never)LiteralString_T)bound_KT_KT_co)	covariant
_KT_contra)contravariant_VT_VT_co)NoneTypeNonezGenericProtocol[Any]c                      e Zd ZU dZded<   dS )ArgsTypeProtocolz_protocol for types that have ``__args__``

    there's no public interface for this AFAIK

    Tuple[_AnnotationScanType, ...]__args__N__name__
__module____qualname____doc____annotations__     e/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/util/typing.pyr9   r9   U   s*           .-----rC   r9   c                  (    e Zd ZU dZded<   ded<   dS )GenericProtocolzXprotocol for generic types.

    this since Python.typing _GenericAlias is private

    r:   r;   Type[_T]
__origin__Nr<   rB   rC   rD   rF   rF   _   s6           .---rC   rF   c                      e Zd Zd	dZd
dZdS )SupportsKeysAndGetItemreturnIterable[_KT]c                    d S NrB   )selfs    rD   keyszSupportsKeysAndGetItem.keyst         rC   _SupportsKeysAndGetItem__kr/   r5   c                    d S rN   rB   )rO   rR   s     rD   __getitem__z"SupportsKeysAndGetItem.__getitem__v   rQ   rC   N)rK   rL   )rR   r/   rK   r5   )r=   r>   r?   rP   rT   rB   rC   rD   rJ   rJ   s   s(        ((((222222rC   rJ   *Fstr_cleanup_fninclude_generic_already_seencls	Type[Any]
annotation_AnnotationScanTypeoriginating_modulestrlocals_Mapping[str, Any]rW   #Optional[Callable[[str, str], str]]rX   boolrY   Optional[Set[Any]]rK   c                   |}t          |          r|j        }t          |t                    r!r |          }t	          |           }r~t          |          rot          |          s`t                      |v r|S                     |           t           fd|j
        D                       }t          ||          S |S )a;  Resolve annotations that may be string based into real objects.

    This is particularly important if a module defines "from __future__ import
    annotations", as everything inside of __annotations__ is a string. We want
    to at least have generic containers like ``Mapped``, ``Union``, ``List``,
    etc.

    r`   in_classNc           
   3  D   K   | ]}t          |           V  dS )rV   N)de_stringify_annotation).0elemrY   rZ   rX   r`   r^   rW   s     rD   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s]       
 
  $"- /+  
 
 
 
 
 
rC   )
is_fwd_ref__forward_arg__
isinstancer_   eval_expression
is_generic
is_literalsetaddtupler;   _copy_generic_annotation_with)	rZ   r\   r^   r`   rW   rX   rY   original_annotationelementss	   ` `````  rD   ri   ri   }   sE   . %* 0/
*c"" 
 	H'
4FGGJ$*Gc
 
 


 	Cz""C :&&C
  EEM&&
 '&j))) 
 
 
 
 
 
 
 
 
 #+
 
 
 
 
 -ZBBBrC   type_c           	        t          |           rt          |           t          t          t          t
          j        t
          j        t
          j        t
          j	        t
          j
        fv rht          j        dt          |                     sFt          |                               t          d t!          |           D                                 S | S )zfCorrect dict['x', 'y'] into dict[ForwardRef('x'), ForwardRef('y')]
    and similar for list, set

    z3typing.(?:Dict|List|Set|.*Mapping|.*Sequence|.*Set)c                Z    g | ](}t          |t                    rt          |          n|)S rB   )ro   r_   r
   rj   rk   s     rD   
<listcomp>z,fixup_container_fwd_refs.<locals>.<listcomp>   sD        )34(=(=GJt$$$4  rC   )rq   r    dictrs   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__ru   r   ry   s    rD   fixup_container_fwd_refsr      s     	5
u&*+#$	


 

 A4;;
 


( %  22  (   
 
 	
 LrC   GenericProtocol[_T]rx   r:   rG   c                f    t          | d          r|                     |          S | j        |         S )N	copy_with)hasattrr   rH   )r\   rx   s     rD   rv   rv      s:     z;'' /##H--- $X..rC   rf   
expressionmodule_nameOptional[Mapping[str, Any]]rg   Optional[Type[Any]]r   c                  	 t           j        |         j        }n(# t          $ r}t	          d| d|            |d }~ww xY w	 |Vt          |j                  }|                    |j        |           |                    |           t          | ||          }nt          | ||          }|S # t          $ r}t	          d|           |d }~ww xY w)NModule z9 isn't present in sys.modules; can't evaluate expression z"Could not de-stringify annotation )sysmodules__dict__KeyError	NameErrorr~   
setdefaultr=   updateeval	Exception)	r   r   r`   rg   base_globalskecls_namespacer\   errs	            rD   rp   rp      s#   '*{;'?'H   0k 0 0#-0 0
 
 	 !233M$$X%6AAA
   ...j-AAJJj,@@J     ???
 
	s)    
?:?A)B. .
C8CCr`   namec               b   d| v rt          | ||          S 	 t          j        |         j        }n(# t          $ r}t          d| d|            |d }~ww xY w	 ||          S # t          $ rC}	 t          j        |          cY d }~S # t          $ r Y nw xY wt          d|  d|           |d }~ww xY w)N.r   r   z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rp   r   r   r   r   r   builtins)r   r   r`   r   r   s        rD   eval_name_onlyr     s'    d{{t['BBBB'*{;'?'H   #k # # # #
 
 	D!! 	 	 		$T******* 	 	 	D	 CTCCkCC
 
		sJ   0 
AAAA! !
B.,B=B.
BB)BB))B.c                j    	 t          | |          }t          |d|           S # t          $ r | cY S w xY w)Nr=   )r   getattrr   )r   r   objs      rD   resolve_name_to_real_class_namer   >  sP    .T;// sJ---    s   # 22Optional[Any]c                @    | d uot          |           t          j        v S rN   )r    _type_tuplesr   r   s    rD   	is_pep593r   G  s"    LE!2!2l6L!LLrC   r   TypeGuard[Iterable[Any]]c                p    t          | t          j                  ot          | t          t          f           S rN   )ro   r   r   r_   bytes)r   s    rD   is_non_string_iterabler   K  s6    c?344 Zc5\> > : rC   c                8    t          |           t          j        v S rN   )r    r   r!   r   s    rD   rr   rr   Q  s    e 444rC   Optional[_AnnotationScanType]TypeGuard[NewType]c                "    t          | d          S )N__supertype__r   r   s    rD   
is_newtyper   U  s    5/***rC   TypeGuard[GenericProtocol[Any]]c                B    t          | d          ot          | d          S )Nr;   rH   r   r   s    rD   rq   rq   ]  s!    5*%%F'%*F*FFrC   TypeGuard[TypeAliasType]c                |    t          |           rt          | j                  S t          | t          j                  S rN   )rq   	is_pep695rH   ro   _type_instancesr*   r   s    rD   r   r   a  s8    
 % +)***e_:;;;rC   r   c                ^    | j         }t          |          r|j         }t          |          |S rN   )r   r   )ry   
super_types     rD   flatten_newtyper   k  s:    $J
Z
 
  .-
 Z
 
  .rC   Set[Any]c                   t                      fd |           }t          |t                    rt                      }t          |          }|rh|                                }t          |t                    r|                    |           n'|                    |t          t          hv rdn|           |h|S |hS )zExtracts the value from a TypeAliasType, recursively exploring unions
    and inner TypeAliasType to flatten them into a single set.

    Forward references are not evaluated, so no recursive exploration happens
    into them.
    c                    | v r| S                      |            t          |           s| S | j        }t          |          s|S fd|j        D             S )Nc                &    g | ]} |          S rB   rB   )rj   trecursive_values     rD   r}   z:pep695_values.<locals>.recursive_value.<locals>.<listcomp>  s#    ;;;q"";;;rC   )rt   r   	__value__is_unionr;   )
inner_typevalue_seenr   s     rD   r   z&pep695_values.<locals>.recursive_value{  su     		*$$ 	$ 	L;;;;EN;;;;rC   N)	rs   ro   r   r   popleftextendrt   r6   NoneFwd)ry   restypesstackr   r   r   s        @@rD   pep695_valuesr   r  s     EEE< < < < < < /%
 
 C#t c

 	CA!T"" CQ		!'':":":$$BBB  	C urC   check_genericcheck_for_plain_stringTypeGuard[ForwardRef]c                    rt          | t                    rdS t          | t          j                  rdS |r/t	          |           r t          fd| j        D                       S dS )NTc              3  <   K   | ]}t          |d           V  dS )T)r   N)rm   )rj   argr   s     rD   rl   zis_fwd_ref.<locals>.<genexpr>  sP       
 
  T2H  
 
 
 
 
 
rC   F)ro   r_   r   r
   rq   anyr;   )ry   r   r   s     `rD   rm   rm     s    
  *UC"8"8 t	E?5	6	6 
t	 :e,,  
 
 
 
 ~	
 
 
 
 
 	
 urC   c                    d S rN   rB   r   s    rD   de_optionalize_union_typesr     s    363rC   c                    d S rN   rB   r   s    rD   r   r     s    ?BsrC   c                    d S rN   rB   r   s    rD   r   r     	     #rC   c                Z   t          |           rt          | d          S t          |           rt          |           rt          j        rt          | j                  }nt          | g          }t                      }|rZ|	                                }|j        D ]<}t          |          r|
                    |           '|                    |           =|Z|                    d           |                    t                     |                    t                     t          | S | S )zGiven a type, filter out ``Union`` types that include ``NoneType``
    to not include the ``NoneType``.

    Contains extra logic to work on non-flattened unions, unions that contain
    ``None`` (seen in py38, 37)

    FN)rm   #_de_optionalize_fwd_ref_union_typesr   includes_noner   py39rs   r;   r   r   appendrt   discardr6   r   make_union_type)ry   typstack_of_unionsu_typrk   s        rD   r   r     s(    % 25%@@@	% ]511 ; 	en%%CC $UGnnO%%C! &'//11!N & &D~~ &'..t4444 " & KKHG$$ rC   r
   return_has_noneLiteral[True]c                    d S rN   rB   ry   r   s     rD   r   r     s	     3rC   Literal[False]c                    d S rN   rB   r   s     rD   r   r     r   rC    Union[_AnnotationScanType, bool]c                
   | j         }t          j        d|          }|r|                    d                              d          d         }|dk    r&|rdn!t          |                    d                    S |dk    r&d	|                    d          v rg }g }d
}|                    d          D ]}|d	k    r|dz  }ng|dk    r|dz  }n[|d
k    rU|dk    rO|                    d                    |                                                     |	                                 u|                    |           n(t          j        d|                    d                    }d |D             }	|r t          |          t          |	          k    S |	r	t          |	 nt          S |rdn| S t          j        d|          }
d|
v }|r|S |r7d                    d |
D                       }|rt          |          nt          S | S )zreturn the non-optional type for Optional[], Union[None, ...], x|None,
    etc. without de-stringifying forward refs.

    unfortunately this seems to require lots of hardcoded heuristics

    z^(.+?)\[(.+)\]$r   r   r   T   r   [r   ], z,\s*c                8    g | ]}|d k    t          |          S )r7   r	   r|   s     rD   r}   z7_de_optionalize_fwd_ref_union_types.<locals>.<listcomp>  s%    MMM$dfnnZ%%nnnrC   Fz\s*\|\s*r7   |c              3  &   K   | ]}|d k    |V  dS )r7   NrB   )rj   ps     rD   rl   z6_de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s&      BB!a6kkAkkkkBBrC   )rn   r   r   groupsplitr
   r   joinstripclearlenr   r+   )ry   r   r\   mmg1rx   currentignore_commacharpartspipe_tokenshas_noneanno_strs                rD   r   r     s,    &J	$j	1	1B	 7XXa[[s##B'*G44
288A;;0G0GG7]]bhhqkk!!&(%' HHQKK 	) 	)Ds{{$)$)%**ts{{ (8(8(>(>(@(@AAA NN4((((	) 8GRXXa[[99MM(MMME C8}}E

2227B..UB+6556(;
33K$H  ;88BB{BBBBB'/:z(###U:LrC   r   c                 *    t          j        |           S )zMake a Union type.)r   rT   )r   s    rD   r   r   $  s    U###rC   c                   t          |           rt          | d          S t          |           r&t          d t	          |           D                       S t          |           r"t          t	          |           d                   S t          |           r&t          d t          |           D                       S t          |           rt          | j
                  S 	 | t          t          dfv S # t          $ r Y dS w xY w)a.  Returns if the type annotation ``type_`` allows ``None``.

    This function supports:
    * forward refs
    * unions
    * pep593 - Annotated
    * pep695 - TypeAliasType (does not support looking into
    fw reference of other pep695)
    * NewType
    * plain types like ``int``, ``None``, etc
    Tc              3  4   K   | ]}t          |          V  d S rN   r   rj   r   s     rD   rl   z includes_none.<locals>.<genexpr>8  s*      ===##======rC   r   c              3  4   K   | ]}t          |          V  d S rN   r  r  s     rD   rl   z includes_none.<locals>.<genexpr><  s*      BB=##BBBBBBrC   NF)rm   r   r   r   r   r   r   r   r   r   r   r   r6   	TypeErrorr   s    rD   r   r   )  s    % @25$??? >==Xe__====== 1Xe__Q/000 CBB]5-A-ABBBBBB% 2U0111(D111    uu	s   C0 0
C>=C>c                    t          | t                    p9t          | d          p)| j        dv p t          |           j        d         j        dv S )NrH   )typingtyping_extensionsr   )ro   typer   r>   __mro__r   s    rD   	is_a_typer  H  s[    5$ 	P5,''	P>>	P ;;q!,0OO	rC   TypeGuard[ArgsTypeProtocol]c                $    t          | dd          S )Nr   	UnionType)is_origin_ofr   s    rD   r   r   Q  s    w444rC   	class_obj'Union[Tuple[Type[Any], ...], Type[Any]]c                r    t          |           }|dS t          |t                    ot          ||          S )z[return True if the given type has an __origin__ that shares a base
    with the given classNF)r    ro   r  
issubclass)ry   r  origins      rD   is_origin_of_clsr#  U  s:     F~ufd##E
69(E(EErC   )modulenamesr$  Optional[str]c                   t          |           }|dS t          |          |v o|du p|j                            |          S )z\return True if the given type has an __origin__ with the given name
    and optional module.NF)r    _get_type_namer>   
startswith)ry   r$  r%  r"  s       rD   r  r  b  sR     F~u&!!U* $>&+66v>>rC   c                t    t           j        r| j        S t          | dd           }|t          | dd           }|S )Nr=   _name)r   py310r=   r   )ry   typ_names     rD   r(  r(  q  sA    | ~5*d33ugt44HrC   c                  &    e Zd ZddZdd	Zdd
ZdS )DescriptorProtoinstanceobjectownerr   rK   c                    d S rN   rB   rO   r0  r2  s      rD   __get__zDescriptorProto.__get__}  rQ   rC   r   r7   c                    d S rN   rB   rO   r0  r   s      rD   __set__zDescriptorProto.__set__  rQ   rC   c                    d S rN   rB   rO   r0  s     rD   
__delete__zDescriptorProto.__delete__  rQ   rC   N)r0  r1  r2  r   rK   r   )r0  r   r   r   rK   r7   r0  r   rK   r7   )r=   r>   r?   r5  r8  r;  rB   rC   rD   r/  r/  |  s4        ????====444444rC   r/  _DESCc                  2    e Zd ZdZerddZddZddZdS dS )DescriptorReferencea  a descriptor that refers to a descriptor.

    used for cases where we need to have an instance variable referring to an
    object that is itself a descriptor, which typically confuses typing tools
    as they don't know when they should use ``__get__`` or not when referring
    to the descriptor assignment as an instance variable. See
    sqlalchemy.orm.interfaces.PropComparator.prop

    r0  r1  r2  r   rK   r=  c                    d S rN   rB   r4  s      rD   r5  zDescriptorReference.__get__  rQ   rC   r   r7   c                    d S rN   rB   r7  s      rD   r8  zDescriptorReference.__set__  rQ   rC   c                    d S rN   rB   r:  s     rD   r;  zDescriptorReference.__delete__  rQ   rC   N)r0  r1  r2  r   rK   r=  )r0  r   r   r=  rK   r7   r<  r=   r>   r?   r@   r   r5  r8  r;  rB   rC   rD   r?  r?    sR           9EEEECCCC8888889 9rC   r?  _DESC_co)r.   r1   c                  2    e Zd ZdZerddZddZddZdS dS )RODescriptorReferenceza descriptor that refers to a descriptor.

    same as :class:`.DescriptorReference` but is read-only, so that subclasses
    can define a subtype as the generically contained element

    r0  r1  r2  r   rK   rD  c                    d S rN   rB   r4  s      rD   r5  zRODescriptorReference.__get__  rQ   rC   r   r   c                    d S rN   rB   r7  s      rD   r8  zRODescriptorReference.__set__  rQ   rC   c                    d S rN   rB   r:  s     rD   r;  z RODescriptorReference.__delete__  rQ   rC   N)r0  r1  r2  r   rK   rD  )r0  r   r   r   rK   r   )r0  r   rK   r   rC  rB   rC   rD   rF  rF    sR           =HHHHEEEE<<<<<<= =rC   rF  _FN.c                  2    e Zd ZdZerddZddZddZdS dS )CallableReferenceza descriptor that refers to a callable.

    works around mypy's limitation of not allowing callables assigned
    as instance variables


    r0  r1  r2  r   rK   rJ  c                    d S rN   rB   r4  s      rD   r5  zCallableReference.__get__  rQ   rC   r   r7   c                    d S rN   rB   r7  s      rD   r8  zCallableReference.__set__  rQ   rC   c                    d S rN   rB   r:  s     rD   r;  zCallableReference.__delete__  rQ   rC   N)r0  r1  r2  r   rK   rJ  )r0  r   r   rJ  rK   r7   r<  rC  rB   rC   rD   rL  rL    sR           9CCCCAAAA8888889 9rC   rL  c                      e Zd ZddZdS )_TypingInstanceskeyr_   rK   tuple[type, ...]c           	         t          d t          t          |d           t          t          |d           fD                       }|st	          |          || j        |<   |S )Nc                    h | ]}||S rN   rB   r  s     rD   	<setcomp>z/_TypingInstances.__getattr__.<locals>.<setcomp>  s)        = 
 !==rC   )ru   r   r  r  AttributeErrorr   )rO   rR  r   s      rD   __getattr__z_TypingInstances.__getattr__  sy      FC..-sD99  	
 	
  	& %%%"crC   N)rR  r_   rK   rS  )r=   r>   r?   rX  rB   rC   rD   rQ  rQ    s(             rC   rQ  )rZ   r[   r\   r]   r^   r_   r`   ra   rW   rb   rX   rc   rY   rd   rK   r[   )ry   r]   rK   r]   )r\   r   rx   r:   rK   rG   )
r   r_   r   r_   r`   r   rg   r   rK   r   )r   r_   r   r_   r`   r   rK   r   )r   r_   r   r_   rK   r_   )ry   r   rK   rc   )r   r   rK   r   )ry   r   rK   rc   )ry   r   rK   r   )ry   r]   rK   r   )ry   r]   rK   r   )ry   r   rK   r[   )ry   r]   rK   r   )FF)ry   r]   r   rc   r   rc   rK   r   )ry   r_   rK   r_   )ry   r[   rK   r[   )ry   r
   r   r   rK   rc   )ry   r
   r   r   rK   r]   )ry   r
   r   rc   rK   r   )r   r]   rK   r[   )ry   r   rK   r  )ry   r   r  r  rK   rc   )ry   r   r%  r_   r$  r&  rK   rc   )ry   r[   rK   r_   )g
__future__r   r   collectionsr   collections.abcabcr   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   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r/   r0   r2   r4   r5   r,  r   r6   r  r   r_   r]   r9   rF   rJ   _LiteralStarri   r   rv   rp   r   r   r   r   rr   r   rq   r   r   r   rm   r   r   r   r   r  r   r#  r  r(  r/  r=  r?  rD  rF  rJ  rL  rQ  r   r   LITERAL_TYPESrB   rC   rD   <module>r_     s   # " " " " "        ) ) ) ) ) ) 				 



                                                                                                                             A888888<<<<<<      100000000000666666::::::444444<<<<<<888888666666@@@@@@888888888888888888......@@@@@@000000@@@@@@WTgenn	T	*	*	*W\666
genn	T	*	*	*	<  +******tDzzH
*V

 IsJ8NN 
. . . . .x . . .    hrl   (3 3 3 3 3Xc6k2 3 3 3 s| ;?!(,D D D D D DN& & & &R/ / / / ,0$(! ! ! ! ! !P ,0	     D. . . .M M M M   5 5 5 5+ + + +G G G G< < < <   " " " "N  #(    ( 
 6 6 6 
 6 
 B B B 
 B 
   

& & & &R 
   

 
   

3 3 3 3l$ $ $ $
   >   5 5 5 5
F 
F 
F 
F 6:        5 5 5 5 5h 5 5 5 	///9 9 9 9 9'%. 9 9 9( 7:_EEE= = = = =GH- = = =" ge8HS#X$678889 9 9 9 9 9 9 9$       $  !! #'OO"O$rC   