
    ,hW                    P   S SK Jr  S SKrS SKJr  S SKJr  S SKrS SK	r	S SK
r
S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S S	K
Jr  S S
K
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SK
Jr  S SKrSSKJr   S SKJr  S SKJ r   S SKJ!r!  S SKJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S S KJ'r'  S S!KJ(r(  S S"KJ)r)  S S#KJ*r*  S S$KJ+r+  S S%KJ,r,  S S&KJ-r-  S S'KJ.r.  S S(KJ/r/  S S)KJ0r0  S S*KJ1r1  \" S+\S,9r2\" S-5      r3\" S.SS/9r4\" S0SS19r5\" S25      r6\" S3SS/9r7\Rp                  (       a  S S4K9J:r:  O\;" S5      r:SoS5 jr<\\\   \=\\\/S64   r> " S7 S8\)5      r? " S9 S:\)\2   5      r@ " S; S<\)\3\74   5      rA\&S=   rBSS>SS?.               SpS@ jjrC    SqSA jrD      SrSB jrESSSC.         SsSD jjrFSSE.       StSF jjrGSuSG jrHSvSH jrISwSI jrJSxSJ jrKSySK jrLSzSL jrMS{SM jrNS|SN jrOS}SO jrP  S~       SSP jjrQ\SSQ j5       rR\SSR j5       rR\    SqSS j5       rR    SqST jrR\      SSU j5       rS\      SSV j5       rS      SSW jrSSSX jrTSxSY jrUSxSZ jrVSS[ jrW      SS\ jrXSS].       SS^ jjrYSS_ jrZ " S` Sa\)5      r[\" Sb\[S,9r\ " Sc Sd\\\   5      r]\" Se\[SSf9r^ " Sg Sh\\^   5      r_\" Si\\Sj\4      S,9r` " Sk Sl\\`   5      ra " Sm Sn5      rb\b" 5       rc\(       a  \rdO\crd\cRL                  reg)    )annotationsN)deque)Any)Callable)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)NoneTypec                N    [        U [        5      =(       a    U R                  S:H  $ )NNone)
isinstancer   __forward_arg__)typs    N/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/util/typing.pyis_fwd_noner<   M   s    c:&H3+>+>&+HH    zGenericProtocol[Any]c                  $    \ rS rSr% SrS\S'   Srg)ArgsTypeProtocolV   zWprotocol for types that have ``__args__``

there's no public interface for this AFAIK

Tuple[_AnnotationScanType, ...]__args__ N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__rC   r=   r;   r?   r?   V   s     .-r=   r?   c                  .    \ rS rSr% SrS\S'   S\S'   Srg)	GenericProtocol`   zPprotocol for generic types.

this since Python.typing _GenericAlias is private

rA   rB   Type[_T]
__origin__rC   NrD   rC   r=   r;   rM   rM   `   s     .-r=   rM   c                  (    \ rS rSrSS jrSS jrSrg)SupportsKeysAndGetItemt   c                    g NrC   )selfs    r;   keysSupportsKeysAndGetItem.keysu   s    Sr=   c                    g rU   rC   )rV   _SupportsKeysAndGetItem__ks     r;   __getitem__"SupportsKeysAndGetItem.__getitem__w   s    sr=   rC   N)returnzIterable[_KT])rZ   r.   r]   r4   )rE   rF   rG   rH   rW   r[   rK   rC   r=   r;   rR   rR   t   s    (2r=   rR   *Fstr_cleanup_fninclude_generic_already_seenc                 ^ ^^^^^ Un[        U5      (       a  UR                  n[        U[        5      (       a  T(       a	  T" UT5      n[	        UTTT S9nT(       au  [        U5      (       ae  [        U5      (       dU  Tc
  [        5       mUT;   a  U$ TR                  U5        [        UU UUUU4S jUR                   5       5      n[        X5      $ U$ )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.

locals_in_classc              3  B   >#    U  H  n[        TUTTTTTS 9v   M     g7f)r_   N)de_stringify_annotation).0elemrb   clsra   re   originating_moduler`   s     r;   	<genexpr>*de_stringify_annotation.<locals>.<genexpr>   s6      
 , $"- /+ ,s   )
is_fwd_refr9   r8   streval_expression
is_generic
is_literalsetaddtuplerB   _copy_generic_annotation_with)	rk   
annotationrl   re   r`   ra   rb   original_annotationelementss	   ` `````  r;   rh   rh   ~   s    . %*//
*c""'
4FGJ$*Gc


 	z"":&& EM&
 '&j) 
 
 #++
 
 -ZBBr=   c                   [        U 5      (       a  [        U 5      [        [        [        [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  4;   a  [        R                  " S[        U 5      5      (       d]  [        U 5      R                  [        [!        U 5       Vs/ s H%  n[#        U[$        5      (       a  ['        U5      OUPM'     sn5      5      $ U $ s  snf )z^Correct dict['x', 'y'] into dict[ForwardRef('x'), ForwardRef('y')]
and similar for list, set

z3typing.(?:Dict|List|Set|.*Mapping|.*Sequence|.*Set))rr   r   dictrt   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__rv   r   r8   rp   r   )type_rj   s     r;   fixup_container_fwd_refsr      s     	5u&&**++##$$	


 A4;
 

 % 22 !) / )34(=(=Jt$4G /
 	
 Ls   ,C>c                d    [        U S5      (       a  U R                  U5      $ U R                  U   $ )N	copy_with)hasattrr   rP   )rx   rz   s     r;   rw   rw      s5     z;''##H-- $$X..r=   rd   c                   [         R                  U   R                  n UbP  [        UR                  5      nUR                  UR                  U5        UR                  U5        [        XU5      nU$ [        XU5      n U$ ! [         a  n[	        SU SU  35      UeS nAff = f! [         a  n[	        SU < 35      UeS nAff = f)NModule z9 isn't present in sys.modules; can't evaluate expression z"Could not de-stringify annotation )sysmodules__dict__KeyError	NameErrorr|   
setdefaultrE   updateeval	Exception)	
expressionmodule_namere   rf   base_globalskecls_namespacerx   errs	            r;   rq   rq      s    '*{{;'?'H'H !2!23M$$X%6%6A
   .jAJ  j@J 1  k] ###-,0
 	&  0?
	s5   B AB& 3B& 
B#BB#&
C0C  Cre   c               J   SU ;   a
  [        XUS9$  [        R                  U   R                  n X0   $ ! [         a  n[        SU SU  35      UeS nAff = f! [         a@  n [        R                  U    s S nA$ ! [         a     Of = f[        SU  SU 35      UeS nAff = f)N.r   r   z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rq   r   r   r   r   r   builtins)namer   re   r   r   s        r;   eval_name_onlyr     s     d{t'BB'*{{;'?'H'H!!  k] # 6#
 	  		$$T** 		 $TF+k]C
		sI   4 A 
AAA
B"#A;5B";
BBBBB"c                X     [        X5      n[        USU 5      $ ! [         a    U s $ f = f)NrE   )r   getattrr   )r   r   objs      r;   resolve_name_to_real_class_namer   ?  s8    .T/ sJ--  s    ))c                P    U S L=(       a    [        U 5      [        R                  ;   $ rU   )r   _type_tuplesr   r   s    r;   	is_pep593r   H  s"    LE!2l6L6L!LLr=   c                z    [        U [        R                  5      =(       a    [        U [        [        45      (       + $ rU   )r8   r~   r
   rp   bytes)r   s    r;   is_non_string_iterabler   L  s1    c?334 Zc5\> : r=   c                :    [        U 5      [        R                  ;   $ rU   )r   r   r    r   s    r;   rs   rs   R  s    e 4 444r=   c                    [        U S5      $ )N__supertype__r   r   s    r;   
is_newtyper   V  s    5/**r=   c                @    [        U S5      =(       a    [        U S5      $ )NrB   rP   r   r   s    r;   rr   rr   ^  s    5*%F'%*FFr=   c                    [        U 5      (       a  [        U R                  5      $ [        U [        R
                  5      $ rU   )rr   	is_pep695rP   r8   _type_instancesr)   r   s    r;   r   r   b  s3    
 %))**e_::;;r=   c                z    U R                   n[        U5      (       a  UR                   n[        U5      (       a  M  U$ rU   )r   r   )r   
super_types     r;   flatten_newtyper   l  s6    $$J
Z
 
 --
 Z
 
 r=   c                |  ^^ [        5       mUU4S jmT" U 5      n[        U[        5      (       a  [        5       n[        U5      nU(       al  UR	                  5       n[        U[        5      (       a  UR                  U5        O,UR                  U[        L d  [        U5      (       a  SOU5        U(       a  Ml  U$ U1$ )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                   > U T;   a  U $ TR                  U 5        [        U 5      (       d  U $ U R                  n[        U5      (       d  U$ UR                   Vs/ s H  nT" U5      PM     sn$ s  snf rU   )ru   r   	__value__is_unionrB   )
inner_typevaluet_seenrecursive_values      r;   r   &pep695_values.<locals>.recursive_value|  sj     		*$$$$L,1NN;Nq"N;;;s   A.N)	rt   r8   r}   r   popleftextendru   r5   r<   )r   restypesstackr   r   r   s        @@r;   pep695_valuesr   s  s     EE< %
 C#tc
A!T""Q		!x-;q>>$qI e ur=   c                   ^ T(       a  [        U [        5      (       a  g[        U [        R                  5      (       a  gU(       a/  [	        U 5      (       a  [        U4S jU R                   5       5      $ g)NTc              3  :   >#    U  H  n[        US TS9v   M     g7f)T)check_for_plain_stringN)ro   )ri   argr   s     r;   rm   is_fwd_ref.<locals>.<genexpr>  s)      
 & T2H &s   F)r8   rp   r   r   rr   anyrB   )r   check_genericr   s     `r;   ro   ro     s_    
 *UC"8"8	E?55	6	6	:e,, 
 ~~	
 
 	
 r=   c                    g rU   rC   r   s    r;   de_optionalize_union_typesr     s    36r=   c                    g rU   rC   r   s    r;   r   r     s    ?Br=   c                    g rU   rC   r   s    r;   r   r          r=   c                f   [        U 5      (       a  [        U S5      $ [        U 5      (       a  [        U 5      (       a  [        R
                  (       a  [        U R                  5      nO[        U /5      n[        5       nU(       a`  UR                  5       nUR                   H7  n[        U5      (       a  UR                  U5        M&  UR                  U5        M9     U(       a  M`  UR                  S5        U Vs1 s H!  oU[        Ld  M  [        U5      (       a  M  UiM#     nn[        U6 $ U $ s  snf )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)ro   #_de_optionalize_fwd_ref_union_typesr   includes_noner   py39rt   rB   r   r   appendru   discardr5   r<   make_union_type)r   r:   stack_of_unionsu_typrj   r   s         r;   r   r     s     %25%@@	%]511;;enn%C $UGnO%C!'//1!NND~~'..t4	 + "/ KKJ#Q(!2q;q>q#J$$  Ks   :D.
D.D.c                    g rU   rC   r   return_has_nones     r;   r   r     s     r=   c                    g rU   rC   r   s     r;   r   r     r   r=   c                "   U R                   n[        R                  " SU5      nU(       Ga  UR                  S5      R	                  S5      S   nUS:X  a#  U(       a  S$ [        UR                  S5      5      $ US:X  Ga$  S	UR                  S5      ;   a  / n/ nS
nUR                  S5       Hx  nUS	:X  a  US-  nOXUS:X  a  US-  nOLUS
:X  aF  US:X  a@  UR                  SR                  U5      R                  5       5        UR                  5         Mg  UR                  U5        Mz     O&[        R                  " SUR                  S5      5      nU V	s/ s H  oS:w  d  M
  [        U	5      PM     n
n	U(       a  [        U5      [        U
5      :g  $ U
(       a  [        U
6 $ [        $ U(       a  S$ U $ [        R                  " SU5      nSU;   nU(       a  U$ U(       a0  SR                  S U 5       5      nU(       a  [        U5      $ [        $ U $ s  sn	f )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*r7   Fz\s*\|\s*|c              3  4   #    U  H  oS :w  d  M
  Uv   M     g7f)r7   NrC   )ri   ps     r;   rm   6_de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s     B{!6kAA{s   		)r9   r   r   groupsplitr   r   joinstripclearlenr   r*   )r   r   rx   mmg1rz   currentignore_commacharrj   partspipe_tokenshas_noneanno_strs                 r;   r   r     s    &&J	$j	1B	XXa[s#B'*4G
288A;0GG7]bhhqk!&(%' HHQKDs{$)$)%*ts{ (8(>(>(@A NN4( ( 88GRXXa[92:M($fn%Z%(EM8}E
2227.BUB+566((;
3K$H88B{BB'/z(#:U:L! Ns   	HHc                     [         U    $ )zMake a Union type.r   )r   s    r;   r   r   $  s     <r=   c                   [        U 5      (       a  [        U S5      $ [        U 5      (       a  [        S [	        U 5       5       5      $ [        U 5      (       a  [        [	        U 5      S   5      $ [        U 5      (       a  [        S [        U 5       5       5      $ [        U 5      (       a  [        U R                  5      $  U [        S4;   =(       d    [        U 5      $ ! [         a     gf = f)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  8   #    U  H  n[        U5      v   M     g 7frU   r   ri   r   s     r;   rm    includes_none.<locals>.<genexpr>9  s     =_=##_   r   c              3  8   #    U  H  n[        U5      v   M     g 7frU   r   r  s     r;   rm   r  =  s     B-A=##-Ar  NF)ro   r   r   r   r   r   r   r   r   r   r   r5   r<   	TypeErrorr   s    r;   r   r   *  s     %25$??=Xe_===Xe_Q/00B]5-ABBB%U00114((>K,>>  	s    C 
C*)C*c                    [        U [        5      =(       dN    [        U S5      =(       d;    U R                  S;   =(       d%    [        U 5      R                  S   R                  S;   $ )NrP   )typingtyping_extensionsr   )r8   typer   rF   __mro__r   s    r;   	is_a_typer  I  s\    5$ 	P5,'	P>>	P ;q!,,0OO	r=   c                    [        U SS5      $ )Nr   	UnionType)is_origin_ofr   s    r;   r   r   R  s    w44r=   c                d    [        U 5      nUc  g[        U[        5      =(       a    [        X!5      $ )zWreturn True if the given type has an __origin__ that shares a base
with the given classF)r   r8   r	  
issubclass)r   	class_objorigins      r;   is_origin_of_clsr  V  s-     F~fd#E
6(EEr=   )modulec                   [        U 5      nUc  g[        U5      U;   =(       a&    USL =(       d    UR                  R                  U5      $ )zXreturn True if the given type has an __origin__ with the given name
and optional module.NF)r   _get_type_namerF   
startswith)r   r  namesr  s       r;   r  r  c  sJ     F~&!U* $>&++66v>r=   c                    [         R                  (       a  U R                  $ [        U SS 5      nUc  [        U SS 5      nU$ )NrE   _name)r   py310rE   r   )r   typ_names     r;   r  r  r  s:    ||~~5*d3ugt4Hr=   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
DescriptorProtoi}  c                    g rU   rC   rV   instanceowners      r;   __get__DescriptorProto.__get__~  s    Cr=   c                    g rU   rC   rV   r!  r   s      r;   __set__DescriptorProto.__set__  s    #r=   c                    g rU   rC   rV   r!  s     r;   
__delete__DescriptorProto.__delete__  s    r=   rC   N)r!  objectr"  r   r]   r   )r!  r   r   r   r]   r7   r!  r   r]   r7   )rE   rF   rG   rH   r#  r'  r+  rK   rC   r=   r;   r  r  }  s    ?=4r=   r  _DESCc                  J    \ rS rSrSr\(       a  SS jrS	S jrS
S jrSr	gSr	g)DescriptorReferencei  ar  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

c                    g rU   rC   r   s      r;   r#  DescriptorReference.__get__      #r=   c                    g rU   rC   r&  s      r;   r'  DescriptorReference.__set__      r=   c                    g rU   rC   r*  s     r;   r+  DescriptorReference.__delete__      Sr=   rC   N)r!  r-  r"  r   r]   r/  )r!  r   r   r/  r]   r7   r.  
rE   rF   rG   rH   rI   r   r#  r'  r+  rK   rC   r=   r;   r1  r1    s     EC8 r=   r1  _DESC_co)r-   r0   c                  J    \ rS rSrSr\(       a  SS jrS	S jrS
S jrSr	gSr	g)RODescriptorReferencei  za 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

c                    g rU   rC   r   s      r;   r#  RODescriptorReference.__get__  s    Sr=   c                    g rU   rC   r&  s      r;   r'  RODescriptorReference.__set__  r4  r=   c                    g rU   rC   r*  s     r;   r+   RODescriptorReference.__delete__  s    r=   rC   N)r!  r-  r"  r   r]   r<  )r!  r   r   r   r]   r   )r!  r   r]   r   r;  rC   r=   r;   r>  r>    s     HE< r=   r>  _FN.c                  J    \ rS rSrSr\(       a  SS jrS	S jrS
S jrSr	gSr	g)CallableReferencei  za descriptor that refers to a callable.

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


c                    g rU   rC   r   s      r;   r#  CallableReference.__get__  r7  r=   c                    g rU   rC   r&  s      r;   r'  CallableReference.__set__  s    cr=   c                    g rU   rC   r*  s     r;   r+  CallableReference.__delete__  r:  r=   rC   N)r!  r-  r"  r   r]   rE  )r!  r   r   rE  r]   r7   r.  r;  rC   r=   r;   rG  rG    s     CA8 r=   rG  c                      \ rS rSrSS jrSrg)_TypingInstancesi  c                    [        [        [        US 5      [        [        US 5      4 Vs1 s H
  nUc  M  UiM     sn5      nU(       d  [	        U5      eX0R
                  U'   U$ s  snf rU   )rv   r   r  r  AttributeErrorr   )rV   keyr   r   s       r;   __getattr___TypingInstances.__getattr__  ss     FC.-sD9A  	
  %%"cs
   A$A$rC   N)rR  rp   r]   ztuple[type, ...])rE   rF   rG   rH   rS  rK   rC   r=   r;   rO  rO    s    r=   rO  )r:   r   r]   bool)rk   	Type[Any]rx   _AnnotationScanTyperl   rp   re   zMapping[str, Any]r`   z#Optional[Callable[[str, str], str]]ra   rU  rb   zOptional[Set[Any]]r]   rV  )r   rW  r]   rW  )rx   zGenericProtocol[_T]rz   rA   r]   rO   )
r   rp   r   rp   re   Optional[Mapping[str, Any]]rf   zOptional[Type[Any]]r]   r   )r   rp   r   rp   re   rX  r]   r   )r   rp   r   rp   r]   rp   )r   zOptional[Any]r]   rU  )r   r   r]   zTypeGuard[Iterable[Any]])r   r   r]   rU  )r   zOptional[_AnnotationScanType]r]   zTypeGuard[NewType])r   rW  r]   zTypeGuard[GenericProtocol[Any]])r   rW  r]   zTypeGuard[TypeAliasType])r   r   r]   rV  )r   rW  r]   zSet[Any])FF)r   rW  r   rU  r   rU  r]   zTypeGuard[ForwardRef])r   rp   r]   rp   )r   rV  r]   rV  )r   r   r   zLiteral[True]r]   rU  )r   r   r   zLiteral[False]r]   rW  )r   r   r   rU  r]   z Union[_AnnotationScanType, bool])r   rW  r]   rV  )r   r   r]   zTypeGuard[ArgsTypeProtocol])r   r   r  z'Union[Tuple[Type[Any], ...], Type[Any]]r]   rU  )r   r   r  rp   r  zOptional[str]r]   rU  )r   rV  r]   rp   )f
__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/   r1   r3   r4   r  r   r5   r	  r<   rp   rW  r?   rM   rR   _LiteralStarrh   r   rw   rq   r   r   r   r   rs   r   rr   r   r   r   ro   r   r   r   r   r  r   r  r  r  r  r/  r1  r<  r>  rE  rG  rO  r   r   LITERAL_TYPESrC   r=   r;   <module>r_     s   #   ) 	 
                     8< 106:4<86@888.@0@Ten	T	*\6
en	T	*	<< +DzHI IsJ8NN 
.x .hrl (3Xc6k2 3 s| ;?!(,D	D#D D 	D 8D D &D DN&&&R/#//N// ,0$(!!! )	!
 "! 	!P ,0	
 )	
 	D.M5+G<"N  #( ! 	( 
 6 
 6 
 B 
 B 
 

%%%P 
(5	 

 
(6 

33(,3%3l>5
F
FB
F	
F 6:%2	5h 5 	/9'%. 9( :_E=GH- =" e8HS#X$6789 9$ $  !'O"O$$r=   