
    e?1i=                    x   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jb                  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<	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dfd=Z>	 	 	 	 	 	 dgd>Z?dd?	 	 	 	 	 	 	 dhd@Z@dd?	 	 	 	 	 	 	 didAZAdjdBZBddC	 	 	 	 	 	 	 	 	 	 	 dkdDZCdldEZDdmdFZEdndGZFdodHZGdpdIZH	 dq	 	 	 	 	 drdJZIedsdK       ZJedtdL       ZJe	 	 	 	 dudM       ZJ	 	 	 	 dudNZJ	 	 	 	 dvdOZKdwdPZL	 dx	 	 	 	 	 	 	 dydQZMdzdRZNd{dSZOdzdTZP	 	 	 	 	 	 d|dUZQddV	 	 	 	 	 	 	 d}dWZRd~dXZS G dY dZe%      ZT ed[eT)      ZU G d\ d]eeU         ZV ed^eTd_      ZW G d` daeeW         ZX edbeedcef      )      ZY G dd deeeY         ZZy)    )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<   y)ArgsTypeProcotolz_protocol for types that have ``__args__``

    there's no public interface for this AFAIK

    Tuple[_AnnotationScanType, ...]__args__N__name__
__module____qualname____doc____annotations__     `/home/www/therecruiter.miabetepe.com/venv/lib/python3.12/site-packages/sqlalchemy/util/typing.pyr4   r4   S   s     .-r>   r4   c                  &    e Zd ZU dZded<   ded<   y)GenericProtocolzXprotocol for generic types.

    this since Python.typing _GenericAlias is private

    r5   r6   Type[_T]
__origin__Nr7   r=   r>   r?   rA   rA   ]   s     .-r>   rA   c                      e Zd ZddZddZy)SupportsKeysAndGetItemc                     y Nr=   )selfs    r?   keyszSupportsKeysAndGetItem.keysr       r>   c                     y rG   r=   )rH   _SupportsKeysAndGetItem__ks     r?   __getitem__z"SupportsKeysAndGetItem.__getitem__u   rJ   r>   N)returnzIterable[_KT])rL   r*   rN   r0   )r8   r9   r:   rI   rM   r=   r>   r?   rE   rE   q   s    r>   rE   *Fstr_cleanup_fninclude_generic_already_seenc               j    |}t        |      r|j                  }t        |t              rr	 |      }t	        |      }rht        |      r]t        |      sR
t               |v r|S j                  |       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.

    locals_c           
   3  B   K   | ]  }t        |         yw)rP   N)de_stringify_annotation).0elemrS   clsrR   rV   originating_modulerQ   s     r?   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s:      
  $"- /+ 
s   )
is_fwd_ref__forward_arg__
isinstancestreval_expression
is_generic
is_literalsetaddtupler6   _copy_generic_annotation_with)	r[   
annotationr\   rV   rQ   rR   rS   original_annotationelementss	   ` `````  r?   rX   rX   }   s    . %*//
*c"'
4FGJ$*G


 	z":& EM&
 '&j) 
 
 #++
 
 -ZBBr>   c                Z    t        | d      r| j                  |      S | j                  |   S )N	copy_with)hasattrrm   rC   )ri   rk   s     r?   rh   rh      s2     z;'##H-- $$X..r>   rU   c                   	 t         j                  |   j                  }	 t        | ||      }|S # t        $ r}t	        d| d|        |d }~ww xY w# 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)
expressionmodule_namerV   base_globalskeri   errs          r?   rb   rb      s    '*{{;'?'H'H*lG<
   k] ###-,0
 	  0?
	s+   / A 	AA

A	A/A**A/c               J   d| v rt        | ||      S 	 t        j                  |   j                  }	 ||    S # t        $ r}t        d| d|        |d }~ww xY w# t        $ r?}	 t        j                  |    cY d }~S # t        $ r Y nw xY wt        d|  d|       |d }~ww xY w)N.rU   rp   z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rb   rq   rr   rs   rt   ru   builtins)namery   rV   rz   r{   s        r?   eval_name_onlyr      s     d{t['BB'*{{;'?'H'HD!!  k] # 6#
 	  		$$T** 		 $TF+k]C
		sJ   7 A 	A AA	B"$A<6B"<	BBBBB"c                X    	 t        | |      }t        |d|       S # t        $ r | cY S w xY w)Nr8   )r   getattrru   )r   ry   objs      r?   resolve_name_to_real_class_namer     s:    .T;/ sJ--  s    ))rQ   c               h    t        |j                  D cg c]  }t        | ||i |       c} S c c}w )Nr   )make_union_typer6   rX   )r[   ri   r\   rV   rQ   annos         r?   de_stringify_union_elementsr     sJ      #++	

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

 	

s   /c                0    | d uxr t        |       t        u S rG   )typing_get_originr   type_s    r?   	is_pep593r   '  s    F!25!9Y!FFr>   c                $    t        |       t        u S rG   )r   r   r   s    r?   rd   rd   +  s    e''r>   c                    t        | d      S )N__supertype__rn   r   s    r?   
is_newtyper   /  s    5/**r>   c                6    t        | d      xr t        | d      S )Nr6   rC   r   r   s    r?   rc   rc   7  s    5*%F'%*FFr>   c                d    | j                   }t        |      r|j                   }t        |      r|S rG   )r   r   )r   
super_types     r?   flatten_newtyper   ;  s0    $$J
Z
 --
 Z
 r>   c                x    t        | t              ry|r't        |       rt        d | j                  D              S y)NTc              3  4   K   | ]  }t        |d         yw)TN)r^   )rY   args     r?   r]   zis_fwd_ref.<locals>.<genexpr>H  s     CS:c4(Cs   F)r`   r   rc   anyr6   )r   check_generics     r?   r^   r^   B  s3     %$	:e,CENNCCCr>   c                     y rG   r=   r   s    r?   de_optionalize_union_typesr   M      r>   c                     y rG   r=   r   s    r?   r   r   R  r   r>   c                     y rG   r=   r   s    r?   r   r   W  s     r>   c                    t        |       rt        |       S t        |       rGt        | j                        }|j                  t               |j                  t               t        | S | S )zmGiven a type, filter out ``Union`` types that include ``NoneType``
    to not include the ``NoneType``.

    )	r^   "de_optionalize_fwd_ref_union_typesis_optionalre   r6   discardr1   NoneFwdr   )r   typs     r?   r   r   ^  sW     %1%88	U	%..!HG$$ r>   c                   | j                   }t        j                  d|      }|r|j                  d      dk(  rt	        |j                  d            S |j                  d      dk(  rJt        j
                  d|j                  d            }t        |D cg c]  }|dk7  s	t	        |       c} S | S t        j
                  d|      }d|v r!t	        d	j                  d
 |D                    S | S c c}w )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*r2   z\s*\|\s*|c              3  ,   K   | ]  }|d k7  s	|  yw)r2   Nr=   )rY   ps     r?   r]   z5de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s     "IQ&[1"Is   
)r_   rematchgroupr   splitr   join)r   ri   mmrk   rZ   pipe_tokenss         r?   r   r   u  s     &&J	$j	1B	88A;*$bhhqk**XXa[G#xx!5H"/7Jt46>*T"J  L((;
3K#(("Ik"IIJJL Ks   
C0 C0c                 H    t        t        t              j                  |       S )zMake a Union type.

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

    )r   r   r   rM   )typess    r?   r   r     s     U''..r>   c                    t        |       rHt        | j                        }|r|j                  t               |r| ft        |      z   S t        |      S | fS )zPReturn a type as a tuple of individual types, expanding for
    ``Union`` types.)is_unionre   r6   r   r1   rg   )r   include_uniondiscard_noner   s       r?   expand_unionsr     sM     %..!KK!8eCj((:xr>   c                    t        | ddd      S )Nr   r   	UnionTypeis_origin_ofr   s    r?   r   r     s    	 r>   c                >    t        |       xr t        t        |       v S rG   )r   r1   typing_get_argsr   s    r?   is_optional_unionr     s    uD(oe.D"DDr>   c                    t        | d      S )Nr   r   r   s    r?   r   r     s    w''r>   c                Z    t        |       }|yt        |t              xr t        ||      S )z[return True if the given type has an __origin__ that shares a base
    with the given classF)r   r`   type
issubclass)r   	class_objorigins      r?   is_origin_of_clsr     s/     u%F~fd#E
69(EEr>   )modulec               ~    t        |       }|yt        |      |v xr! |du xs |j                  j                  |      S )z\return True if the given type has an __origin__ with the given name
    and optional module.NF)r   _get_type_namer9   
startswith)r   r   namesr   s       r?   r   r     sJ     u%F~&!U* $>&++66v>r>   c                v    t         j                  r| j                  S t        | dd       }|t        | dd       }|S )Nr8   _name)r   py310r8   r   )r   typ_names     r?   r   r     s:    ||~~5*d3ugt4Hr>   c                  $    e Zd ZddZddZddZy)DescriptorProtoc                     y rG   r=   rH   instanceowners      r?   __get__zDescriptorProto.__get__  rJ   r>   c                     y rG   r=   rH   r   values      r?   __set__zDescriptorProto.__set__  rJ   r>   c                     y rG   r=   rH   r   s     r?   
__delete__zDescriptorProto.__delete__  rJ   r>   N)r   objectr   r   rN   r   )r   r   r   r   rN   r2   r   r   rN   r2   )r8   r9   r:   r   r   r   r=   r>   r?   r   r     s    r>   r   _DESCc                  .    e Zd ZdZerddZddZddZyy)	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

    c                     y rG   r=   r   s      r?   r   zDescriptorReference.__get__      r>   c                     y rG   r=   r   s      r?   r   zDescriptorReference.__set__  r   r>   c                     y rG   r=   r   s     r?   r   zDescriptorReference.__delete__  r   r>   N)r   r   r   r   rN   r   )r   r   r   r   rN   r2   r   r8   r9   r:   r;   r   r   r   r   r=   r>   r?   r   r     s      			 r>   r   _DESC_co)r)   r,   c                  .    e Zd ZdZerddZddZddZyy)	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

    c                     y rG   r=   r   s      r?   r   zRODescriptorReference.__get__  r   r>   c                     y rG   r=   r   s      r?   r   zRODescriptorReference.__set__  r   r>   c                     y rG   r=   r   s     r?   r   z RODescriptorReference.__delete__"  r   r>   N)r   r   r   r   rN   r   )r   r   r   r   rN   r   )r   r   rN   r   r   r=   r>   r?   r   r     s      			 r>   r   _FN.c                  .    e Zd ZdZerddZddZddZyy)	CallableReferenceza descriptor that refers to a callable.

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


    c                     y rG   r=   r   s      r?   r   zCallableReference.__get__4  r   r>   c                     y rG   r=   r   s      r?   r   zCallableReference.__set__7  r   r>   c                     y rG   r=   r   s     r?   r   zCallableReference.__delete__:  r   r>   N)r   r   r   r   rN   r   )r   r   r   r   rN   r2   r   r   r=   r>   r?   r   r   )  s      			 r>   r   )r[   	Type[Any]ri   _AnnotationScanTyper\   ra   rV   Mapping[str, Any]rQ   #Optional[Callable[[str, str], str]]rR   boolrS   zOptional[Set[Any]]rN   r   )ri   zGenericProtocol[_T]rk   r5   rN   rB   )rx   ra   ry   ra   rV   Optional[Mapping[str, Any]]rN   r   )r   ra   ry   ra   rV   r   rN   r   )r   ra   ry   ra   rN   ra   )r[   r   ri   r4   r\   ra   rV   r   rQ   r   rN   r   )r   Optional[_AnnotationScanType]rN   r   )r   r   rN   r   )r   r   rN   zTypeGuard[NewType])r   r   rN   zTypeGuard[GenericProtocol[Any]])r   r   rN   r   )F)r   r   r   r   rN   zTypeGuard[ForwardRef])r   ra   rN   ra   )r   r   rN   r   )r   r   rN   r   )r   r   rN   r   )r   r   rN   r   )FF)r   r   r   r   r   r   rN   zTuple[Type[Any], ...])r   r   rN   zTypeGuard[ArgsTypeProcotol])r   r   rN   r   )r   r   r   z'Union[Tuple[Type[Any], ...], Type[Any]]rN   r   )r   r   r   ra   r   zOptional[str]rN   r   )r   r   rN   ra   )[
__future__r   r   r   rq   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   r   r   r1   r   r   r   r   ra   r   r4   rA   rE   _LiteralStarrX   rh   rb   r   r   r   r   rd   r   rc   r   r^   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r=   r>   r?   <module>r     s4   #  	 
                     8< 106:4<86@888. Ten	T	*\6
en	T	* 
<< +DzH
V
  IsJ)?? 
.x .hrl (Xc6k2  s| ;?!(,C	C#C C 	C 8C C &C CL/#//N// ,0	 )	
 	8 ,0	
 )	
 	D. ;?	   	 8 ,G(+G 7</3 
 
 
 
 
 
.>/ IN%)AE(E(
F
FB
F	
F 6:%2	h  	/'%. . :_EGH- ( e8HS#X$678 r>   