
    *'&hW                    ,   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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m0Z0 d d*lm1Z1  ed+e,          Z2 ed-          Z3 ed.d/          Z4 ed0d1          Z5 ed2          Z6 ed3d/          Z7ej8        rd d4l9m:Z: n e;d          Z:dd9Z<eee         e=eee/d:f         Z> G d; d<e)          Z? G d= d>e)e2                   Z@ G d? d@e)e3e7f                   ZAe&dA         ZBddBddCddQZCddSZDddXZEdddYdd_ZFdd`ddbZGddcZHddeZIddhZJddiZKddlZLddnZMddpZNddrZOddtZP	 	 dddxZQeddy            ZReddz            ZRedd{            ZRdd|ZRedd            ZSedd            ZSddZSddZTddZUddZVddZWddZXddddZYddZZ 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                  ,          Z` G d dee`                   Za G d d          Zb eb            ZcereZdnecZdecj&        ZedS )    )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)NoneTypetypr   returnboolc                B    t          | t                    o
| j        dk    S )NNone)
isinstancer	   __forward_arg__)r7   s    Q/var/www/html/reinick/venv/lib/python3.11/site-packages/sqlalchemy/util/typing.pyis_fwd_noner?   M   s    c:&&H3+>&+HH    z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__ r@   r>   rB   rB   V   s*           .-----r@   rB   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

    rC   rD   Type[_T]
__origin__NrE   rK   r@   r>   rM   rM   `   s6           .---r@   rM   c                      e Zd Zd	dZd
dZdS )SupportsKeysAndGetItemr8   Iterable[_KT]c                    d S NrK   )selfs    r>   keyszSupportsKeysAndGetItem.keysu         r@   _SupportsKeysAndGetItem__kr/   r5   c                    d S rT   rK   )rU   rX   s     r>   __getitem__z"SupportsKeysAndGetItem.__getitem__w   rW   r@   N)r8   rR   )rX   r/   r8   r5   )rF   rG   rH   rV   rZ   rK   r@   r>   rQ   rQ   t   s(        ((((222222r@   rQ   *Fstr_cleanup_fninclude_generic_already_seencls	Type[Any]
annotation_AnnotationScanTypeoriginating_modulestrlocals_Mapping[str, Any]r]   #Optional[Callable[[str, str], str]]r^   r_   Optional[Set[Any]]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.

    rf   in_classNc           
   3  D   K   | ]}t          |           V  dS )r\   N)de_stringify_annotation).0elemr_   r`   r^   rf   rd   r]   s     r>   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s]       
 
  $"- /+  
 
 
 
 
 
r@   )
is_fwd_refr=   r<   re   eval_expression
is_generic
is_literalsetaddtuplerD   _copy_generic_annotation_with)	r`   rb   rd   rf   r]   r^   r_   original_annotationelementss	   ` `````  r>   rn   rn   ~   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 rK   )r<   re   r	   ro   rp   s     r>   
<listcomp>z,fixup_container_fwd_refs.<locals>.<listcomp>   sD        )34(=(=GJt$$$4  r@   )rt   r    dictrv   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__rx   r   r|   s    r>   fixup_container_fwd_refsr      s     	5
u&*+#$	


 

 A4;;
 


( %  22  (   
 
 	
 Lr@   GenericProtocol[_T]r{   rC   rN   c                f    t          | d          r|                     |          S | j        |         S )N	copy_with)hasattrr   rO   )rb   r{   s     r>   ry   ry      s:     z;'' /##H--- $X..r@   rk   
expressionmodule_nameOptional[Mapping[str, Any]]rl   Optional[Type[Any]]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   
setdefaultrF   updateeval	Exception)	r   r   rf   rl   base_globalskecls_namespacerb   errs	            r>   rs   rs      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rf   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 )rs   r   r   r   r   r   builtins)r   r   rf   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)NrF   )r   getattrr   )r   r   objs      r>   resolve_name_to_real_class_namer   ?  sP    .T;// sJ---    s   # 22Optional[Any]c                @    | d uot          |           t          j        v S rT   )r    _type_tuplesr   r   s    r>   	is_pep593r   H  s"    LE!2!2l6L!LLr@   r   TypeGuard[Iterable[Any]]c                p    t          | t          j                  ot          | t          t          f           S rT   )r<   r   r   re   bytes)r   s    r>   is_non_string_iterabler   L  s6    c?344 Zc5\> > : r@   c                8    t          |           t          j        v S rT   )r    r   r!   r   s    r>   ru   ru   R  s    e 444r@   Optional[_AnnotationScanType]TypeGuard[NewType]c                "    t          | d          S )N__supertype__r   r   s    r>   
is_newtyper   V  s    5/***r@   TypeGuard[GenericProtocol[Any]]c                B    t          | d          ot          | d          S )NrD   rO   r   r   s    r>   rt   rt   ^  s!    5*%%F'%*F*FFr@   TypeGuard[TypeAliasType]c                |    t          |           rt          | j                  S t          | t          j                  S rT   )rt   	is_pep695rO   r<   _type_instancesr*   r   s    r>   r   r   b  s8    
 % +)***e_:;;;r@   r   c                ^    | j         }t          |          r|j         }t          |          |S rT   )r   r   )r|   
super_types     r>   flatten_newtyper   l  s:    $J
Z
 
  .-
 Z
 
  .r@   Set[Any]c                   t                      fd |           }t          |t                    rt                      }t          |          }|rp|                                }t          |t                    r|                    |           n/|                    |t          u st          |          rdn|           |p|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 rK   rK   )ro   trecursive_values     r>   r   z:pep695_values.<locals>.recursive_value.<locals>.<listcomp>  s#    ;;;q"";;;r@   )rw   r   	__value__is_unionrD   )
inner_typevalue_seenr   s     r>   r   z&pep695_values.<locals>.recursive_value|  su     		*$$ 	$ 	L;;;;EN;;;;r@   N)	rv   r<   r   r   popleftextendrw   r6   r?   )r|   restypesstackr   r   r   s        @@r>   pep695_valuesr   s  s     EEE< < < < < < /%
 
 C#t c

 	JA!T"" JQ		!x--;q>>-$$qIII  	J ur@   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)rr   )ro   argr   s     r>   rq   zis_fwd_ref.<locals>.<genexpr>  sP       
 
  T2H  
 
 
 
 
 
r@   F)r<   re   r   r	   rt   anyrD   )r|   r   r   s     `r>   rr   rr     s    
  *UC"8"8 t	E?5	6	6 
t	 :e,,  
 
 
 
 ~	
 
 
 
 
 	
 ur@   c                    d S rT   rK   r   s    r>   de_optionalize_union_typesr     s    363r@   c                    d S rT   rK   r   s    r>   r   r     s    ?Bsr@   c                    d S rT   rK   r   s    r>   r   r     	     #r@   c                
   t          |           rt          | d          S t          |           rt          |           rt          j        rt          | j                  }nt          | g          }t                      }|rZ|	                                }|j        D ]<}t          |          r|
                    |           '|                    |           =|Z|                    d           d |D             }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)

    FNc                B    h | ]}|t           ut          |          |S rK   )r6   r?   ro   r   s     r>   	<setcomp>z-de_optionalize_union_types.<locals>.<setcomp>  s-    JJJQ(!2!2;q>>!2q!2!2!2r@   )rr   #_de_optionalize_fwd_ref_union_typesr   includes_noner   py39rv   rD   r   r   appendrw   discardmake_union_type)r|   r7   stack_of_unionsu_typrp   s        r>   r   r     s    % 25%@@@	% ]511 ; 	en%%CC $UGnnO%%C! &'//11!N & &D~~ &'..t4444 " & KKJJ#JJJ$$ r@   r	   return_has_noneLiteral[True]c                    d S rT   rK   r|   r   s     r>   r   r     s	     3r@   Literal[False]c                    d S rT   rK   r   s     r>   r   r     r   r@    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 )r;   r   r   s     r>   r   z7_de_optionalize_fwd_ref_union_types.<locals>.<listcomp>  s%    MMM$dfnnZ%%nnnr@   Fz\s*\|\s*r;   |c              3  &   K   | ]}|d k    |V  dS )r;   NrK   )ro   ps     r>   rq   z6_de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s&      BB!a6kkAkkkkBBr@   )r=   r   r   groupsplitr	   r   joinstripclearlenr   r+   )r|   r   rb   mmg1r{   currentignore_commacharpartspipe_tokenshas_noneanno_strs                r>   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:Lr@   r   c                     t           |          S )zMake a Union type.r   )r   s    r>   r   r   $  s     <r@   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          dfv pt          |           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 rT   r   r   s     r>   rq   z includes_none.<locals>.<genexpr>9  s*      ===##======r@   r   c              3  4   K   | ]}t          |          V  d S rT   r  r   s     r>   rq   z includes_none.<locals>.<genexpr>=  s*      BB=##BBBBBBr@   NF)rr   r   r   r   r   r   r   r   r   r   r   r6   r?   	TypeErrorr   s    r>   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4((>K,>,>>    uu	s   C9 9
DDc                    t          | t                    p9t          | d          p)| j        dv p t          |           j        d         j        dv S )NrO   )typingtyping_extensionsr   )r<   typer   rG   __mro__r   s    r>   	is_a_typer  I  s[    5$ 	P5,''	P>>	P ;;q!,0OO	r@   TypeGuard[ArgsTypeProtocol]c                $    t          | dd          S )Nr   	UnionType)is_origin_ofr   s    r>   r   r   R  s    w444r@   	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    r<   r  
issubclass)r|   r!  origins      r>   is_origin_of_clsr&  V  s:     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_namerG   
startswith)r|   r'  r(  r%  s       r>   r   r   c  sR     F~u&!!U* $>&+66v>>r@   c                t    t           j        r| j        S t          | dd           }|t          | dd           }|S )NrF   _name)r   py310rF   r   )r|   typ_names     r>   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   r8   c                    d S rT   rK   rU   r3  r5  s      r>   __get__zDescriptorProto.__get__~  rW   r@   r   r;   c                    d S rT   rK   rU   r3  r   s      r>   __set__zDescriptorProto.__set__  rW   r@   c                    d S rT   rK   rU   r3  s     r>   
__delete__zDescriptorProto.__delete__  rW   r@   N)r3  r4  r5  r   r8   r   )r3  r   r   r   r8   r;   r3  r   r8   r;   )rF   rG   rH   r8  r;  r>  rK   r@   r>   r2  r2  }  s4        ????====444444r@   r2  _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

    r3  r4  r5  r   r8   r@  c                    d S rT   rK   r7  s      r>   r8  zDescriptorReference.__get__  rW   r@   r   r;   c                    d S rT   rK   r:  s      r>   r;  zDescriptorReference.__set__  rW   r@   c                    d S rT   rK   r=  s     r>   r>  zDescriptorReference.__delete__  rW   r@   N)r3  r4  r5  r   r8   r@  )r3  r   r   r@  r8   r;   r?  rF   rG   rH   rI   r   r8  r;  r>  rK   r@   r>   rB  rB    sR           9EEEECCCC8888889 9r@   rB  _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

    r3  r4  r5  r   r8   rG  c                    d S rT   rK   r7  s      r>   r8  zRODescriptorReference.__get__  rW   r@   r   r   c                    d S rT   rK   r:  s      r>   r;  zRODescriptorReference.__set__  rW   r@   c                    d S rT   rK   r=  s     r>   r>  z RODescriptorReference.__delete__  rW   r@   N)r3  r4  r5  r   r8   rG  )r3  r   r   r   r8   r   )r3  r   r8   r   rF  rK   r@   r>   rI  rI    sR           =HHHHEEEE<<<<<<= =r@   rI  _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


    r3  r4  r5  r   r8   rM  c                    d S rT   rK   r7  s      r>   r8  zCallableReference.__get__  rW   r@   r   r;   c                    d S rT   rK   r:  s      r>   r;  zCallableReference.__set__  rW   r@   c                    d S rT   rK   r=  s     r>   r>  zCallableReference.__delete__  rW   r@   N)r3  r4  r5  r   r8   rM  )r3  r   r   rM  r8   r;   r?  rF  rK   r@   r>   rO  rO    sR           9CCCCAAAA8888889 9r@   rO  c                      e Zd ZddZdS )_TypingInstanceskeyre   r8   tuple[type, ...]c           	         t          d t          t          |d           t          t          |d           fD                       }|st	          |          || j        |<   |S )Nc                    h | ]}||S rT   rK   r   s     r>   r   z/_TypingInstances.__getattr__.<locals>.<setcomp>  s)        = 
 !==r@   )rx   r   r  r  AttributeErrorr   )rU   rU  r   s      r>   __getattr__z_TypingInstances.__getattr__  sy      FC..-sD99  	
 	
  	& %%%"cr@   N)rU  re   r8   rV  )rF   rG   rH   rZ  rK   r@   r>   rT  rT    s(             r@   rT  )r7   r   r8   r9   )r`   ra   rb   rc   rd   re   rf   rg   r]   rh   r^   r9   r_   ri   r8   ra   )r|   rc   r8   rc   )rb   r   r{   rC   r8   rN   )
r   re   r   re   rf   r   rl   r   r8   r   )r   re   r   re   rf   r   r8   r   )r   re   r   re   r8   re   )r|   r   r8   r9   )r   r   r8   r   )r|   r   r8   r9   )r|   r   r8   r   )r|   rc   r8   r   )r|   rc   r8   r   )r|   r   r8   ra   )r|   rc   r8   r   )FF)r|   rc   r   r9   r   r9   r8   r   )r|   re   r8   re   )r|   ra   r8   ra   )r|   r	   r   r   r8   r9   )r|   r	   r   r   r8   rc   )r|   r	   r   r9   r8   r   )r   rc   r8   ra   )r|   r   r8   r  )r|   r   r!  r"  r8   r9   )r|   r   r(  re   r'  r)  r8   r9   )r|   ra   r8   re   )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/   r0   r2   r4   r5   r/  r   r6   r  r?   re   rc   rB   rM   rQ   _LiteralStarrn   r   ry   rs   r   r   r   r   ru   r   rt   r   r   r   rr   r   r   r   r   r  r   r&  r   r+  r2  r@  rB  rG  rI  rM  rO  rT  r   r   LITERAL_TYPESrK   r@   r>   <module>ra     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I I I I 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 
   

% % % %P 
   

 
   

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$r@   