
    jG                    <   S SK Jr  S SK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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J.r.  \" S)\	S*9r/\" S+5      r0\" S,SS-9r1\" S.SS/9r2\" S05      r3\" S1SS-9r4\Rj                  (       a  \6" \RJ                  \%/5      r7O	\6" \%/5      r7\Rp                  (       a  S S2K9J:r:  O\;" S5      r:\" S35      r<\#r=\$r>\\\	   \?\\\.S44   r@ " S5 S6\(5      rA " S7 S8\(\/   5      rB " S9 S:\(\0\44   5      rC\%S;   rDSS<SS=.               SkS> jjrE    SlS? jrF      SmS@ jrGSSSA.         SnSB jjrHSSC.       SoSD jjrISpSE jrJSSF.           SqSG jjrKSrSH jrLSsSI jrMStSJ jrNSuSK jrOSvSL jrPSwSM jrQSxSN jrR Sy     SzSO jjrS\S{SP j5       rT\S|SQ j5       rT\    SlSR j5       rT    SlSS jrT    S}ST jrUS~SU jrV S       SSV jjrWSSW jrXSSX jrYSSY jrZ      SSZ jr[SS[.       SS\ jjr\SS] jr] " S^ S_\(5      r^\" S`\^S*9r_ " Sa Sb\\_   5      r`\" Sc\^SSd9ra " Se Sf\\a   5      rb\" Sg\\
Sh\	4      S*9rc " Si Sj\\c   5      rdg)    )annotationsN)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_T)bound_KT_KT_co)	covariant
_KT_contra)contravariant_VT_VT_co)NoneTypeNonezGenericProtocol[Any]c                  $    \ rS rSr% SrS\S'   Srg)ArgsTypeProcotol[   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__r9       S/var/www/reloj-farallon/venv/lib/python3.13/site-packages/sqlalchemy/util/typing.pyr5   r5   [   s     .-rB   r5   c                  .    \ rS rSr% SrS\S'   S\S'   Srg)	GenericProtocole   zPprotocol for generic types.

this since Python.typing _GenericAlias is private

r7   r8   Type[_T]
__origin__r9   Nr:   r9   rB   rC   rE   rE   e   s     .-rB   rE   c                  (    \ rS rSrSS jrSS jrSrg)SupportsKeysAndGetItemy   c                    g Nr9   )selfs    rC   keysSupportsKeysAndGetItem.keysz   s    SrB   c                    g rM   r9   )rN   _SupportsKeysAndGetItem__ks     rC   __getitem__"SupportsKeysAndGetItem.__getitem__|   s    srB   r9   N)returnzIterable[_KT])rR   r+   rU   r1   )r;   r<   r=   r>   rO   rS   rA   r9   rB   rC   rJ   rJ   y   s    (2rB   rJ   *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)rW   N)de_stringify_annotation).0elemrZ   clsrY   r]   originating_modulerX   s     rC   	<genexpr>*de_stringify_annotation.<locals>.<genexpr>   s6      
 , $"- /+ ,s   )
is_fwd_ref__forward_arg__
isinstancestreval_expression
is_generic
is_literalsetaddtupler8   _copy_generic_annotation_with)	rc   
annotationrd   r]   rX   rY   rZ   original_annotationelementss	   ` `````  rC   r`   r`      s    . %*//
*c""'
4FGJ$*Gc


 	z"":&& EM&
 '&j) 
 
 #++
 
 -ZBBrB   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))rl   typing_get_origindictrn   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__rp   typing_get_argsri   rj   r   )type_rb   s     rC   fixup_container_fwd_refsr      s     	5e$&&**++##$$	


 A4;
 

 !'99 !0 6 6 )34(=(=Jt$4G 6
 	
 Ls   ,C>c                d    [        U S5      (       a  U R                  U5      $ U R                  U   $ )N	copy_with)hasattrr   rH   )rr   rt   s     rC   rq   rq      s5     z;''##H-- $$X..rB   r\   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	NameErrorrw   
setdefaultr;   updateeval	Exception)	
expressionmodule_namer]   r^   base_globalskecls_namespacerr   errs	            rC   rk   rk      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r]   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 )rk   r   r   r   r   r   builtins)namer   r]   r   r   s        rC   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)Nr;   )r   getattrr   )r   r   objs      rC   resolve_name_to_real_class_namer   D  s8    .T/ sJ--  s    ))rX   c               h    [        UR                   Vs/ s H  n[        U UU0 US9PM     sn6 $ s  snf )Nr   )make_union_typer8   r`   )rc   rr   rd   r]   rX   annos         rC   de_stringify_union_elementsr   M  sQ      #++	

 , $"- ,	

 	

s   /c                :    U S L=(       a    [        U 5      [        L $ rM   )rv   r   r   s    rC   	is_pep593r   c  s    F!25!9Y!FFrB   c                z    [        U [        R                  5      =(       a    [        U [        [        45      (       + $ rM   )ri   ry   r
   rj   bytes)r   s    rC   is_non_string_iterabler   g  s1    c?334 Zc5\> : rB   c                &    [        U 5      [        ;   $ rM   )r   _LITERAL_TYPESr   s    rC   rm   rm   m  s    e..rB   c                    [        U S5      $ )N__supertype__r   r   s    rC   
is_newtyper   q  s    5/**rB   c                @    [        U S5      =(       a    [        U S5      $ )Nr8   rH   r   r   s    rC   rl   rl   y  s    5*%F'%*FFrB   c                "    [        U [        5      $ rM   )ri   r(   r   s    rC   	is_pep695r   }  s    e]++rB   c                z    U R                   n[        U5      (       a  UR                   n[        U5      (       a  M  U$ rM   )r   r   )r   
super_types     rC   flatten_newtyper     s6    $$J
Z
 
 --
 Z
 
 rB   c                    [        U [        5      (       a  gU(       a,  [        U 5      (       a  [        S U R                   5       5      $ g)NTc              3  :   #    U  H  n[        US 5      v   M     g7f)TN)rg   )ra   args     rC   re   is_fwd_ref.<locals>.<genexpr>  s     CNS:c4((Ns   F)ri   r   rl   anyr8   )r   check_generics     rC   rg   rg     s9     %$$	:e,,CENNCCCrB   c                    g rM   r9   r   s    rC   de_optionalize_union_typesr     s    36rB   c                    g rM   r9   r   s    rC   r   r     s    ?BrB   c                    g rM   r9   r   s    rC   r   r     s     rB   c                    [        U 5      (       a  [        U 5      $ [        U 5      (       aG  [        U R                  5      nUR                  [        5        UR                  [        5        [        U6 $ U $ )zeGiven a type, filter out ``Union`` types that include ``NoneType``
to not include the ``NoneType``.

)	rg   "de_optionalize_fwd_ref_union_typesis_optionalrn   r8   discardr2   NoneFwdr   )r   typs     rC   r   r     s]     %1%88	U		%..!HG$$ rB   c                
   U R                   n[        R                  " SU5      nU(       a  UR                  S5      S:X  a  [	        UR                  S5      5      $ UR                  S5      S:X  aO  [        R
                  " SUR                  S5      5      n[        U Vs/ s H  oDS:w  d  M
  [	        U5      PM     sn6 $ U $ [        R
                  " SU5      nSU;   a!  [	        S	R                  S
 U 5       5      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   z,\s*r3   z\s*\|\s*|c              3  4   #    U  H  oS :w  d  M
  Uv   M     g7f)r3   Nr9   )ra   ps     rC   re   5de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s     "Ik&[11ks   		)rh   r~   r   groupr   splitr   join)r   rr   mmrt   rb   pipe_tokenss         rC   r   r     s     &&J	$j	1B	88A;*$bhhqk**XXa[G#xx!5H"/7Jxt6>"*T"xJ  L((;
3K#(("Ik"IIJJL Ks   	D +D c                 H    [        [        [        5      R                  U 5      $ )zxMake a Union type.

This is needed by :func:`.de_optionalize_union_types` which removes
``NoneType`` from a ``Union``.

)r   r   r   rS   )typess    rC   r   r     s     U''..rB   c                    [        U 5      (       aR  [        U R                  5      nU(       a  UR                  [        5        U(       a  U 4[        U5      -   $ [        U5      $ U 4$ )zLReturn a type as a tuple of individual types, expanding for
``Union`` types.)is_unionrn   r8   r   r2   rp   )r   include_uniondiscard_noner   s       rC   expand_unionsr     sO     %..!KK!8eCj((:xrB   c                    [        U SSS5      $ )Nr   r   	UnionTypeis_origin_ofr   s    rC   r   r     s    	 rB   c                J    [        U 5      =(       a    [        [        U 5      ;   $ rM   )r   r2   r   r   s    rC   is_optional_unionr     s    uD(oe.D"DDrB   c                    [        U S5      $ )Nr   r   r   s    rC   r   r     s    w''rB   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)rv   ri   type
issubclass)r   	class_objorigins      rC   is_origin_of_clsr     s-     u%F~fd#E
6(EErB   )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)rv   _get_type_namer<   
startswith)r   r   namesr   s       rC   r   r     sJ     u%F~&!U* $>&++66v>rB   c                    [         R                  (       a  U R                  $ [        U SS 5      nUc  [        U SS 5      nU$ )Nr;   _name)r   py310r;   r   )r   typ_names     rC   r   r   "  s:    ||~~5*d3ugt4HrB   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 rM   r9   rN   instanceowners      rC   __get__DescriptorProto.__get__.  s    CrB   c                    g rM   r9   rN   r   values      rC   __set__DescriptorProto.__set__0  s    #rB   c                    g rM   r9   rN   r   s     rC   
__delete__DescriptorProto.__delete__2  s    rB   r9   N)r   objectr   r   rU   r   )r   r   r   r   rU   r3   r   r   rU   r3   )r;   r<   r=   r>   r   r   r  rA   r9   rB   rC   r   r   -  s    ?=4rB   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)DescriptorReferencei8  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 rM   r9   r   s      rC   r   DescriptorReference.__get__E      #rB   c                    g rM   r9   r   s      rC   r   DescriptorReference.__set__G      rB   c                    g rM   r9   r   s     rC   r  DescriptorReference.__delete__I      SrB   r9   N)r   r  r   r   rU   r  )r   r   r   r  rU   r3   r  
r;   r<   r=   r>   r?   r   r   r   r  rA   r9   rB   rC   r  r  8  s     EC8 rB   r  _DESC_co)r*   r-   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)RODescriptorReferenceiO  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 rM   r9   r   s      rC   r   RODescriptorReference.__get__Y  s    SrB   c                    g rM   r9   r   s      rC   r   RODescriptorReference.__set__[  r
  rB   c                    g rM   r9   r   s     rC   r   RODescriptorReference.__delete__]  s    rB   r9   N)r   r  r   r   rU   r  )r   r   r   r   rU   r   )r   r   rU   r   r  r9   rB   rC   r  r  O  s     HE< rB   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)CallableReferenceic  za descriptor that refers to a callable.

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


c                    g rM   r9   r   s      rC   r   CallableReference.__get__n  r  rB   c                    g rM   r9   r   s      rC   r   CallableReference.__set__p  s    crB   c                    g rM   r9   r   s     rC   r  CallableReference.__delete__r  r  rB   r9   N)r   r  r   r   rU   r  )r   r   r   r  rU   r3   r  r  r9   rB   rC   r  r  c  s     CA8 rB   r  )rc   	Type[Any]rr   _AnnotationScanTyperd   rj   r]   Mapping[str, Any]rX   #Optional[Callable[[str, str], str]]rY   boolrZ   zOptional[Set[Any]]rU   r$  )r   r%  rU   r%  )rr   zGenericProtocol[_T]rt   r7   rU   rG   )
r   rj   r   rj   r]   Optional[Mapping[str, Any]]r^   zOptional[Type[Any]]rU   r   )r   rj   r   rj   r]   r)  rU   r   )r   rj   r   rj   rU   rj   )rc   r$  rr   r5   rd   rj   r]   r&  rX   r'  rU   r$  )r   Optional[_AnnotationScanType]rU   r(  )r   r   rU   zTypeGuard[Iterable[Any]])r   r%  rU   r(  )r   r*  rU   zTypeGuard[NewType])r   r%  rU   zTypeGuard[GenericProtocol[Any]])r   r%  rU   zTypeGuard[TypeAliasType])r   r   rU   r$  )F)r   r%  r   r(  rU   zTypeGuard[ForwardRef])r   rj   rU   rj   )r   r$  rU   r$  )r   r   rU   r%  )r   r%  rU   r$  )FF)r   r$  r   r(  r   r(  rU   zTuple[Type[Any], ...])r   r   rU   zTypeGuard[ArgsTypeProcotol])r   r   rU   r(  )r   r   r   z'Union[Tuple[Type[Any], ...], Type[Any]]rU   r(  )r   r   r   rj   r   zOptional[str]rU   r(  )r   r$  rU   rj   )e
__future__r   r   collections.abcabcry   r~   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r    r   typing_extensionsr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r+   r,   r.   r0   r1   py38	frozensetr   r   r   r2   r   r   r   rv   rj   r%  r5   rE   rJ   _LiteralStarr`   r   rq   rk   r   r   r   r   r   rm   r   rl   r   r   rg   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r9   rB   rC   <module>r4     s   #  ) 	 
                     8< 106:4<86@888.@Ten	T	*\6
en	T	*	;; 89Ny)N 
<< +DzH
V
  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. ;?	   	 8 ,G/+G, 7</3 
 6 
 6 
 B 
 B 
 

.>/ IN%)AE(E(
F
FB
F	
F 6:%2	5h 5 	/9'%. 9( :_E=GH- =" e8HS#X$6789 9rB   