
    Ngmn                        d Z ddlZddlZddlZddlZddlmZ dej        dd         cxk    rdk     r
n nddlmZ	 n=ej        dd         dk    r	 ddlmZ	 n"# e
$ r	 ddlmZ	 Y nw xY wddlmZ  ee          Z	ej        dd         dk    ZerddlZd	Zd	Zd	Zd	Zd
ZerFddlmZmZmZmZmZmZmZmZmZ ddlmZmZ ej        dd         dk    rddlm Z  ee ej!        fZ"nefZ"nddlmZm#Z#mZmZm$Z$mZm%Z%m&Z& 	 ddlm'Z'm(Z( n# e
$ r  ee          Z'd
Zd	ZY nw xY w	 ddlm)Z) n # e
$ r 	 ddlm)Z) n# e
$ r d
ZY nw xY wY nw xY w	 ddlmZ n # e
$ r 	 ddlmZ n# e
$ r d
ZY nw xY wY nw xY w	 ddlmZ n # e
$ r 	 ddlmZ n# e
$ r d
ZY nw xY wY nw xY wd Z*d Z+d Z,d Z-d Z.d Z/	 ej0        Z1n# e2$ r dZ1Y nw xY wd Z3ehZ4 e5ed          re46                    ej                   d Z7d Z8d Z9d Z:d  Z;d! Z<d" Z=d# Z>d$ Z?d% Z@d8d&ZAd' ZBd( ZCd) ZDd* ZEd+ ZFd, ZGd- ZHd. ZId9d/ZJd9d0ZKd9d1ZLd9d2ZMd3 ZNd4 ZOd5 ZPd6 ZQd7 ZRdS ):zDefines experimental API for runtime inspection of types defined
in the standard "typing" module.

Example usage::
    from typing_inspect import is_generic_type
    N)_TypedDictMeta)      r   r   )r   	      )	TypedDict)r      r   TF)	GenericCallableUnionTypeVarClassVarTuple_GenericAlias
ForwardRefNewType)FinalLiteral)r   r   r   )_SpecialGenericAlias)r   CallableMetar   r   	TupleMetar   GenericMeta_ForwardRef)_Union	_ClassVar)_Final)r   )r   c                     t          | t                    sJ t          | d          r| j        S | j        | j        } | j        | S )z@This function exists for compatibility with old typing versions._gorg)
isinstancer   hasattrr   
__origin__clss    J/var/www/html/ai-engine/env/lib/python3.11/site-packages/typing_inspect.pyr   r   \   sP    c;'''''sG y
.
$n .
$J    c                 H   t           rjt          | t                    rt          | t                    p?t          | t
                    o*| j        t          t          t          t          j        j        fvS t          | t                    ot          | t          t          f           S )a  Test if the given type is a generic type. This includes Generic itself, but
    excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
    Examples::

        is_generic_type(int) == False
        is_generic_type(Union[int, str]) == False
        is_generic_type(Union[int, T]) == False
        is_generic_type(ClassVar[List[int]]) == False
        is_generic_type(Callable[..., T]) == False

        is_generic_type(Generic) == True
        is_generic_type(Generic[T]) == True
        is_generic_type(Iterable[int]) == True
        is_generic_type(Mapping) == True
        is_generic_type(MutableMapping[T, List[int]]) == True
        is_generic_type(Sequence[Union[str, bytes]]) == True
    )
NEW_TYPINGr   type
issubclassr
   typingGenericAliasr!   r   tupler   collectionsabcr   r   r   r   tps    r$   is_generic_typer0   f   s    $  Y2t$$@B)@)@ X2122 XeUHko>V%WW	Y r;'' 6rL)455-6 7r%   c                 :   t           r| t          u put          | t                    r| j        t
          j        j        u pHt          | t                    o3t          | t                    ot          | t
          j        j                  S t          |           t          u S )a  Test if the type is a generic callable type, including subclasses
    excluding non-generic types and callables.
    Examples::

        is_callable_type(int) == False
        is_callable_type(type) == False
        is_callable_type(Callable) == True
        is_callable_type(Callable[..., int]) == True
        is_callable_type(Callable[[int, int], Iterable[str]]) == True
        class MyClass(Callable[[int], int]):
            ...
        is_callable_type(MyClass) == True

    For more general tests use callable(), for more precise test
    (excluding subclasses) use::

        get_origin(tp) is collections.abc.Callable  # Callable prior to Python 3.7
    )r'   r   r   r*   r!   r,   r-   r(   r)   r
   r   r.   s    r$   is_callable_typer2      s    &  :h 9*R1C"D"D #:!9992t$$ 9B)@)@ 92{788	: 88|##r%   c                    t           rk| t          u pat          | t                    r| j        t
          u p>t          | t                    o)t          | t                    ot          | t
                    S t          |           t          u S )a   Test if the type is a generic tuple type, including subclasses excluding
    non-generic classes.
    Examples::

        is_tuple_type(int) == False
        is_tuple_type(tuple) == False
        is_tuple_type(Tuple) == True
        is_tuple_type(Tuple[str, int]) == True
        class MyClass(Tuple[str, int]):
            ...
        is_tuple_type(MyClass) == True

    For more general tests use issubclass(..., tuple), for more precise test
    (excluding subclasses) use::

        get_origin(tp) is tuple  # Tuple prior to Python 3.7
    )
r'   r   r   r*   r!   r+   r(   r)   r
   r   r.   s    r$   is_tuple_typer4      s    $  'e &z".@AA  '&&2t$$ &B)@)@ &2u%%	' 88y  r%   c                     | t          d          u rdS t          |           r(t          d t          | d          D                       S dS )a  Test if the type is type(None), or is a direct union with it, such as Optional[T].

    NOTE: this method inspects nested `Union` arguments but not `TypeVar` definition
    bounds and constraints. So it will return `False` if
     - `tp` is a `TypeVar` bound, or constrained to, an optional type
     - `tp` is a `Union` to a `TypeVar` bound or constrained to an optional type,
     - `tp` refers to a *nested* `Union` containing an optional type or one of the above.

    Users wishing to check for optionality in types relying on type variables might wish
    to use this method in combination with `get_constraints` and `get_bound`
    NTc              3   4   K   | ]}t          |          V  d S N)is_optional_type).0tts     r$   	<genexpr>z#is_optional_type.<locals>.<genexpr>   s+      NNB#B''NNNNNNr%   )evaluateF)r(   is_union_typeanyget_argsr.   s    r$   r8   r8      sY     
T$ZZt	r		 NN(22M2M2MNNNNNNur%   c                     t           r,| t          u p"t          | t                    o| j        t          u S t
          ot          |           t          u S )zTest if the type is a final type. Examples::

        is_final_type(int) == False
        is_final_type(Final) == True
        is_final_type(Final[int]) == True
    )r'   r   r   r*   r!   
WITH_FINALr(   r   r.   s    r$   is_final_typerB      sP      Oe N2122Mr}7M	O,$r((f,,r%   c                     t           rH| t          u p>t          | t                    o| j        t          u pt
          ot          | t
                    S t          |           t          u S )a)  Test if the type is a union type. Examples::

        is_union_type(int) == False
        is_union_type(Union) == True
        is_union_type(Union[int, int]) == False
        is_union_type(Union[T, int]) == True
        is_union_type(int | int) == False
        is_union_type(T | int) == True
    )r'   r   r   r*   r!   MaybeUnionTyper(   r   r.   s    r$   r=   r=      se      Ee DB 233N8NDBJr>$B$B	E 88vr%   r   c                     t           r,| t          v p"t          | t                    o| j        t          v S t
          o"t          |           t          t                    u S r7   )r'   LITERALSr   r*   r!   WITH_LITERALr(   r   r.   s    r$   is_literal_typerH      sT     Rh Q2122Pr}7P	R5DHHW55r%   c                 .    t          |           t          u S )zTest if the type represents a type variable. Examples::

        is_typevar(int) == False
        is_typevar(T) == True
        is_typevar(Union[T, int]) == False
    )r(   r   r.   s    r$   
is_typevarrJ      s     88wr%   c                     t           r,| t          u p"t          | t                    o| j        t          u S t
          rt          |           t          u S dS )zTest if the type represents a class variable. Examples::

        is_classvar(int) == False
        is_classvar(ClassVar) == True
        is_classvar(ClassVar[int]) == True
        is_classvar(ClassVar[List[T]]) == True
    F)r'   r   r   r*   r!   WITH_CLASSVARr(   r   r.   s    r$   is_classvarrM     sW      h Q2122Pr}7P	R	 Bxx9$$ur%   c                 @   t           sdS t          j        dd         dk    rKt          j        j        dk    r6| t          t
          j        fv p t          | t          t
          j        f          S t          j        dd         dk    rv	 t          | t
          j                  }|r|S n# t          $ r Y nw xY w| t          t
          j        fv p0t          | dd          duot          | dd	          d
k    o| j	        dv S | t          u pt          | dd          duo| j	        dv S )zTests if the type represents a distinct type. Examples::

        is_new_type(int) == False
        is_new_type(NewType) == True
        is_new_type(NewType('Age', int)) == True
        is_new_type(NewType('Scores', List[Dict[str, float]])) == True
    FNr   )r   
   r   beta)r   r   r   __supertype____qualname__ zNewType.<locals>.new_type)typingtyping_extensions)
WITH_NEWTYPEsysversion_inforeleaselevelr   rU   r   	TypeErrorgetattr
__module__)r/   ress     r$   is_new_typer^     sk     Du		"1"		+	+0@0MQW0W0Ww 1 9:: E2):)BCDD	F		"1"		*	*	R!2!:;;C  
  	 	 	D	
 w 1 9:: C_d334? B^R004OOB"AA	D g C_d334? B"AA	Ds   B% %
B21B2c                 d    t           st          | t                    S t          | t                    S )zTests if the type is a :class:`typing.ForwardRef`. Examples::

        u = Union["Milk", Way]
        args = get_args(u)
        is_forward_ref(args[0]) == True
        is_forward_ref(args[1]) == False
    )r'   r   r   r   r.   s    r$   is_forward_refr`   6  s,      +"k***b*%%%r%   c                     t           rt          d          t                      }t          | d|          }||u rdS || S |S )a  Get the last base of (multiply) subscripted type. Supports generic types,
    Union, Callable, and Tuple. Returns None for unsupported types.
    Examples::

        get_last_origin(int) == None
        get_last_origin(ClassVar[int]) == None
        get_last_origin(Generic[T]) == Generic
        get_last_origin(Union[T, int][str]) == Union[T, int]
        get_last_origin(List[Tuple[T, T]][int]) == List[Tuple[T, T]]
        get_last_origin(List) == List
    zEThis function is only supported in Python 3.6, use get_origin insteadr!   N)r'   
ValueErrorobjectr[   )r/   sentinelorigins      r$   get_last_originrf   C  s\      4 3 4 4 	4xxHRx00Ft~	Mr%   c                 |   t           r>t          | t                    r| j        t          ur| j        ndS | t
          u rt
          S dS t          | t                    rt          |           S t          |           rt          S t          |           rt          S t          |           rt           r	| j        p| S t          S dS )a  Get the unsubscripted version of a type. Supports generic types, Union,
    Callable, and Tuple. Returns None for unsupported types. Examples::

        get_origin(int) == None
        get_origin(ClassVar[int]) == None
        get_origin(Generic) == Generic
        get_origin(Generic[T]) == Generic
        get_origin(Union[T, int]) == Union
        get_origin(List[Tuple[T, T]][int]) == list  # List prior to Python 3.7
    N)r'   r   r*   r!   r   r
   r   r   r=   r   r4   r   rH   r   r.   s    r$   
get_originrh   [  s      b,-- 	L$&M$A$A2==tK==Nt"k"" RyyR R r  	'=&B&4r%   c                    t           r7t          |           r6g }| j        | j        ndD ]}|t          |          z  }t	          |          S t          |           r6g }| j        | j        ndD ]}|t          |          z  }t	          |          S t          |           rg }| j        }|dS |D ]y}t          |          rt          |          n|fD ]U}t          |          r't          |t                    st          d|z            |g }||vr|                    |           Vz|t	          |          S dS dS t          rat          | t                     rt#          | d          s3t          | t$                    r%t'          | t(                    r| t(          ur| j        S dS t          |           s-t          |           st+          |           st          |           r| j        | j        ndS dS )a>  Return type parameters of a parameterizable type as a tuple
    in lexicographic order. Parameterizable types are generic types,
    unions, tuple types and callable types. Examples::

        get_parameters(int) == ()
        get_parameters(Generic) == ()
        get_parameters(Union) == ()
        get_parameters(List[int]) == ()

        get_parameters(Generic[T]) == (T,)
        get_parameters(Tuple[List[T], List[S_co]]) == (T, S_co)
        get_parameters(Union[S_co, Tuple[T, T]][int, U]) == (U,)
        get_parameters(Mapping[T, Tuple[S_co, T]]) == (T, S_co)
    N zKCannot inherit from a generic class parameterized with non-type-variable %s__parameters__)LEGACY_TYPINGr=   __union_params__get_parametersr+   r4   __tuple_params__r0   rk   r?   _has_type_varr   r   rZ   appendr'   r*   r    r(   r)   r
   r2   )r/   paramsargbase_paramsbp_bps         r$   rn   rn   z  st     3 	F/1/B/N++TV . ..---== 2 	F/1/B/N++TV . ..---== R   	F+K"r" 
* 
*,9#,>,>J8C===SF 	* 	*B$R(( 9B1H1H 9'35789 9 9 ~!#''b)))	* !V}}$r2	  r#566		 B 011		
 2t$$		
 *4B)@)@		 '!!$$2,R00 -b 1 1 %'$5$Ar  rIrr%   c                 ^   t           rt          d          t          |           r| j        | j        fndS t	          |           rH	 | j        t          | j                  dk    r| j        S n# t          $ r Y nw xY w| j        | j        ndS t          |           r1	 | j        | j        ndS # t          $ r | j
        | j
        ndcY S w xY wt          |           r| j        | j        ndS t          |           r1	 | j        | j        ndS # t          $ r | j        | j        ndcY S w xY wdS )a  Get last arguments of (multiply) subscripted type.
       Parameters for Callable are flattened. Examples::

        get_last_args(int) == ()
        get_last_args(Union) == ()
        get_last_args(ClassVar[int]) == (int,)
        get_last_args(Union[T, int]) == (T, int)
        get_last_args(Iterable[Tuple[T, S]][int, T]) == (int, T)
        get_last_args(Callable[[T], int]) == (T, int)
        get_last_args(Callable[[], int]) == (int,)
    zCThis function is only supported in Python 3.6, use get_args insteadNrj   r   )r'   rb   rM   __type__r0   __args__lenAttributeErrorrk   r=   rm   r2   r4   ro   r.   s    r$   get_last_argsr|     s      1 2 2 	2	R !#!8~~b@			 	{&3r{+;+;a+?+?{" 	 	 	D	 %'$5$Ar  rI	r		 	R"$+"92;;rA 	R 	R 	R*,*=*I2&&rQQQ	R 
"		 	 k5r{{2=	r		 	R"$+"92;;rA 	R 	R 	R*,*=*I2&&rQQQ	R rs6   %A. .
A;:A;B. .C
C=D D*)D*c                    g }| D ]d}t          |t                    s|                    |           .t          |d                   rt	          |dd                   }t          |          dk    r)|                    t          g |d         f                    |d         t          u r)|                    t          d|d         f                    |                    t          t          |dd                   |d         f                    |                    t          |d                   
                    |d         t	          |dd                                        ft          |          S )zInternal helper for get_args.r      Nr   .)r   r+   rq   r2   
_eval_argsrz   r   Ellipsislistr(   __getitem__)argsr]   rs   callable_argss       r$   r   r     sP   
C N N#u%% 	NJJsOOOOc!f%% 		N&s122w//M3xx1}}

8Ba(8$89::::Q8##

8Cq)9$9:;;;;

8Dss);$<$<mB>O$OPQQQQJJtCF||//A
3qrr78K8KLLMMMM::r%   c                    t           r||st          d          t          | t                    rgt	          | d          rW| j        }t          |           t          j        j	        u r.|d         t          urt          |dd                   |d         f}|S t          rt          | t                    r| j        S dS t          |           st          |           r| j        | j        fndS t!          |           r	| j        pdS t%          |           s.t'          |           st)          |           st+          |           r	 |                                 }np# t.          $ rc t'          |           rt1          |           }nAt%          |           rt3          |           }n"t+          |           rt5          |           }nY dS Y nw xY wt          |t6                    r|t9          |          dk    ri|s
|dd         S t;          |dd                   }t          |           t          u r.|d         t          urt          |dd                   |d         f}|S dS )a  Get type arguments with all substitutions performed. For unions,
    basic simplifications used by Union constructor are performed.
    On versions prior to 3.7 if `evaluate` is False (default),
    report result as nested tuple, this matches
    the internal representation of types. If `evaluate` is True
    (or if Python version is 3.7 or greater), then all
    type parameters are applied (this could be time and memory expensive).
    Examples::

        get_args(int) == ()
        get_args(Union[int, Union[T, int], str][int]) == (int, str)
        get_args(Union[int, Tuple[T, int]][str]) == (int, (Tuple, str, int))

        get_args(Union[int, Tuple[T, int]][str], evaluate=True) ==                  (int, Tuple[str, int])
        get_args(Dict[int, Tuple[T, T]][Optional[int]], evaluate=True) ==                  (int, Tuple[Optional[int], Optional[int]])
        get_args(Callable[[], T][int], evaluate=True) == ([], int,)
    Nz*evaluate can only be True in Python >= 3.7ry   r   r   rj   r~   )r'   rb   r   r*   r    ry   rh   r,   r-   r   r   r   rD   rM   rB   rx   rH   
__values__r0   r=   r2   r4   
_subs_treer{   _union_subs_tree_generic_subs_tree_tuple_subs_treer+   rz   r   )r/   r<   r]   trees       r$   r?   r?     su   (  IJJJb,-- 	'"j2I2I 	+C"~~!999c!fH>T>TCH~~s2w/J 	j^<< 	;r2 A-++ A!#!8~~b@r #}"",R00 -b 1 1	==??DD 	 	 	R   '++ $$ )"--r"" '++ rr	 dE"" 	s4yy1}}  ABBxT!""X&&C"~~))c!fH.D.DCH~~s2w/J2s   E A'GGc                     t          |           rt          | dd          S t          dt          |           z             )zReturn the type bound to a `TypeVar` if any.

    It the type is not a `TypeVar`, a `TypeError` is raised.
    Examples::

        get_bound(TypeVar('T')) == None
        get_bound(TypeVar('T', bound=int)) == int
    	__bound__Ntype is not a `TypeVar`: rJ   r[   rZ   strr.   s    r$   	get_boundr   A  s>     "~~ ?r;---3c"gg=>>>r%   c                     t          |           rt          | dd          S t          dt          |           z             )zReturns the constraints of a `TypeVar` if any.

    It the type is not a `TypeVar`, a `TypeError` is raised
    Examples::

        get_constraints(TypeVar('T')) == ()
        get_constraints(TypeVar('T', int, str)) == (int, str)
    __constraints__rj   r   r   r.   s    r$   get_constraintsr   Q  s?     "~~ ?r,b1113c"gg=>>>r%   c                 J    t          | dd          }||nt          |           S )a6  Get the generic type of an object if possible, or runtime class otherwise.
    Examples::

        class Node(Generic[T]):
            ...
        type(Node[int]()) == Node
        get_generic_type(Node[int]()) == Node[int]
        get_generic_type(Node[T]()) == Node[T]
        get_generic_type(1) == int
    __orig_class__N)r[   r(   )objgen_types     r$   get_generic_typer   a  s+     s,d33H+88c:r%   c                 n    t           rt          d | j        D                       S t          | dd          S )a  Get generic base types of a type or empty tuple if not possible.
    Example::

        class MyClass(List[int], Mapping[str, List[int]]):
            ...
        MyClass.__bases__ == (List, Mapping)
        get_generic_bases(MyClass) == (List[int], Mapping[str, List[int]])
    c              3   D   K   | ]}t          |t                    |V  d S r7   )r   r   )r9   ts     r$   r;   z$get_generic_bases.<locals>.<genexpr>{  s1      KK1
1k0J0JKQKKKKKKr%   __orig_bases__rj   )rl   r+   	__bases__r[   r.   s    r$   get_generic_basesr   q  s>      1KKKKKKKKr+R000r%   c                 p    t          | t          t          f          r| j                                        S dS )a  If td is a TypedDict class, return a dictionary mapping the typed keys to types.
    Otherwise, return None. Examples::

        class TD(TypedDict):
            x: int
            y: int
        class Other(dict):
            x: int
            y: int

        typed_dict_keys(TD) == {'x': int, 'y': int}
        typed_dict_keys(dict) == None
        typed_dict_keys(Other) == None
    N)r   _TypedDictMeta_Mypy_TypedDictMeta_TE__annotations__copy)tds    r$   typed_dict_keysr     s7     "*,=>?? )!&&(((4r%   c                 2    t          |           r| j        ndS )a  
    If fr is a ForwardRef, return the string representation of the forward reference.
    Otherwise return None. Examples::

        tp = List["FRef"]
        fr = get_args(tp)[0]
        get_forward_arg(fr) == "FRef"
        get_forward_arg(tp) == None
    N)r`   __forward_arg__)frs    r$   get_forward_argr     s     "0!3!3=2=r%   c                 B   |g }t          |           rt          | ||          S t          |           rt          | ||          S t	          |           rt          | ||          S t          | t                    r%t          |          D ]\  }}| |k    r
||         c S | S )zbackport of _replace_arg)	r=   r   r4   r   r0   r   r   r   	enumerate)rs   tvarsr   itvars        r$   _replace_argr     s    } S 2UD111S 2UD111s 4!#ud333#w  '' 	 	GAtd{{Aw Jr%   c                    g }| D ]}t          |t                    r|                    |j                   2t          |t                    r@t          |          dk    r-|d         t          u r|                    |dd                    |                    |           t          |          t                    t          |          k     rCg }|D ]0}|v r*|                    |           	                    |           1|}r
J             t          |          |D ]Lt          t                    st          fdhz
  D                       r	                               Mt	          fd|D                       S )z backport of _remove_dups_flattenr   r~   Nc              3      K   | ]b}t          |t                    rt          |          &t          |t                    ;t          |t                    ot          |          V  cd S r7   )r   r   rh   r   r(   r)   )r9   t2t1s     r$   r;   z'_remove_dups_flatten.<locals>.<genexpr>  s|       1 1"2{331 #22!"g.. 3 "d##:
2r(:(: 32221 1r%   c              3   $   K   | ]
}|v |V  d S r7   rj   )r9   r   
all_paramss     r$   r;   z'_remove_dups_flatten.<locals>.<genexpr>  s'      66qa:oooooo66r%   )r   r   extendrm   r+   rz   r   rq   setremover(   r>   )
parametersrr   p
new_paramsr   r   r   s        @@r$   _remove_dups_flattenr     s    F  a   	MM!,----5!! 	c!ffqjjQqTU]]MM!ABB%    MM!VJ
:V$$
 	% 	%AJ!!!$$$!!!$$$))z))) VJ " ""d## 	 1 1 1 1#rd*1 1 1 1 1 	"
 b!!!6666F666666r%   c           
         d } ||           }| t          |           st          |           s| S g } ||          +|                    |            ||          } ||          +g }d } ||           D ]&}|                    t          |||                     '|D ]E}	g }
 ||	          D ]3}|
                    t          |t	          |	          |                     4|
}F|S )z;backport of typing._subs_tree, adapted for legacy versions c                 4    	 | j         S # t          $ r Y d S w xY wr7   )r!   r{   r"   s    r$   _get_originz_subs_tree.<locals>._get_origin  s1    	>! 	 	 	44	s   	 
Nc                     t          |           r| j        }n2t          |           r| j        }n	 | j        }n# t
          $ r d}Y nw xY w||ndS )Nrj   )r=   rm   r4   ro   ry   r{   )r#   cls_argss     r$   	_get_argsz_subs_tree.<locals>._get_args  sw     	+HH3 	+HH<!   #/xxR7s   8 AA)r=   r4   rq   r   rn   )r#   r   r   r   current
orig_chain	tree_argsr   rs   oclsnew_tree_argss              r$   r   r     sN      k#GS!! 	-*<*< 	J J
+g


*'"""+g&& +g


*
 I
8 
8 
8 y~~ 9 9c5$778888 " "9T?? 	U 	UC  c>$3G3G!S!STTTT!		r%   c                     | t           u rt           S t          | ||          }t          |          }t          |          dk    r|d         S t           f|z   S )z backport of Union._subs_tree r~   r   )r   r   r   rz   r/   r   r   r   s       r$   r   r     sV    	U{{2ud++I$Y//I
9~~|8ir%   c                 v    | j         | S t          | ||          }t          |           ft          |          z   S )z$ backport of GenericMeta._subs_tree )r!   r   r   r+   r   s       r$   r   r     s;    	}	2ud++I"II<%	****r%   c                 t    | t           u rt           S t          | ||          }t           ft          |          z   S )z7 ad-hoc function (inspired by union) for legacy typing )r   r   r+   r   s       r$   r   r     s6    	U{{2ud++I8eI&&&&r%   c                     | dS t          |           rt          |           S t          |           rt          |           S t	          |           rt          |           S t          |           rt          |           S dS )NF)r=   _union_has_type_varr4   _tuple_has_type_varr0   _generic_has_type_varr2   _callable_has_type_var)r   s    r$   rp   rp   '  s    yu	q		 	"1%%%	q		 "1%%%			 $Q'''	!		 %a(((ur%   c                 L    | j         r| j         D ]}t          |          r dS dS NTF)rm   rp   r/   r   s     r$   r   r   6  @    	 $ 	 	AQ tt5r%   c                 L    | j         r| j         D ]}t          |          r dS dS r   )ro   rp   r   s     r$   r   r   >  r   r%   c                 p    | j         r| j         D ]}t          |          r dS t          | j                  S )NT)ry   rp   
__result__r   s     r$   r   r   F  sI    	{  	 	AQ tt'''r%   c                 L    | j         r| j         D ]}t          |          r dS dS r   )rk   rp   r   s     r$   r   r   N  s@    	 " 	 	AQ tt5r%   r7   )NN)S__doc__rW   typesrT   rU   mypy_extensionsr   r   rX   r   ImportErrorr   r(   r'   collections.abcr,   rA   rG   rL   rV   rl   r
   r   r   r   r   r   r   r   r   r   r   r   GenericAliasr*   r   r   r   r   r   r   r   r   r0   r2   r4   r8   rB   	UnionTyperD   r{   r=   rF   r    addrH   rJ   rM   r^   r`   rf   rh   rn   r|   r   r?   r   r   r   r   r   r   r   r   r   r   r   r   rp   r   r   r   r   rj   r%   r$   <module>r      s    


       A A A A A A  !$0000y00000EEEEEEEbqbY&&?IIIIIII ? ? ?>>>>>>>>? !     Ybqb!Y.
 
 .!                      10000000
y((//////+-A5CUV+-                   ,,,,,,,,,   e	,,,,,,,   	%%%%%%% 	 	 	JJJ	!------- ! ! !	!&&&&&&& 	! 	! 	! LLL	!!!------- ! ! !	!&&&&&&& 	! 	! 	! LLL	!!  7 7 74$ $ $6! ! !4  *
- 
- 
-_NN   NNN  " 9
769 !LL   6 6 6    "D D D@
& 
& 
&  0  >B B BJ( ( (V  &A A A AH? ? ? ? ? ? ; ; ; 1 1 1  (
> 
> 
>  &%7 %7 %7P* * * *Z	  	  	  	 + + + +' ' ' '      ( ( (    s   A A&%A&:D DDD% %E+D21E2D<9E;D<<EEE E*EE*E$!E*#E$$E*)E*.E5 5F;FFF	FFFF(F0 0F:9F: