
    chmn                        S r SSKrSSKrSSKrSSKrSSKJr  S\R                  SS s=::  a  S:  a
  O  OSSKJr	  O)\R                  SS S:  a   SSKJr	  OSSKJr  \" \5      r	\R                  SS S:  r\(       a  SSKrS	rS	rS	rS	rS
r\(       aK  SSKJrJrJrJrJrJrJrJrJr  SSKJrJr  \R                  SS S:  a  SSKJ r   \\ \RB                  4r"O6\4r"O2SSKJrJ#r#JrJrJ$r$JrJ%r%J&r&   SSKJ'r'J(r(   SSKJ)r)   SSKJr   SSKJr  S r*S r+S r,S r-S r.S r/ \R`                  r1S r3\1r4\5" \S5      (       a  \4Rm                  \R>                  5        S r7S r8S r9S r:S  r;S! r<S" r=S# r>S$ r?S% r@S8S& jrAS' rBS( rCS) rDS* rES+ rFS, rGS- rHS. rIS9S/ jrJS9S0 jrKS9S1 jrLS9S2 jrMS3 rNS4 rOS5 rPS6 rQS7 rRg! \
 a
    SSKJr	   GNgf = f! \
 a    \" \5      r'S
rS	r Nf = f! \
 a     SSKJ)r)   N! \
 a    S
r  GNf = ff = f! \
 a     SSKJr   GN! \
 a    S
r  GNf = ff = f! \
 a     SSKJr   GN/! \
 a    S
r  GN;f = ff = f! \2 a    Sr1 GN/f = f):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                     [        U [        5      (       d   e[        U S5      (       a  U R                  $ U R                  b  U R                  n U R                  b  M  U $ )z@This function exists for compatibility with old typing versions._gorg)
isinstancer   hasattrr   
__origin__clss    F/var/www/html/shao/venv/lib/python3.13/site-packages/typing_inspect.pyr   r   \   sP    c;''''sGyy
..
$nn ..
$J    c                 t   [         (       a|  [        U [        5      =(       a    [        U [        5      =(       dN    [        U [
        5      =(       a7    U R                  [        [        [        [        R                  R                  4;  $ [        U [        5      =(       a    [        U [        [        45      (       + $ )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    $ z2t$@B)@ X212 XeUHkoo>V>V%WW	Y r;' 6rL)45-6 7r%   c                    [         (       a  U [        L =(       d    [        U [        5      =(       a&    U R                  [
        R                  R                  L =(       dR    [        U [        5      =(       a;    [        U [        5      =(       a$    [        U [
        R                  R                  5      $ [        U 5      [        L $ )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    & zh 9*R1C"D #:!9!9992t$ 9B)@ 92{778	: 8|##r%   c                 4   [         (       a}  U [        L =(       dn    [        U [        5      =(       a    U R                  [
        L =(       d>    [        U [        5      =(       a'    [        U [        5      =(       a    [        U [
        5      $ [        U 5      [        L $ )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      sr    $ ze &z".@A  '&&2t$ &B)@ &2u%	' 8y  r%   c                 v    U [        S5      L a  g[        U 5      (       a  [        S [        U SS9 5       5      $ g)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   6   #    U H  n[        U5      v   M     g 7fN)is_optional_type).0tts     r$   	<genexpr>#is_optional_type.<locals>.<genexpr>   s     N2MB#B''2Ms   )evaluateF)r(   is_union_typeanyget_argsr.   s    r$   r8   r8      s9     
T$Z	r		N(22MNNNr%   c                     [         (       a8  U [        L =(       d)    [        U [        5      =(       a    U R                  [        L $ [
        =(       a    [        U 5      [        L $ )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_typerC      sI     ze N212Mr}}7M	O,$r(f,,r%   c                     [         (       a\  U [        L =(       dM    [        U [        5      =(       a    U R                  [        L =(       d    [
        =(       a    [        U [
        5      $ [        U 5      [        L $ )zTest 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>      s[     ze DB 23N8NDBJr>$B	E 8vr%   r   c                     [         (       a:  U [        ;   =(       d*    [        U [        5      =(       a    U R                  [        ;   $ [
        =(       a    [        U 5      [        [        5      L $ r7   )r'   LITERALSr   r*   r!   WITH_LITERALr(   r   r.   s    r$   is_literal_typerI      sK    zh Q212Pr}}7P	R5DHW55r%   c                 $    [        U 5      [        L $ )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_typevarrK      s     8wr%   c                     [         (       a8  U [        L =(       d)    [        U [        5      =(       a    U R                  [        L $ [
        (       a  [        U 5      [        L $ g)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_classvarrN     sL     zh Q212Pr}}7P	R	Bx9$$r%   c                    [         (       d  g[        R                  SS S:  a^  [        R                  R                  S:w  a@  U [        [
        R                  4;   =(       d     [        U [        [
        R                  45      $ [        R                  SS S:  a   [        U [
        R                  5      nU(       a  U$  U [        [
        R                  4;   =(       d<    [        U SS5      SL=(       a&    [        U SS	5      S
:H  =(       a    U R                  S;   $ U [        L =(       d%    [        U SS5      SL=(       a    U R                  S;   $ ! [         a     Nf = f)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   rV   r   	TypeErrorgetattr
__module__)r/   ress     r$   is_new_typer_     sP    <			"1		+0@0@0M0MQW0Ww 1 9 9:: E2):)B)BCD	F			"1		*	R!2!:!:;C 
 w 1 9 9:: C_d34? B^R04OOB"AA	D g C_d34? B"AA	D  		s   E 
EEc                 X    [         (       d  [        U [        5      $ [        U [        5      $ )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_refra   6  s#     :"k**b*%%r%   c                 t    [         (       a  [        S5      e[        5       n[        U SU5      nX!L a  gUc  U $ U$ )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_originrg   C  sH     z 3 4 	4xHRx0F~	Mr%   c                    [         (       aF  [        U [        5      (       a!  U R                  [        La  U R                  $ S$ U [
        L a  [
        $ g[        U [        5      (       a  [        U 5      $ [        U 5      (       a  [        $ [        U 5      (       a  [        $ [        U 5      (       a&  [         (       a  U R                  =(       d    U $ [        $ g)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   rI   r   r.   s    r$   
get_originri   [  s     zb,--$&MM$A2==KtK=N"k""RyRRr:==&B&r%   c                 H   [         (       GaJ  [        U 5      (       a=  / nU R                  b  U R                  OS H  nU[        U5      -  nM     [	        U5      $ [        U 5      (       a=  / nU R                  b  U R                  OS H  nU[        U5      -  nM     [	        U5      $ [        U 5      (       a  / nU R                  nUc  gU Hx  n[        U5      (       a  [        U5      OU4 HS  n[        U5      (       a#  [        U[        5      (       d  [        SU-  5      eUc  / nXQ;  d  MB  UR                  U5        MU     Mz     Ub  [	        U5      $ gg[        (       af  [        U [         5      (       a  [#        U S5      (       d3  [        U [$        5      (       a*  ['        U [(        5      (       a  U [(        La  U R                  $ g[        U 5      (       d0  [        U 5      (       d   [+        U 5      (       d  [        U 5      (       a  U R                  b  U R                  $ S$ g)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)
 zKCannot inherit from a generic class parameterized with non-type-variable %s__parameters__)LEGACY_TYPINGr>   __union_params__get_parametersr+   r4   __tuple_params__r0   rl   r@   _has_type_varr   r   r[   appendr'   r*   r    r(   r)   r
   r2   )r/   paramsargbase_paramsbp_bps         r$   ro   ro   z  s    }F/1/B/B/N++TVV.-- W= 2F/1/B/B/N++TVV.-- W= R  F++K"",9#,>,>8C=SFJB$R((B1H1H'35789 9 ~!#'b) K # !V}$	 r#566B 0112t$$B)@)@'!$$$}R00b 1 1$&$5$5$Ar  IrIr%   c                    [         (       a  [        S5      e[        U 5      (       a  U R                  b  U R                  4$ S$ [	        U 5      (       aN   U R
                  b%  [        U R
                  5      S:  a  U R
                  $ U R                  b  U R                  $ S$ [        U 5      (       a   U R
                  b  U R
                  $ S$ [        U 5      (       a  U R
                  b  U R
                  $ S$ [        U 5      (       a   U R
                  b  U R
                  $ S$ g! [         a     Nf = f! [         a     U R                  b  U R                  s $ Ss $ f = f! [         a     U R                  b  U R                  s $ Ss $ f = f)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 insteadrk   r   )r'   rc   rN   __type__r0   __args__lenAttributeErrorrl   r>   rn   r2   r4   rp   r.   s    r$   get_last_argsr}     s|    z 1 2 	2	R!#!8~@b@				{{&3r{{+;a+?{{" %'$5$5$Ar  IrI	r			R"$++"92;;ArA 
"		 kk5r{{=2=	r			R"$++"92;;ArA
 '  		  	R*,*=*=*I2&&QrQ	R  	R*,*=*=*I2&&QrQ	RsN   1D% 2D5 D5 	E" "E" %
D21D25#EEE"#FFFc                 D   / nU  GH  n[        U[        5      (       d  UR                  U5        M,  [        US   5      (       a  [	        USS 5      n[        U5      S:X  a  UR                  [        / US   4   5        M{  US   [        L a  UR                  [        SUS   4   5        M  UR                  [        [        USS 5      US   4   5        M  UR                  [        US   5      R                  US   [	        USS 5      5      5        GM     [        U5      $ )zInternal helper for get_args.r      Nr   .)r   r+   rr   r2   
_eval_argsr{   r   Ellipsislistr(   __getitem__)argsr^   rt   callable_argss       r$   r   r     s    
C#u%%JJsOc!f%%&s12w/M3x1}

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

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

8Ds);$<mB>O$OPQJJtCF|//A
3qr78KLM  :r%   c                    [         (       a  Ub  U(       d  [        S5      e[        U [        5      (       ad  [	        U S5      (       aS  U R
                  n[        U 5      [        R                  R                  L a  US   [        La  [        USS 5      US   4nU$ [        (       a!  [        U [        5      (       a  U R
                  $ g[        U 5      (       d  [        U 5      (       a  U R                  b  U R                  4$ S$ [!        U 5      (       a  U R"                  =(       d    S$ [%        U 5      (       d0  ['        U 5      (       d   [)        U 5      (       d  [+        U 5      (       a   U R-                  5       n[        U[6        5      (       a\  [9        U5      S:  aM  U(       d  USS $ [;        USS 5      n[        U 5      [        L a  US   [        La  [        USS 5      US   4nU$ g! [.         aZ    ['        U 5      (       a  [1        U 5      n N[%        U 5      (       a  [3        U 5      n N[+        U 5      (       a  [5        U 5      n N gf = f)at  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.7rz   r   r   rk   r   )r'   rc   r   r*   r    rz   ri   r,   r-   r   r   r   rE   rN   rC   ry   rI   
__values__r0   r>   r2   r4   
_subs_treer|   _union_subs_tree_generic_subs_tree_tuple_subs_treer+   r{   r   )r/   r=   r^   trees       r$   r@   r@     s   ( zIJJb,--'"j2I2I++C"~!9!99c!fH>TCH~s2w/J>j^<<;;2-++!#!8~@b@r}}""}R00b 1 1	==?D  dE""s4y1}ABxT!"X&C"~)c!fH.DCH~s2w/J/  	R  '+ $$)"-r""'+ 	s   )G+ +%II/IIc                 j    [        U 5      (       a  [        U SS5      $ [        S[        U 5      -   5      e)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`: rK   r\   r[   strr.   s    r$   	get_boundr   A  s1     "~~r;--3c"g=>>r%   c                 j    [        U 5      (       a  [        U SS5      $ [        S[        U 5      -   5      e)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__rk   r   r   r.   s    r$   get_constraintsr   Q  s2     "~~r,b113c"g=>>r%   c                 <    [        U SS5      nUb  U$ [        U 5      $ )a  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3H+8:c:r%   c                 j    [         (       a  [        S U R                   5       5      $ [        U SS5      $ )zGet 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   R   #    U H  n[        U[        5      (       d  M  Uv   M      g 7fr7   )r   r   )r9   ts     r$   r;   $get_generic_bases.<locals>.<genexpr>{  s     K1
1k0JQQs   '	'__orig_bases__rk   )rm   r+   	__bases__r\   r.   s    r$   get_generic_basesr   q  s.     }KKKKr+R00r%   c                 n    [        U [        [        45      (       a  U R                  R	                  5       $ g)aW  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     s0     "*,=>??!!&&((r%   c                 >    [        U 5      (       a  U R                  $ S$ )z
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)ra   __forward_arg__)frs    r$   get_forward_argr     s     "0!3!32==r%   c                     Uc  / n[        U 5      (       a  [        XU5      $ [        U 5      (       a  [        XU5      $ [	        U 5      (       a  [        XU5      $ [        U [        5      (       a  [        U5       H  u  p4X:X  d  M  X#   s  $    U $ )zbackport of _replace_arg)	r>   r   r4   r   r0   r   r   r   	enumerate)rt   tvarsr   itvars        r$   _replace_argr     s    } SD11SD11s!#d33#w 'GA{w ( Jr%   c                   ^^ / nU  H  n[        U[        5      (       a  UR                  UR                  5        M5  [        U[        5      (       a1  [        U5      S:  a"  US   [        L a  UR                  USS 5        M{  UR                  U5        M     [        U5      m[        T5      [        U5      :  aE  / nU H-  nUT;   d  M  UR                  U5        TR                  U5        M/     UnT(       a   T5       e[        U5      mU HK  m[        T[        5      (       d  M  [        U4S jTT1-
   5       5      (       d  M:  TR                  T5        MM     [	        U4S jU 5       5      $ )z backport of _remove_dups_flattenr   r   Nc              3      >#    U Hb  n[        U[        5      (       a  [        U5      b  M&  [        U[        5      (       a  M=  [        U[        5      =(       a    [        TU5      v   Md     g 7fr7   )r   r   ri   r   r(   r)   )r9   t2t1s     r$   r;   '_remove_dups_flatten.<locals>.<genexpr>  sU      1*2"2{33"2 ; ""g.	 ;z"d#:
2r(::*s   $A,A,*A,c              3   4   >#    U H  oT;   d  M
  Uv   M     g 7fr7   rk   )r9   r   
all_paramss     r$   r;   r     s     6Fq:oFs   	)r   r   extendrn   r+   r{   r   rr   setremover(   r?   )
parametersrs   p
new_paramsr   r   r   s        @@r$   _remove_dups_flattenr     s<    Fa  MM!,,-5!!c!fqjQqTU]MM!AB% MM!  VJ
:V$
AJ!!!$!!!$  )z)~ VJ"d## 1#rd*1 1 1
 b!  6F666r%   c           
         S nU" U 5      nUc"  [        U 5      (       d  [        U 5      (       d  U $ / nU" U5      b$  UR                  U5        U" U5      nU" U5      b  M$  / nS nU" U 5       H  nUR                  [        XU5      5        M      U H;  n	/ n
U" U	5       H(  nU
R                  [        U[	        U	5      U5      5        M*     U
nM=     U$ )z;backport of typing._subs_tree, adapted for legacy versions c                 <     U R                   $ ! [         a     g f = fr7   )r!   r|   r"   s    r$   _get_origin_subs_tree.<locals>._get_origin  s#    	>>! 		s    
c                     [        U 5      (       a  U R                  nO*[        U 5      (       a  U R                  nO U R                  nUb  U$ S$ ! [
         a    Sn Nf = f)Nrk   )r>   rn   r4   rp   rz   r|   )r#   cls_argss     r$   	_get_args_subs_tree.<locals>._get_args  sd    ++H3++H<< $/x7R7 " s   A AA)r>   r4   rr   r   ro   )r#   r   r   r   current
orig_chain	tree_argsr   rt   oclsnew_tree_argss              r$   r   r     s     #GS!!-*<*<J J
g

*'"g& g

*
 I
8 ~c$78  T?C  c>$3G!ST #!		 
 r%   c                     U [         L a  [         $ [        XU5      n[        U5      n[        U5      S:X  a  US   $ [         4U-   $ )zbackport of Union._subs_tree r   r   )r   r   r   r{   r/   r   r   r   s       r$   r   r     sG    	U{2d+I$Y/I
9~|8ir%   c                 h    U R                   c  U $ [        XU5      n[        U 5      4[        U5      -   $ )z#backport of GenericMeta._subs_tree )r!   r   r   r+   r   s       r$   r   r     s3    	}}	2d+I"I<%	***r%   c                 ^    U [         L a  [         $ [        XU5      n[         4[        U5      -   $ )z6ad-hoc function (inspired by union) for legacy typing )r   r   r+   r   s       r$   r   r     s,    	U{2d+I8eI&&&r%   c                     U c  g[        U 5      (       a  [        U 5      $ [        U 5      (       a  [        U 5      $ [	        U 5      (       a  [        U 5      $ [        U 5      (       a  [        U 5      $ g)NF)r>   _union_has_type_varr4   _tuple_has_type_varr0   _generic_has_type_varr2   _callable_has_type_var)r   s    r$   rq   rq   '  se    y	q		"1%%	q		"1%%			$Q''	!		%a((r%   c                 p    U R                   (       a%  U R                    H  n[        U5      (       d  M    g   gNTF)rn   rq   r/   r   s     r$   r   r   6  .    	$$AQ % r%   c                 p    U R                   (       a%  U R                    H  n[        U5      (       d  M    g   gr   )rp   rq   r   s     r$   r   r   >  r   r%   c                     U R                   (       a%  U R                    H  n[        U5      (       d  M    g   [        U R                  5      $ )NT)rz   rq   
__result__r   s     r$   r   r   F  s6    	{{AQ  ''r%   c                 p    U R                   (       a%  U R                    H  n[        U5      (       d  M    g   gr   )rl   rq   r   s     r$   r   r   N  s.    	""AQ # r%   r7   )NN)S__doc__rX   typesrU   rV   mypy_extensionsr   r   rY   r   ImportErrorr   r(   r'   collections.abcr,   rB   rH   rM   rW   rm   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   rC   	UnionTyperE   r|   r>   rG   r    addrI   rK   rN   r_   ra   rg   ri   ro   r}   r   r@   r   r   r   r   r   r   r   r   r   r   r   r   rq   r   r   r   r   rk   r%   r$   <module>r      s       A   !$0y0EbqY&?I
 !Ybq!Y.

   1
y(/+-A5CUCUV+-  ,,!-!-74$6!4*
-__N
" 9
69LL 6"D@
&0>BJ(V&AH? ? ; 1(
>&%7P*Z	 +'(i  ?>>?F  e	  	% 	J	  !	!&& 	! L	!!  !	!&& 	! L	!!H  Ns   F> 4G =G) H H0 $I >GGG&%G&)H	0G88H H	HH	H-HH)$H-(H))H-0I7I  IIIII I 