
    
 @g=                       d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ ddlmZ 	 d dl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d(e)          Z+ ed*          Z, ed+d,          Z- ed-d.          Z. ed/          Z/ ed0d,          Z0ej1        rd d1l2m3Z3 n e4d          Z3 e
d2          Z5e Z6e!Z7eee         e8e
ed3f         Z9 G d4 d5e%          Z: G d6 d7e%e+                   Z; G d8 d9e%e,e0f                   Z<e"d:         Z=dd;dd<ddLZ>ddQZ?ddRddWZ@ddRddYZAddZZBdd[dd\ZCdd_ZDdd`ZEddbZFdddZGddfZH	 dddiZIeddj            ZJeddk            ZJeddl            ZJddmZJddoZKddqZL	 ddduZMddwZNddxZOddyZPdd|ZQdd}ddZRddZS G d de%          ZT edeT)          ZU G d deeU                   ZV edeTd          ZW G d deeW                   ZX edeedef                  )          ZY G d deeY                   ZZdS )    )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_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 )ArgsTypeProcotolz_protocol for types that have ``__args__``

    there's no public interface for this AFAIK

    Tuple[_AnnotationScanType, ...]__args__N__name__
__module____qualname____doc____annotations__     J/var/www/piapp/venv/lib/python3.11/site-packages/sqlalchemy/util/typing.pyr5   r5   S   s*           .-----r?   r5   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

    r6   r7   Type[_T]
__origin__Nr8   r>   r?   r@   rB   rB   ]   s6           .---r?   rB   c                      e Zd Zd	dZd
dZdS )SupportsKeysAndGetItemreturnIterable[_KT]c                    d S Nr>   )selfs    r@   keyszSupportsKeysAndGetItem.keysr       r?   _SupportsKeysAndGetItem__kr+   r1   c                    d S rJ   r>   )rK   rN   s     r@   __getitem__z"SupportsKeysAndGetItem.__getitem__u   rM   r?   N)rG   rH   )rN   r+   rG   r1   )r9   r:   r;   rL   rP   r>   r?   r@   rF   rF   q   s<                r?   rF   *Fstr_cleanup_fninclude_generic_already_seencls	Type[Any]
annotation_AnnotationScanTypeoriginating_modulestrlocals_Mapping[str, Any]rS   #Optional[Callable[[str, str], str]]rT   boolrU   Optional[Set[Any]]rG   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\   Nc           
   3  D   K   | ]}t          |           V  dS )rR   Nde_stringify_annotation).0elemrU   rV   rT   r\   rZ   rS   s     r@   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s]       
 
  $"- /+  
 
 
 
 
 
r?   )
is_fwd_ref__forward_arg__
isinstancer[   eval_expression
is_generic
is_literalsetaddtupler7   _copy_generic_annotation_with)	rV   rX   rZ   r\   rS   rT   rU   original_annotationelementss	   ` `````  r@   re   re   }   sC   . %* 0/
*c"" 
 	H'
4FGGJ$*G
 
 


 	Cz""C :&&C
  EEM&&
 '&j))) 
 
 
 
 
 
 
 
 
 #+
 
 
 
 
 -ZBBBr?   GenericProtocol[_T]rt   r6   rC   c                f    t          | d          r|                     |          S | j        |         S )N	copy_with)hasattrrw   rD   )rX   rt   s     r@   rr   rr      s:     z;'' /##H--- $X..r?   rb   
expressionmodule_nameOptional[Mapping[str, Any]]r   c                   	 t           j        |         j        }n(# t          $ r}t	          d| d|            |d }~ww xY w	 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	NameErroreval	Exception)ry   rz   r\   base_globalskerX   errs          r@   rl   rl      s    '*{;'?'H   0k 0 0#-0 0
 
 	*lG<<
     ???
 
	s(    
?:?A 
A8 A33A8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.rb   r}   z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rl   r~   r   r   r   r   builtins)r   rz   r\   r   r   s        r@   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)Nr9   )r   getattrr   )r   rz   objs      r@   resolve_name_to_real_class_namer     sP    .T;// sJ---    s   # 22rS   c               @     t           fd|j        D              S )Nc           	     8    g | ]}t          |i            S )r   rd   )rf   annorV   rZ   rS   s     r@   
<listcomp>z/de_stringify_union_elements.<locals>.<listcomp>  sI     	

 	

 	

  $"-  	

 	

 	

r?   )make_union_typer7   )rV   rX   rZ   r\   rS   s   ` ` `r@   de_stringify_union_elementsr     sI     	

 	

 	

 	

 	

 	

 #+	

 	

 	

 r?   type_Optional[_AnnotationScanType]c                6    | d uot          |           t          u S rJ   )typing_get_originr   r   s    r@   	is_pep593r   '  s     F!25!9!9Y!FFr?   c                .    t          |           t          u S rJ   )r   r    r   s    r@   rn   rn   +  s    e''r?   TypeGuard[NewType]c                "    t          | d          S )N__supertype__rx   r   s    r@   
is_newtyper   /  s    5/***r?   TypeGuard[GenericProtocol[Any]]c                B    t          | d          ot          | d          S )Nr7   rD   r   r   s    r@   rm   rm   7  s!    5*%%F'%*F*FFr?   r   c                ^    | j         }t          |          r|j         }t          |          |S rJ   )r   r   )r   
super_types     r@   flatten_newtyper   ;  s:    $J
Z
 
  .-
 Z
 
  .r?   check_genericTypeGuard[ForwardRef]c                    t          | t                    rdS |r-t          |           rt          d | j        D                       S dS )NTc              3  6   K   | ]}t          |d           V  dS )TN)ri   )rf   args     r@   rh   zis_fwd_ref.<locals>.<genexpr>H  s,      CCS:c4((CCCCCCr?   F)rk   r	   rm   anyr7   )r   r   s     r@   ri   ri   B  sV     %$$ t	 :e,, CCENCCCCCCur?   c                    d S rJ   r>   r   s    r@   de_optionalize_union_typesr   M      Cr?   c                    d S rJ   r>   r   s    r@   r   r   R  r   r?   c                    d S rJ   r>   r   s    r@   r   r   W  s	     Cr?   c                   t          |           rt          |           S t          |           rQt          | j                  }|                    t                     |                    t                     t          | S | S )zmGiven a type, filter out ``Union`` types that include ``NoneType``
    to not include the ``NoneType``.

    )	ri   "de_optionalize_fwd_ref_union_typesis_optionalro   r7   discardr2   NoneFwdr   )r   typs     r@   r   r   ^  sw     % 1%888	U		 	%.!!HG$$ r?   r	   c                   | j         }t          j        d|          }|r|                    d          dk    r"t	          |                    d                    S |                    d          dk    r;t          j        d|                    d                    }t          d |D              S | S t          j        d|          }d	|v r,t	          d
                    d |D                                 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   z,\s*c                8    g | ]}|d k    t          |          S )r3   r   )rf   rg   s     r@   r   z6de_optionalize_fwd_ref_union_types.<locals>.<listcomp>  s%    JJJt46>>*T"">>>r?   z\s*\|\s*r3   |c              3  &   K   | ]}|d k    |V  dS )r3   Nr>   )rf   ps     r@   rh   z5de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s&      "I"IQ&[[1[[[["I"Ir?   )rj   rematchgroupr	   splitr   join)r   rX   mmrt   pipe_tokenss        r@   r   r   u  s     &J	$j	1	1B	 	88A;;*$$bhhqkk***XXa[[G##x!55H"JJxJJJ  L(;
33K#(("I"Ik"I"I"IIIJJJLr?   typesc                 \    t          t          t                                        |           S )zMake a Union type.

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

    )r   r   r   rP   )r   s    r@   r   r     s"     U''...r?   include_uniondiscard_noneTuple[Type[Any], ...]c                    t          |           rTt          | j                  }|r|                    t                     |r| ft          |          z   S t          |          S | fS )zPReturn a type as a tuple of individual types, expanding for
    ``Union`` types.)is_unionro   r7   r   r2   rq   )r   r   r   r   s       r@   expand_unionsr     si      %.!! 	"KK!!! 	8eCjj((::xr?   TypeGuard[ArgsTypeProcotol]c                &    t          | ddd          S )Nr   r   	UnionTypeis_origin_ofr   s    r@   r   r     s     	  r?   c                L    t          |           ot          t          |           v S rJ   )r   r2   typing_get_argsr   s    r@   is_optional_unionr     s"    uD(oe.D.D"DDr?   c                "    t          | d          S )Nr   r   r   s    r@   r   r     s    w'''r?   	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   rk   type
issubclass)r   r   origins      r@   is_origin_of_clsr     s:     u%%F~ufd##E
69(E(EEr?   )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)r   r   r   r   s       r@   r   r     sR     u%%F~u&!!U* $>&+66v>>r?   c                t    t           j        r| j        S t          | dd           }|t          | dd           }|S )Nr9   _name)r   py310r9   r   )r   typ_names     r@   r   r     sA    | ~5*d33ugt44Hr?   c                  &    e Zd ZddZdd	Zdd
ZdS )DescriptorProtoinstanceobjectownerr   rG   c                    d S rJ   r>   rK   r   r   s      r@   __get__zDescriptorProto.__get__  rM   r?   valuer3   c                    d S rJ   r>   rK   r   r   s      r@   __set__zDescriptorProto.__set__  rM   r?   c                    d S rJ   r>   rK   r   s     r@   
__delete__zDescriptorProto.__delete__  rM   r?   N)r   r   r   r   rG   r   )r   r   r   r   rG   r3   r   r   rG   r3   )r9   r:   r;   r   r   r   r>   r?   r@   r   r     sP                   r?   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

    r   r   r   r   rG   r   c                    d S rJ   r>   r   s      r@   r   zDescriptorReference.__get__      Cr?   r   r3   c                    d S rJ   r>   r   s      r@   r   zDescriptorReference.__set__  r   r?   c                    d S rJ   r>   r   s     r@   r   zDescriptorReference.__delete__  r   r?   N)r   r   r   r   rG   r   )r   r   r   r   rG   r3   r   r9   r:   r;   r<   r   r   r   r   r>   r?   r@   r   r     sn           		 	 	 		 	 	 		 	 	 	 	 		 	r?   r   _DESC_co)r*   r-   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

    r   r   r   r   rG   r  c                    d S rJ   r>   r   s      r@   r   zRODescriptorReference.__get__  r   r?   r   r   c                    d S rJ   r>   r   s      r@   r   zRODescriptorReference.__set__  r   r?   c                    d S rJ   r>   r   s     r@   r   z RODescriptorReference.__delete__"  r   r?   N)r   r   r   r   rG   r  )r   r   r   r   rG   r   )r   r   rG   r   r   r>   r?   r@   r  r    sn           		 	 	 		 	 	 		 	 	 	 	 		 	r?   r  _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


    r   r   r   r   rG   r  c                    d S rJ   r>   r   s      r@   r   zCallableReference.__get__4  r   r?   r   r3   c                    d S rJ   r>   r   s      r@   r   zCallableReference.__set__7  r   r?   c                    d S rJ   r>   r   s     r@   r   zCallableReference.__delete__:  r   r?   N)r   r   r   r   rG   r  )r   r   r   r  rG   r3   r   r   r>   r?   r@   r	  r	  )  sn           		 	 	 		 	 	 		 	 	 	 	 		 	r?   r	  )rV   rW   rX   rY   rZ   r[   r\   r]   rS   r^   rT   r_   rU   r`   rG   rW   )rX   ru   rt   r6   rG   rC   )ry   r[   rz   r[   r\   r{   rG   r   )r   r[   rz   r[   r\   r{   rG   r   )r   r[   rz   r[   rG   r[   )rV   rW   rX   r5   rZ   r[   r\   r]   rS   r^   rG   rW   )r   r   rG   r_   )r   rY   rG   r_   )r   r   rG   r   )r   rY   rG   r   )r   r   rG   rW   )F)r   rY   r   r_   rG   r   )r   r[   rG   r[   )r   rW   rG   rW   )r   rY   rG   rY   )r   r	   rG   rY   )r   rY   rG   rW   )FF)r   rW   r   r_   r   r_   rG   r   )r   r   rG   r   )r   r   rG   r_   )r   r   r   r   rG   r_   )r   r   r   r[   r   r   rG   r_   )r   rW   rG   r[   )[
__future__r   r   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.   r0   r1   r   r   r2   r   r   r   r   r[   rY   r5   rB   rF   _LiteralStarre   rr   rl   r   r   r   r   rn   r   rm   r   ri   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r	  r>   r?   r@   <module>r     s   # " " " " "  				 



                                                                                                                         /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...... WTgenn	T	*	*	*W\666
genn	T	*	*	* 
<  +******tDzzH
*V

  IsJ)?? 
. . . . .x . . .    hrl   (    Xc6k2    s| ;?!(,C C C C C CL/ / / / ,0	     8 ,0	     D. . . . ;?     ,G G G G( ( ( (+ + + +G G G G    7<     
   
 
   
 
   
   .   >/ / / / IN    (   E E E E( ( ( (
F 
F 
F 
F 6:            h    	///    '%.   . 7:_EEE    GH-   ( ge8HS#X$67888         r?   