
    NgG                       d dl mZ d dl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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+          Z0 ed,d-          Z1 ed.d/          Z2 ed0          Z3 ed1d-          Z4ej5        r e6ej%        e%g          Z7n e6e%g          Z7ej8        rd d2l9m:Z: n e;d          Z: ed3          Z<e#Z=e$Z>eee	         e?eee.d4f         Z@ G d5 d6e(          ZA G d7 d8e(e/                   ZB G d9 d:e(e0e4f                   ZCe%d;         ZDdd<dd=ddMZEddOZFddTZGdddUdd\ZHdd]dd_ZIdd`ZJddaddbZKdddZLddgZMddhZNddjZOddlZPddnZQddpZR	 dddsZSeddt            ZTeddu            ZTeddv            ZTddwZTddyZUdd{ZV	 dddZWddZXddZYddZZddZ[ddddZ\ddZ] G d de(          Z^ ede^*          Z_ G d dee_                   Z` ede^d          Za G d deea                   Zb edee
de	f                  *          Zc G d deec                   Zdd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)TypeAliasType_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__     R/var/www/html/ai-engine/env/lib/python3.11/site-packages/sqlalchemy/util/typing.pyr6   r6   [   s*           .-----r@   r6   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

    r7   r8   Type[_T]
__origin__Nr9   r?   r@   rA   rC   rC   e   s6           .---r@   rC   c                      e Zd Zd	dZd
dZdS )SupportsKeysAndGetItemreturnIterable[_KT]c                    d S Nr?   )selfs    rA   keyszSupportsKeysAndGetItem.keysz         r@   _SupportsKeysAndGetItem__kr,   r2   c                    d S rK   r?   )rL   rO   s     rA   __getitem__z"SupportsKeysAndGetItem.__getitem__|   rN   r@   N)rH   rI   )rO   r,   rH   r2   )r:   r;   r<   rM   rQ   r?   r@   rA   rG   rG   y   s(        ((((222222r@   rG   *Fstr_cleanup_fninclude_generic_already_seencls	Type[Any]
annotation_AnnotationScanTypeoriginating_modulestrlocals_Mapping[str, Any]rT   #Optional[Callable[[str, str], str]]rU   boolrV   Optional[Set[Any]]rH   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 )rS   Nde_stringify_annotation).0elemrV   rW   rU   r]   r[   rT   s     rA   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s]       
 
  $"- /+  
 
 
 
 
 
r@   )
is_fwd_ref__forward_arg__
isinstancer\   eval_expression
is_generic
is_literalsetaddtupler8   _copy_generic_annotation_with)	rW   rY   r[   r]   rT   rU   rV   original_annotationelementss	   ` `````  rA   rg   rg      sE   . %* 0/
*c"" 
 	H'
4FGGJ$*Gc
 
 


 	Cz""C :&&C
  EEM&&
 '&j))) 
 
 
 
 
 
 
 
 
 #+
 
 
 
 
 -ZBBBr@   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 r?   )rm   r\   r	   rh   ri   s     rA   
<listcomp>z,fixup_container_fwd_refs.<locals>.<listcomp>   sD        )34(=(=GJt$$$4  r@   )ro   typing_get_origindictrq   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__rs   typing_get_argsrw   s    rA   fixup_container_fwd_refsr      s     	5
e$$&*+#$	


 

 A4;;
 


( !''99  / 6 6   
 
 	
 Lr@   GenericProtocol[_T]rv   r7   rD   c                f    t          | d          r|                     |          S | j        |         S )N	copy_with)hasattrr   rE   )rY   rv   s     rA   rt   rt      s:     z;'' /##H--- $X..r@   rc   
expressionmodule_nameOptional[Mapping[str, Any]]rd   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]   rd   base_globalskecls_namespacerY   errs	            rA   rn   rn      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 )rn   r   r   r   r   r   builtins)r   r   r]   r   r   s        rA   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      rA   resolve_name_to_real_class_namer   D  sP    .T;// sJ---    s   # 22rT   c               @     t           fd|j        D              S )Nc           	     8    g | ]}t          |i            S )r   rf   )rh   annorW   r[   rT   s     rA   r{   z/de_stringify_union_elements.<locals>.<listcomp>V  sI     	

 	

 	

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

 	

 	

r@   )make_union_typer8   )rW   rY   r[   r]   rT   s   ` ` `rA   de_stringify_union_elementsr   M  sI     	

 	

 	

 	

 	

 	

 #+	

 	

 	

 r@   Optional[_AnnotationScanType]c                6    | d uot          |           t          u S rK   )r|   r   r   s    rA   	is_pep593r   c  s     F!25!9!9Y!FFr@   r   TypeGuard[Iterable[Any]]c                p    t          | t          j                  ot          | t          t          f           S rK   )rm   r   r   r\   bytes)r   s    rA   is_non_string_iterabler   g  s6    c?344 Zc5\> > : r@   c                .    t          |           t          v S rK   )r   _LITERAL_TYPESr   s    rA   rp   rp   m  s    e..r@   TypeGuard[NewType]c                "    t          | d          S )N__supertype__r   r   s    rA   
is_newtyper   q  s    5/***r@   TypeGuard[GenericProtocol[Any]]c                B    t          | d          ot          | d          S )Nr8   rE   r   r   s    rA   ro   ro   y  s!    5*%%F'%*F*FFr@   TypeGuard[TypeAliasType]c                ,    t          | t                    S rK   )rm   r)   r   s    rA   	is_pep695r   }  s    e]+++r@   r   c                ^    | j         }t          |          r|j         }t          |          |S rK   )r   r   )rw   
super_types     rA   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)rk   )rh   args     rA   rj   zis_fwd_ref.<locals>.<genexpr>  s,      CCS:c4((CCCCCCr@   F)rm   r	   ro   anyr8   )rw   r   s     rA   rk   rk     sV     %$$ t	 :e,, CCENCCCCCCur@   c                    d S rK   r?   r   s    rA   de_optionalize_union_typesr     s    363r@   c                    d S rK   r?   r   s    rA   r   r     s    ?Bsr@   c                    d S rK   r?   r   s    rA   r   r     s	     #r@   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``.

    )	rk   "de_optionalize_fwd_ref_union_typesis_optionalrq   r8   discardr3   NoneFwdr   )rw   typs     rA   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 )r4   r   rz   s     rA   r{   z6de_optionalize_fwd_ref_union_types.<locals>.<listcomp>  s%    JJJt46>>*T"">>>r@   z\s*\|\s*r4   |c              3  &   K   | ]}|d k    |V  dS )r4   Nr?   )rh   ps     rA   rj   z5de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s&      "I"IQ&[[1[[[["I"Ir@   )rl   r   r   groupr	   splitr   join)rw   rY   mmrv   pipe_tokenss        rA   r   r     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   rQ   )r   s    rA   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_unionrq   r8   r   r3   rs   )rw   r   r   r   s       rA   expand_unionsr     si      %.!! 	"KK!!! 	8eCjj((::xr@   TypeGuard[ArgsTypeProcotol]c                &    t          | ddd          S )Nr   r   	UnionTypeis_origin_ofr   s    rA   r   r     s     	  r@   c                L    t          |           ot          t          |           v S rK   )r   r3   r   r   s    rA   is_optional_unionr     s"    uD(oe.D.D"DDr@   c                "    t          | d          S )Nr   r   r   s    rA   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|   rm   type
issubclass)rw   r   origins      rA   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)rw   r   r   r   s       rA   r   r     sR     u%%F~u&!!U* $>&+66v>>r@   c                t    t           j        r| j        S t          | dd           }|t          | dd           }|S )Nr:   _name)r   py310r:   r   )rw   typ_names     rA   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   rH   c                    d S rK   r?   rL   r  r  s      rA   __get__zDescriptorProto.__get__.  rN   r@   valuer4   c                    d S rK   r?   rL   r  r  s      rA   __set__zDescriptorProto.__set__0  rN   r@   c                    d S rK   r?   rL   r  s     rA   
__delete__zDescriptorProto.__delete__2  rN   r@   N)r  r  r  r   rH   r   )r  r   r  r   rH   r4   r  r   rH   r4   )r:   r;   r<   r  r  r  r?   r@   rA   r  r  -  s4        ????====444444r@   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   rH   r  c                    d S rK   r?   r
  s      rA   r  zDescriptorReference.__get__E  rN   r@   r  r4   c                    d S rK   r?   r  s      rA   r  zDescriptorReference.__set__G  rN   r@   c                    d S rK   r?   r  s     rA   r  zDescriptorReference.__delete__I  rN   r@   N)r  r  r  r   rH   r  )r  r   r  r  rH   r4   r  r:   r;   r<   r=   r   r  r  r  r?   r@   rA   r  r  8  sR           9EEEECCCC8888889 9r@   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   rH   r  c                    d S rK   r?   r
  s      rA   r  zRODescriptorReference.__get__Y  rN   r@   r  r   c                    d S rK   r?   r  s      rA   r  zRODescriptorReference.__set__[  rN   r@   c                    d S rK   r?   r  s     rA   r  z RODescriptorReference.__delete__]  rN   r@   N)r  r  r  r   rH   r  )r  r   r  r   rH   r   )r  r   rH   r   r  r?   r@   rA   r  r  O  sR           =HHHHEEEE<<<<<<= =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   rH   r!  c                    d S rK   r?   r
  s      rA   r  zCallableReference.__get__n  rN   r@   r  r4   c                    d S rK   r?   r  s      rA   r  zCallableReference.__set__p  rN   r@   c                    d S rK   r?   r  s     rA   r  zCallableReference.__delete__r  rN   r@   N)r  r  r  r   rH   r!  )r  r   r  r!  rH   r4   r  r  r?   r@   rA   r#  r#  c  sR           9CCCCAAAA8888889 9r@   r#  )rW   rX   rY   rZ   r[   r\   r]   r^   rT   r_   rU   r`   rV   ra   rH   rX   )rw   rZ   rH   rZ   )rY   r   rv   r7   rH   rD   )
r   r\   r   r\   r]   r   rd   r   rH   r   )r   r\   r   r\   r]   r   rH   r   )r   r\   r   r\   rH   r\   )rW   rX   rY   r6   r[   r\   r]   r^   rT   r_   rH   rX   )rw   r   rH   r`   )r   r   rH   r   )rw   rZ   rH   r`   )rw   r   rH   r   )rw   rZ   rH   r   )rw   rZ   rH   r   )rw   r   rH   rX   )F)rw   rZ   r   r`   rH   r   )rw   r\   rH   r\   )rw   rX   rH   rX   )rw   r	   rH   rZ   )r   rZ   rH   rX   )FF)rw   rX   r   r`   r   r`   rH   r   )rw   r   rH   r   )rw   r   rH   r`   )rw   r   r   r   rH   r`   )rw   r   r   r\   r   r   rH   r`   )rw   rX   rH   r\   )e
__future__r   r   collections.abcabcr   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/   r1   r2   py38	frozensetr   r  r   r3   r   r   r   r|   r\   rZ   r6   rC   rG   _LiteralStarrg   r   rt   rn   r   r   r   r   r   rp   r   ro   r   r   rk   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r!  r#  r?   r@   rA   <module>r0     se   # " " " " "  ) ) ) ) ) ) 				 



                                                                                                                         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......@@@@@@WTgenn	T	*	*	*W\666
genn	T	*	*	*	; * Y899NNYy))N 
<  +******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. . . . ;?     ,G G G G   / / / /+ + + +G G G G, , , ,    7<     
 6 6 6 
 6 
 B B B 
 B 
   

   .   >/ / / / IN    (   E E E E( ( ( (
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 9 9r@   