
    pXHhW                    8   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jp                  rd d4l9m:Z: n e;d      Z:dod5Z<eee   e=eee/d6f   Z> G d7 d8e)      Z? G d9 d:e)e2         Z@ G d; d<e)e3e7f         ZAe&d=   ZBdd>dd?	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dpd@ZC	 	 	 	 dqdAZD	 	 	 	 	 	 drdBZEdddC	 	 	 	 	 	 	 	 	 dsdDZFddE	 	 	 	 	 	 	 dtdFZGdudGZHdvdHZIdwdIZJdxdJZKdydKZLdzdLZMd{dMZNd|dNZOd}dOZP	 	 d~	 	 	 	 	 	 	 ddPZQeddQ       ZReddR       ZRe	 	 	 	 dqdS       ZR	 	 	 	 dqdTZRe	 	 	 	 	 	 ddU       ZSe	 	 	 	 	 	 ddV       ZS	 	 	 	 	 	 ddWZSddXZTdxdYZUdxdZZVdd[ZW	 	 	 	 	 	 dd\ZXdd]	 	 	 	 	 	 	 dd^ZYdd_ZZ G d` dae)      Z[ edbe[,      Z\ G dc ddee\         Z] edee[df      Z^ G dg dhee^         Z_ edieedjef      ,      Z` G dk dlee`         Za G dm dn      Zb eb       ZcereZdecjL                  ZeyecZdecjL                  Zey)    )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)NoneTypec                D    t        | t              xr | j                  dk(  S )NNone)
isinstancer   __forward_arg__)typs    O/var/www/html/planif/env/lib/python3.12/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<   y)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;   r?   r?   V   s     .-r=   r?   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

    r@   rA   Type[_T]
__origin__NrB   rH   r=   r;   rJ   rJ   `   s     .-r=   rJ   c                      e Zd ZddZddZy)SupportsKeysAndGetItemc                     y NrH   )selfs    r;   keyszSupportsKeysAndGetItem.keysu       r=   c                     y rP   rH   )rQ   _SupportsKeysAndGetItem__ks     r;   __getitem__z"SupportsKeysAndGetItem.__getitem__w   rS   r=   N)returnzIterable[_KT])rU   r.   rW   r4   )rC   rD   rE   rR   rV   rH   r=   r;   rN   rN   t   s    (2r=   rN   *Fstr_cleanup_fninclude_generic_already_seenc               l    |}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_in_classc           
   3  B   K   | ]  }t        |         yw)rY   N)de_stringify_annotation).0elemr\   clsr[   r_   originating_modulerZ   s     r;   	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>   s:      
  $"- /+ 
s   )
is_fwd_refr9   r8   streval_expression
is_generic
is_literalsetaddtuplerA   _copy_generic_annotation_with)	re   
annotationrf   r_   rZ   r[   r\   original_annotationelementss	   ` `````  r;   rb   rb   ~   s    . %*//
*c"'
4FGJ$*Gc


 	z":& EM&
 '&j) 
 
 #++
 
 -ZBBr=   c                   t        |       rt        |       t        t        t        t
        j                  t
        j                  t
        j                  t
        j                  t
        j                  fv rtt        j                  dt        |             sUt        |       j                  t        t!        |       D cg c]  }t#        |t$              rt'        |      n|! c}            S | S c c}w )zfCorrect dict['x', 'y'] into dict[ForwardRef('x'), ForwardRef('y')]
    and similar for list, set

    z3typing.(?:Dict|List|Set|.*Mapping|.*Sequence|.*Set))rk   r   dictrm   listcollections_abc
MutableSetMutableMappingMutableSequencer   Sequencerematchrepr__class_getitem__ro   r   r8   ri   r   )type_rd   s     r;   fixup_container_fwd_refsr      s     	5u&&**++##$$	


 A4;

 % 22 !) )34(=Jt$4G
 	
 Ls   8$C)c                Z    t        | d      r| j                  |      S | j                  |   S )N	copy_with)hasattrr   rL   )rq   rs   s     r;   rp   rp      s2     z;'##H-- $$X..r=   r^   c                  	 t         j                  |   j                  }	 |Qt        |j                        }|j                  |j                  |       |j                  |       t        | ||      }|S 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	NameErrorru   
setdefaultrC   updateeval	Exception)	
expressionmodule_namer_   r`   base_globalskecls_namespacerq   errs	            r;   rj   rj      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/B>>Cr_   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.r   r   z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rj   r   r   r   r   r   builtins)namer   r_   r   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)NrC   )r   getattrr   )r   r   objs      r;   resolve_name_to_real_class_namer   ?  s:    .T;/ sJ--  s    ))c                D    | d uxr t        |       t        j                  v S rP   )r   _type_tuplesr   r   s    r;   	is_pep593r   H  s"    LE!2l6L6L!LLr=   c                h    t        | t        j                        xr t        | t        t        f       S rP   )r8   rw   r
   ri   bytes)r   s    r;   is_non_string_iterabler   L  s1    c?334 Zc5\> : r=   c                8    t        |       t        j                  v S rP   )r   r   r    r   s    r;   rl   rl   R  s    e 4 444r=   c                    t        | d      S )N__supertype__r   r   s    r;   
is_newtyper   V  s    5/**r=   c                6    t        | d      xr t        | d      S )NrA   rL   r   r   s    r;   rk   rk   ^  s    5*%F'%*FFr=   c                v    t        |       rt        | j                        S t        | t        j
                        S rP   )rk   	is_pep695rL   r8   _type_instancesr)   r   s    r;   r   r   b  s0    
 %))**e_::;;r=   c                d    | j                   }t        |      r|j                   }t        |      r|S rP   )r   r   )r   
super_types     r;   flatten_newtyper   l  s0    $$J
Z
 --
 Z
 r=   c                D   t               fd |       }t        |t              rtt               }t        |      }|r[|j	                         }t        |t              r|j                  |       n&|j                  |t        u st        |      rdn|       |r[|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 j                  |        t        |       s| S | j                  }t        |      s|S |j                  D cg c]
  } |       c}S c c}w rP   )rn   r   	__value__is_unionrA   )
inner_typevaluet_seenrecursive_values      r;   r   z&pep695_values.<locals>.recursive_value|  sa     		*$$$L,1NN;q";;;s   AN)	rm   r8   rv   r   popleftextendrn   r5   r<   )r   restypesstackr   r   r   s        @@r;   pep695_valuesr   s  s     EE< %
 C#tc
A!T"Q		!x-;q>$qI  ur=   c                    rt        | t              ryt        | t        j                        ry|r)t	        |       rt        fd| j                  D              S y)NTc              3  :   K   | ]  }t        |d         yw)T)check_for_plain_stringN)rh   )rc   argr   s     r;   rg   zis_fwd_ref.<locals>.<genexpr>  s-      
  T2H 
s   F)r8   ri   r   r   rk   anyrA   )r   check_genericr   s     `r;   rh   rh     sV    
 *UC"8	E?55	6	:e, 
 ~~	
 
 	
 r=   c                     y rP   rH   r   s    r;   de_optionalize_union_typesr     s    36r=   c                     y rP   rH   r   s    r;   r   r     s    ?Br=   c                     y rP   rH   r   s    r;   r   r          r=   c                   t        |       rt        | d      S t        |       rt        |       rt        j
                  rt        | j                        }n{t        | g      }t               }|rR|j                         }|j                  D ]0  }t        |      r|j                  |        |j                  |       2 |rR|j                  d       |D ch c]  }|t        ust        |      r| }}t        | S | S c c}w )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)

    FN)rh   #_de_optionalize_fwd_ref_union_typesr   includes_noner   py39rm   rA   r   r   appendrn   discardr5   r<   make_union_type)r   r:   stack_of_unionsu_typrd   r   s         r;   r   r     s     %25%@@	%]51;;enn%C $UGnO%C!'//1!NN &D~'..t4	& " KKJQ(!2;q>qJJ$$  Ks   C=!C=-C=c                     y rP   rH   r   return_has_nones     r;   r   r     s     r=   c                     y rP   rH   r   s     r;   r   r     r   r=   c                   | j                   }t        j                  d|      }|r^|j                  d      j	                  d      d   }|dk(  r|rdS t        |j                  d            S |dk(  rd	|j                  d      v rg }g }d
}|j                  d      D ]r  }|d	k(  r|dz  }nT|dk(  r|dz  }nI|d
k(  rD|dk(  r?|j                  dj                  |      j                                |j                          b|j                  |       t n%t        j                  d|j                  d            }|D 	cg c]  }	|	dk7  s	t        |	       }
}	|rt        |      t        |
      k7  S |
rt        |
 S t        S |rdS | S t        j                  d|      }d|v }|r|S |r+dj                  d |D              }|rt        |      S t        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   T   r   [r   ], z,\s*r7   Fz\s*\|\s*|c              3  ,   K   | ]  }|d k7  s	|  yw)r7   NrH   )rc   ps     r;   rg   z6_de_optionalize_fwd_ref_union_types.<locals>.<genexpr>  s     B!a6kABs   
)r9   r|   r}   groupsplitr   r   joinstripclearlenr   r*   )r   r   rq   mmg1rs   currentignore_commacharrd   partspipe_tokenshas_noneanno_strs                 r;   r   r     s    &&J	$j	1B	XXa[s#B'*4G
288A;0GG7]bhhqk!&(%' HHQK 	)Ds{$)$)%*ts{ (8(>(>(@A NN4(	) 88GRXXa[92:M$dfnZ%MEM8}E
2227.BUB+566((;
3K$H88B{BB'/z(#:U:L! Ns   ;
GG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 xs t        |       S # t        $ r Y y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  2   K   | ]  }t        |        y wrP   r   rc   r   s     r;   rg   z includes_none.<locals>.<genexpr>9  s     ==#=   r   c              3  2   K   | ]  }t        |        y wrP   r   r   s     r;   rg   z includes_none.<locals>.<genexpr>=  s     B=#Br   NF)rh   r   r   r   r   r   r   r   r   r   r   r5   r<   	TypeErrorr   s    r;   r   r   *  s     %25$??=Xe_===Xe_Q/00B]5-ABBB%U00114((>K,>>  	s   'B> >	C
	C
c                    t        | t              xsB t        | d      xs4 | j                  dv xs$ t        |       j                  d   j                  dv S )NrL   )typingtyping_extensionsr   )r8   typer   rD   __mro__r   s    r;   	is_a_typer   I  s\    5$ 	P5,'	P>>	P ;q!,,0OO	r=   c                    t        | dd      S )Nr   	UnionType)is_origin_ofr   s    r;   r   r   R  s    w44r=   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   r8   r   
issubclass)r   	class_objorigins      r;   is_origin_of_clsr  V  s/     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_namerD   
startswith)r   r	  namesr  s       r;   r  r  c  sJ     F~&!U* $>&++66v>r=   c                v    t         j                  r| j                  S t        | dd       }|t        | dd       }|S )NrC   _name)r   py310rC   r   )r   typ_names     r;   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 rP   rH   rQ   instanceowners      r;   __get__zDescriptorProto.__get__~  rS   r=   c                     y rP   rH   rQ   r  r   s      r;   __set__zDescriptorProto.__set__  rS   r=   c                     y rP   rH   rQ   r  s     r;   
__delete__zDescriptorProto.__delete__  rS   r=   N)r  objectr  r   rW   r   )r  r   r   r   rW   r7   r  r   rW   r7   )rC   rD   rE   r  r  r  rH   r=   r;   r  r  }  s    ?=4r=   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 rP   rH   r  s      r;   r  zDescriptorReference.__get__  rS   r=   c                     y rP   rH   r  s      r;   r  zDescriptorReference.__set__  rS   r=   c                     y rP   rH   r  s     r;   r  zDescriptorReference.__delete__  rS   r=   N)r  r  r  r   rW   r!  )r  r   r   r!  rW   r7   r   rC   rD   rE   rF   r   r  r  r  rH   r=   r;   r#  r#    s     EC8 r=   r#  _DESC_co)r-   r0   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 rP   rH   r  s      r;   r  zRODescriptorReference.__get__  rS   r=   c                     y rP   rH   r  s      r;   r  zRODescriptorReference.__set__  rS   r=   c                     y rP   rH   r  s     r;   r  z RODescriptorReference.__delete__  rS   r=   N)r  r  r  r   rW   r(  )r  r   r   r   rW   r   )r  r   rW   r   r'  rH   r=   r;   r*  r*    s     HE< 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 rP   rH   r  s      r;   r  zCallableReference.__get__  rS   r=   c                     y rP   rH   r  s      r;   r  zCallableReference.__set__  rS   r=   c                     y rP   rH   r  s     r;   r  zCallableReference.__delete__  rS   r=   N)r  r  r  r   rW   r.  )r  r   r   r.  rW   r7   r   r'  rH   r=   r;   r0  r0    s     CA8 r=   r0  c                      e Zd ZddZy)_TypingInstancesc                    t        t        t        |d       t        t        |d       fD ch c]  }|| c}      }|st	        |      || j
                  |<   |S c c}w rP   )ro   r   r   r   AttributeErrorr   )rQ   keyr   r   s       r;   __getattr__z_TypingInstances.__getattr__  sn     FC.-sD9 = 	
  %%"cs   AN)r8  ri   rW   ztuple[type, ...])rC   rD   rE   r9  rH   r=   r;   r5  r5    s    r=   r5  )r:   r   rW   bool)re   	Type[Any]rq   _AnnotationScanTyperf   ri   r_   zMapping[str, Any]rZ   z#Optional[Callable[[str, str], str]]r[   r:  r\   zOptional[Set[Any]]rW   r;  )r   r<  rW   r<  )rq   zGenericProtocol[_T]rs   r@   rW   rK   )
r   ri   r   ri   r_   Optional[Mapping[str, Any]]r`   zOptional[Type[Any]]rW   r   )r   ri   r   ri   r_   r=  rW   r   )r   ri   r   ri   rW   ri   )r   zOptional[Any]rW   r:  )r   r   rW   zTypeGuard[Iterable[Any]])r   r   rW   r:  )r   zOptional[_AnnotationScanType]rW   zTypeGuard[NewType])r   r<  rW   zTypeGuard[GenericProtocol[Any]])r   r<  rW   zTypeGuard[TypeAliasType])r   r   rW   r;  )r   r<  rW   zSet[Any])FF)r   r<  r   r:  r   r:  rW   zTypeGuard[ForwardRef])r   ri   rW   ri   )r   r;  rW   r;  )r   r   r   zLiteral[True]rW   r:  )r   r   r   zLiteral[False]rW   r<  )r   r   r   r:  rW   z Union[_AnnotationScanType, bool])r   r<  rW   r;  )r   r   rW   zTypeGuard[ArgsTypeProtocol])r   r   r  z'Union[Tuple[Type[Any], ...], Type[Any]]rW   r:  )r   r   r  ri   r	  zOptional[str]rW   r:  )r   r;  rW   ri   )f
__future__r   r   collectionsr   collections.abcabcrw   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.   r/   r1   r3   r4   r  r   r5   r   r<   ri   r<  r?   rJ   rN   _LiteralStarrb   r   rp   rj   r   r   r   r   rl   r   rk   r   r   r   rh   r   r   r   r   r   r   r  r  r  r  r!  r#  r(  r*  r.  r0  r5  r   r   LITERAL_TYPESrH   r=   r;   <module>rD     s   #   ) 	 
                     8< 106:4<86@888.@0@Ten	T	*\6
en	T	*	<< +DzHI 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.M5+G<"N  #( ! 	( 
 6 
 6 
 B 
 B 
 

%%%P 
(5	 

 
(6 

33(,3%3l>5
F
FB
F	
F 6:%2	5h 5 	/9'%. 9( :_E=GH- =" e8HS#X$6789 9$ $  !'O $$ #O$$r=   