
    hh@             
       Z   d dl Z d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dl	Z		 d dl
m Z ej                  dd dk\  rd dlZ	 d dl	mZmZmZ g dZd Zd Z G d	 d
e      Z G d ded      Z G d ded      Z G d ded      Z G d ded      Zd Z d Z!d Z"d Z#d Z$ G d ded      Z% e%d      Z& G d ded      Z' e'd      Z( G d d ed      Z) e)d!      Z* e)d"      Z+ e)d#      Z, e)d$d%      Z- e)d&d%      Z. e)d'd%      Z/ e)d(d)      Z0 e)d*e1e      Z2d+ Z3dd,Z4d- Z5d. Z6g Z7d/ Z8 G d0 d1ed      Z9 e9d      Z: G d2 d3ed      Z; e;d      Z<d4 Z=d5 Z>d6 Z? G d7 d8ee j                        ZAdZBd9 ZC G d: d;eA<      ZB G d= d>      ZD G d? d@      ZE G dA dBeA      ZF G dC dDeGeGeFE      ZH G dF dGeA      ZI G dH dIej                  eIE      ZJ G dJ dKed      ZK eKd      ZLdL ZMdM ZNe	j                  e	j                  e	j                  e	j                  eeefZSddNZTdO ZUdP ZVdQ ZWdR ZX G dS dTeA      ZY G dU dVeY<      ZZej                  Z[ e\edW      r+ G dX dWeBe-   ej                  Y      Z]ej                  dW        e\edZ      r2 G d[ dZe]e.   eBe-e0e.f   ej                  Y      Z_ej                  dZ        e\ed\      rV G d] d\eBe-   ej                  Y      Z` G d^ d_e`e-   ej                  Y      Zaej                  d\       ej                  d_        G d` daeBe-   ej                  Y      Zb G db dcebe-   ej                  Y      Zc G dd deeZ      Zd G df dgeZ      Ze G dh dieZ      Zf G dj dkeZ      Zg G dl dmeZ      Zh G dn doeZe-         Zi G dp dqeZe-         Zj e\edr      r G ds drebe-   ej                  Y      Zkn G dt dreZe-         Zkej                  Zl G du dveBe-   ej                  Y      Zm e\edw      r0 G dx dwelebe-   eme-   ej                  Y      Znej                  dw        e\edw      r G dy dzene-   ej                  Y      Zpn G d{ dzelebe-   eme-   ej                  Y      Zp G d| d}epe*   ej                  Y      Zq e\edw      r! G d~ dene+   eBe+e/f   ej                  Y      Zrn% G d delebe+   eme+   eBe+e/f   ej                  Y      Zr G d dere+e,f   ej                  Y      Zs e\edr      rH e\edw      r G d deke-   ene-   ej                  Y      Ztn? G d deleke-   eme-   ej                  Y      Ztn G d delebe-   eme-   ej                  Y      Zt G d dete*   ej                  Y      Zu G d detev   ej                  Y      Zw G d dexeue*   exY      Zy G d dej                  eue*   ej                  Y      Z{ G d de|eqe*   e|Y      Zo G d de}epe-   e}Y      Z~ G d delebe-   ej                  Y      Z G d dee+   epe+   ej                   Y      Z G d deeHe+e/f      epeHe+e/f      eBe+e/f   ej                  Y      Z G d dee/   ej                  Y      Z e\ed      r G d deBe-   ej                  Y      Zn G d deBe-         Z e\ed      r- G d deBe-   ej
                  Y      Zej                  d       nej                  dd dk\  r ed        G d deese+e,f   eY      Z G d dej                  ese+e,f   ej                  Y      Z G d dej                  ee*evf   ej                  Y      Z e\ed      r:ej                  d        G d dej                  ese+e,f   ej                  Y      Z e\ed      rej                  Zne	j                   Z G d dece-   eBe-e0e.f   eY      Z e\ed      r2 G d deae-   eBe-e0f   ej"                  Y      Zej                  d        e)dde      Z G d deBe   eY      Zd Zej                  dd dk\  ZdZdZ G d de      Z G d de<      Zd ZeZdZ G d deBe2         Z G d dee1         Z G d dee         Z G dÄ dī      Zedz   e_        eejD                  ejB                  <    ede2 e ejF                  dǫ            dȄ       Z ede2 e ejJ                  ddǫ            dʄ       Z G d˄ d̫      Zedz   e_        eejD                  ejB                  <   y# e$ r d dlZY 	6w xY w# e$ r?  eej(                        Z e e       j*                        Z eej.                        ZY 	\w xY w)    N)abstractmethodabstractproperty   )      )WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorType)6AnyCallableClassVarGenericOptionalTupleTypeTypeVarUnionAbstractSetGenericMeta
ByteString	ContainerContextManagerHashable	ItemsViewIterableIteratorKeysViewMappingMappingViewMutableMappingMutableSequence
MutableSetSequenceSized
ValuesView
ReversibleSupportsAbsSupportsBytesSupportsComplexSupportsFloatSupportsIndexSupportsIntSupportsRoundCounterDequeDictDefaultDictListSet	FrozenSet
NamedTuple	GeneratorAnyStrcastget_type_hintsNewTypeno_type_checkno_type_check_decoratorNoReturnoverloadTextTYPE_CHECKINGc                 ^    t         j                  d d dk\  r| j                  S | j                  S )Nr   )r   r   )sysversion_info__qualname____name__xs    D/var/www/html/dev/engine/venv/lib/python3.12/site-packages/typing.py	_qualnamerI   i   s-    
v%~~ zz    c                 >    d}| j                  d      r	| |vr| dd  } | S )N)
_TypeAlias_ForwardRef_TypingBase_FinalTypingBase_   )
startswith)nm	whitelists     rH   
_trim_namerU   q   s*    PI	}}Sb	1VIrJ   c                   D     e Zd ZdZdZdd fd
Zd Zd Zd Zd Z	 xZ
S )	
TypingMetaa  Metaclass for most types defined in typing module
    (not a part of public API).

    This overrides __new__() to require an extra keyword parameter
    '_root', which serves as a guard against naive subclassing of the
    typing classes.  Any legitimate class defined using a metaclass
    derived from TypingMeta must pass _root=True.

    This also defines a dummy constructor (all the work for most typing
    constructs is done in __new__) and a nicer repr().
    F_rootc          	          |s/t        ddj                  t        t        |            xs dz        t        |   | |||      S )NzCannot subclass %s, ())	TypeErrorjoinmap
_type_reprsuper__new__)clsnamebases	namespacerY   	__class__s        rH   rb   zTypingMeta.__new__   sK    0!YYs:u'=>F$H I IwsD%;;rJ   c                      y N selfargskwdss      rH   __init__zTypingMeta.__init__       rJ   c                     | S )a'  Override this in subclasses to interpret forward references.

        For example, List['C'] is internally stored as
        List[_ForwardRef('C')], which should evaluate to List[C],
        where C is an object found in globalns or localns (searching
        localns first, of course).
        rj   rl   globalnslocalnss      rH   
_eval_typezTypingMeta._eval_type   s	     rJ   c                      y ri   rj   rl   tvarss     rH   _get_type_varszTypingMeta._get_type_vars   rp   rJ   c                 L    t        t        |             }| j                  d|S N.)rU   rI   
__module__)rl   qnames     rH   __repr__zTypingMeta.__repr__   s    9T?+//511rJ   )rE   r}   rD   __doc___is_protocolrb   ro   ru   ry   r   __classcell__rg   s   @rH   rW   rW   x   s+    
 L6; <2rJ   rW   c                   D     e Zd ZdZdZd Z fdZd Zd Zd Z	d Z
 xZS )	rN   z0Internal indicator of special typing constructs.)__weakref__c                      y ri   rj   rk   s      rH   ro   z_TypingBase.__init__   rp   rJ   c                     t        |      dk(  r4t        |d   t              r!t        |d   t              rt	        d| z        t
        |   |       S )zConstructor.

        This only exists to give a better error message in case
        someone tries to subclass a special typing object (not a good idea).
        r   r   rQ   zCannot subclass %r)len
isinstancestrtupler]   ra   rb   )rc   rm   rn   rg   s      rH   rb   z_TypingBase.__new__   sL     IN47C(47E*03677ws##rJ   c                     | S ri   rj   rr   s      rH   ru   z_TypingBase._eval_type   s    rJ   c                      y ri   rj   rw   s     rH   ry   z_TypingBase._get_type_vars   rp   rJ   c                 b    t        |       }t        t        |            }|j                  d|S r{   )typerU   rI   r}   )rl   rc   r~   s      rH   r   z_TypingBase.__repr__   s(    4j9S>*..%00rJ   c                 0    t        dt        |       z        )NCannot instantiate %r)r]   r   rk   s      rH   __call__z_TypingBase.__call__   s    /$t*<==rJ   )rE   r}   rD   r   	__slots__ro   rb   ru   ry   r   r   r   r   s   @rH   rN   rN      s)    : I$1
>rJ   rN   T)	metaclassrY   c                   2     e Zd ZdZdZdd fd
Zd Z xZS )rO   zInternal mix-in class to prevent instantiation.

    Prevents instantiation unless _root=True is given in class call.
    It is used to create pseudo-singleton instances Any, Union, Optional, etc.
    rj   FrX   c                R    t        |   | g|i |}|du r|S t        d| z        )NTr   )ra   rb   r]   )rc   rY   rm   rn   rl   rg   s        rH   rb   z_FinalTypingBase.__new__   s8    ws2T2T2D=K/#566rJ   c                 >    t        t        |       j                        S ri   )rU   r   rE   rl   s    rH   
__reduce__z_FinalTypingBase.__reduce__   s    $t*--..rJ   )rE   r}   rD   r   r   rb   r   r   r   s   @rH   rO   rO      s     I"' 7/rJ   rO   rX   c                   J     e Zd ZdZdZ fdZd Zd Zd Zd Z	d Z
d	 Z xZS )
rM   z-Internal wrapper to hold a forward reference.)__forward_arg____forward_code____forward_evaluated____forward_value__c                     t         |   |       t        |t              st	        d|      	 t        |dd      }|| _        || _        d| _	        d | _
        y # t        $ r t        d|      w xY w)Nz*Forward reference must be a string -- got z<string>evalz/Forward reference must be an expression -- got F)ra   ro   r   r   r]   compileSyntaxErrorr   r   r   r   )rl   argcoderg   s      rH   ro   z_ForwardRef.__init__   s    #s#cSTT	&3
F3D  # $%*"!%  	&"% & &	&s   A A2c                     | j                   r||ur?||i x}}n	||}n||}t        t        | j                  ||      d      | _        d| _         | j                  S )Nz*Forward references must evaluate to types.T)r   _type_checkr   r   r   rr   s      rH   ru   z_ForwardRef._eval_type   ss    ))WH-DGO%''7!""%0T**Hg><&>D" *.D&%%%rJ   c                     t        |t              st        S | j                  r@|j                  r4| j                  |j                  k(  xr | j
                  |j
                  k(  S | j                  |j                  k(  S ri   )r   rM   NotImplementedr   r   r   rl   others     rH   __eq__z_ForwardRef.__eq__   sn    %-!!%%%*E*E((E,A,AA F**e.E.EEG##u'<'<<<rJ   c                 ,    t        | j                        S ri   )hashr   r   s    rH   __hash__z_ForwardRef.__hash__  s    D(())rJ   c                     t        d      )Nz4Forward references cannot be used with isinstance().r]   rl   objs     rH   __instancecheck__z_ForwardRef.__instancecheck__      NOOrJ   c                     t        d      )Nz4Forward references cannot be used with issubclass().r   rl   rc   s     rH   __subclasscheck__z_ForwardRef.__subclasscheck__
  r   rJ   c                 "    d| j                   dS )Nz_ForwardRef())r   r   s    rH   r   z_ForwardRef.__repr__  s    $($8$8::rJ   )rE   r}   rD   r   r   ro   ru   r   r   r   r   r   r   r   s   @rH   rM   rM      s2    7?I&&=*PP;rJ   rM   c                   >    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zy
)rL   a:  Internal helper class for defining generic variants of concrete types.

    Note that this is not a type; let's call it a pseudo-type.  It cannot
    be used in instance and subclass checks in parameterized form, i.e.
    ``isinstance(42, Match[str])`` raises ``TypeError`` instead of returning
    ``False``.
    )rd   type_var	impl_typetype_checkerc                 H   t        |t              sJ t        |             t        |t              sJ t        |             t        |t              rJ t        |             t        |t        t
        f      sJ t        |             || _        || _        || _        || _	        y)at  Initializer.

        Args:
            name: The name, e.g. 'Pattern'.
            type_var: The type parameter, e.g. AnyStr, or the
                specific type, e.g. str.
            impl_type: The implementation type.
            type_checker: Function that takes an impl_type instance.
                and returns a value that should be a type_var instance.
        N)
r   r   reprr   rW   rN   rd   r   r   r   )rl   rd   r   r   r   s        rH   ro   z_TypeAlias.__init__  s     $$0d4j0$)T*;DO;*i4Ed9oE4(T;$78H$x.H8	 "(rJ   c                 L    | j                   dt        | j                        dS )N[])rd   r`   r   r   s    rH   r   z_TypeAlias.__repr__0  s    99j&?@@rJ   c                    t        | j                  t              st        d| z        | j                  j                  rKt        |t
              r;t        || j                  j                        st        |d| j                  d      t        |t              r|| j                  urt        d| z        | j                  | j                  || j                  | j                        S )Nz#%s cannot be further parameterized.z! is not a valid substitution for r|   z%s cannot be re-parameterized.)r   r   r   r]   __constraints__r   
issubclassrg   rd   r   r   )rl   	parameters     rH   __getitem__z_TypeAlias.__getitem__3  s    $--1ADHII==((Z	4-Hi)F)FG!*DMM!; < <i)it}}.L<tCDD~~dii"nnd.?.?A 	ArJ   c                     t        |t              st        S | j                  |j                  k(  xr | j                  |j                  k(  S ri   )r   rL   r   rd   r   r   s     rH   r   z_TypeAlias.__eq__?  s7    %,!!yyEJJ&J4==ENN+JJrJ   c                 D    t        | j                  | j                  f      S ri   )r   rd   r   r   s    rH   r   z_TypeAlias.__hash__D  s    TYY.//rJ   c                 x    t        | j                  t              st        d      t        || j                        S )Nz<Parameterized type aliases cannot be used with isinstance().)r   r   r   r]   r   r   s     rH   r   z_TypeAlias.__instancecheck__G  3    $--1 1 2 2#t~~..rJ   c                 x    t        | j                  t              st        d      t	        || j
                        S )Nz<Parameterized type aliases cannot be used with issubclass().)r   r   r   r]   r   r   r   s     rH   r   z_TypeAlias.__subclasscheck__M  r   rJ   N)rE   r}   rD   r   r   ro   r   r   r   r   r   r   rj   rJ   rH   rL   rL     s5     BI)(A
AK
0//rJ   rL   c                 v    | D ]4  }t        |t              st        |t              s$|j                  |       6 y ri   )r   rW   rN   ry   )typesrx   ts      rH   ry   ry   T  s2     $a$
1k(BU#$rJ   c                 4    g }t        | |       t        |      S ri   )ry   r   )r   rx   s     rH   
_type_varsr   Z  s    E5% <rJ   c                 j    t        | t              st        | t              r| j                  ||      S | S ri   )r   rW   rN   ru   )r   rs   rt   s      rH   ru   ru   `  s+    !Z Jq+$>||Hg..HrJ   c                    | t        d      S t        | t              rt        |       } t        | t              rt        |       j
                  dk(  s!t        | t         t        f      st        |       st        |d| fz  z         t        |       j
                  dv rt        | dd      r(t        | t              r&| j                  t        t        fv rt        d| z        | S )a  Check that the argument is a type, and return it (internal helper).

    As a special case, accept None and return type(None) instead.
    Also, _TypeAlias instances (e.g. Match, Pattern) are acceptable.

    The msg argument is a human-readable error message, e.g.

        "Union[arg, ...]: arg should be a type."

    We append the repr() of the actual value (truncated to 100 chars).
    N	_ClassVarz Got %.100r.)_Union	_Optional
__origin__z&Plain %s is not valid as type argument)r   r   r   rM   rN   rE   callabler]   getattrrW   _gorgr   	_Protocol)r   msgs     rH   r   r   f  s     {Dz#s#3$c););{)JsT;/0#nv5566 	S	55Ct,3
#		gy5I(I@3FGGJrJ   c                    t        | t              rDt        | t              s4| j                  dk(  rt	        |       S | j                  dt	        |       S | du ryt        | t
        j                        r| j                  S t        |       S )a;  Return the repr() of an object, special-casing types (internal helper).

    If obj is a type, we return a shorter version than the default
    type.__repr__, based on the module and qualified name, which is
    typically enough to uniquely identify a type.  For everything
    else, we fall back on repr(obj).
    builtinsr|   ....)	r   r   rW   r}   rI   r   FunctionTyperE   r   )r   s    rH   r`   r`     sn     #tZZ%@>>Z'S>!..)C.99
cz#u))*||9rJ   c                        e Zd ZdZdZd Zd Zy)_Anya`  Special type indicating an unconstrained type.

    - Any is compatible with every type.
    - Any assumed to have all methods.
    - All values assumed to be instances of Any.

    Note that all the above statements are true from the point of view of
    static type checkers. At runtime, Any should not be used with instance
    or class checks.
    rj   c                     t        d      )Nz%Any cannot be used with isinstance().r   r   s     rH   r   z_Any.__instancecheck__      ?@@rJ   c                     t        d      )Nz%Any cannot be used with issubclass().r   r   s     rH   r   z_Any.__subclasscheck__  r   rJ   NrE   r}   rD   r   r   r   r   rj   rJ   rH   r   r     s    	 IAArJ   r   c                        e Zd ZdZdZd Zd Zy)	_NoReturna  Special type indicating functions that never return.
    Example::

      from typing import NoReturn

      def stop() -> NoReturn:
          raise Exception('no way')

    This type is invalid in other positions, e.g., ``List[NoReturn]``
    will fail in static type checkers.
    rj   c                     t        d      )Nz*NoReturn cannot be used with isinstance().r   r   s     rH   r   z_NoReturn.__instancecheck__      DEErJ   c                     t        d      )Nz*NoReturn cannot be used with issubclass().r   r   s     rH   r   z_NoReturn.__subclasscheck__  r   rJ   Nr   rj   rJ   rH   r   r     s    
 IFFrJ   r   c                   H     e Zd ZdZdZdddd fd
Zd Zd Zd	 Zd
 Z	 xZ
S )r   a  Type variable.

    Usage::

      T = TypeVar('T')  # Can be anything
      A = TypeVar('A', str, bytes)  # Must be str or bytes

    Type variables exist primarily for the benefit of static type
    checkers.  They serve as the parameters for generic types as well
    as for generic function definitions.  See class Generic for more
    information on generic types.  Generic functions work as follows:

      def repeat(x: T, n: int) -> List[T]:
          '''Return a list containing n references to x.'''
          return [x]*n

      def longest(x: A, y: A) -> A:
          '''Return the longest of two strings.'''
          return x if len(x) >= len(y) else y

    The latter example's signature is essentially the overloading
    of (str, str) -> str and (bytes, bytes) -> bytes.  Also note
    that if the arguments are instances of some subclass of str,
    the return type is still plain str.

    At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError.

    Type variables defined with covariant=True or contravariant=True
    can be used do declare covariant or contravariant generic types.
    See PEP 484 for more details. By default generic types are invariant
    in all type variables.

    Type variables can be introspected. e.g.:

      T.__name__ == 'T'
      T.__constraints__ == ()
      T.__covariant__ == False
      T.__contravariant__ = False
      A.__constraints__ == (str, bytes)
    )rE   	__bound__r   __covariant____contravariant__NFbound	covariantcontravariantc                ^   t        |   |g||||d || _        |r|rt        d      t	        |      | _        t	        |      | _        |r|t        d      |rt        |      dk(  rt        d      dt        fd|D              | _
        |rt        |d      | _        y d | _        y )	Nr   z"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rQ   z"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c              3   6   K   | ]  }t        |        y wri   r   ).0r   r   s     rH   	<genexpr>z#TypeVar.__init__.<locals>.<genexpr>  s     $NQ[C%8$N   zBound must be a type.)ra   ro   rE   
ValueErrorboolr   r   r]   r   r   r   r   r   )rl   rd   r   r   r   constraintsr   rg   s         @rH   ro   zTypeVar.__init__  s     	K 	K5#,M	KABB!)_!%m!45,KLL3{+q0@AAJ$$N+$NN(0GHDN!DNrJ   c                 0    | |vr|j                  |        y y ri   )appendrw   s     rH   ry   zTypeVar._get_type_vars
  s    uLL rJ   c                 `    | j                   rd}n| j                  rd}nd}|| j                  z   S )N+-~)r   r   rE   )rl   prefixs     rH   r   zTypeVar.__repr__  s2    F##FF%%rJ   c                     t        d      )Nz0Type variables cannot be used with isinstance().r   rl   instances     rH   r   zTypeVar.__instancecheck__      JKKrJ   c                     t        d      )Nz0Type variables cannot be used with issubclass().r   r   s     rH   r   zTypeVar.__subclasscheck__  r  rJ   )rE   r}   rD   r   r   ro   ry   r   r   r   r   r   s   @rH   r   r     s5    'R7I 26 "(&LLrJ   r   TKTVTT_co)r   V_coVT_coT_contra)r   r7   c                     |g }t        | d      r(t        | t        t        f      r| j	                  ||      S t        | t
              rt        |      D ]  \  }}| |k(  s||   c S  | S )zAn internal helper function: replace arg if it is a type variable
    found in tvars with corresponding substitution from args or
    with corresponding substitution sub-tree if arg is a generic type.
    
_subs_tree)hasattrr   r   rN   r  r   	enumerate)r   rx   rm   itvars        rH   _replace_argr  -  sp     }sL!j{K6P&Q~~eT**#w ' 	GAtd{Aw	 JrJ   c           	         | j                   | S | j                   }g }|j                   *|j                  |       |j                   }|j                   *g }| j                  D ]  }|j                  t        |||               |D ]=  }g }|j                  D ](  }|j                  t        ||j                  |             * |}? |S )a  An internal helper function: calculate substitution tree
    for generic cls after replacing its type parameters with
    substitutions in tvars -> args (if any).
    Repeat the same following __origin__'s.

    Return a list of arguments with all possible substitutions
    performed. Arguments that are generic classes themselves are represented
    as tuples (so that no new classes are created by this function).
    For example: _subs_tree(List[Tuple[int, T]][str]) == [(Tuple, int, str)]
    )r   r   __args__r  __parameters__)	rc   rx   rm   current
orig_chain	tree_argsr   oclsnew_tree_argss	            rH   r  r  H  s     ~~
nnGJ



('"$$ 


( I|| 9c5$789  "== 	TC  c43F3F	!RS	T!		"
 rJ   c                    g }| D ]  }t        |t              r.|j                  t        u r|j	                  |j
                         At        |t              r.t        |      dkD  r |d   t        u r|j	                  |dd        |j                  |        t        |      t              t        |      k  r;g }|D ])  }|v s|j                  |       j                  |       + |}rJ        t        |      |D ]=  t        t              st        fdhz
  D              s-j                         ? t        fd|D              S )zAn internal helper for Union creation and substitution: flatten Union's
    among parameters, then remove duplicates and strict subclasses.
    r   rQ   Nc              3      K   | ]>  }t        |t              r|j                   t        |t              xr t	        |       @ y wri   )r   r   r   r   r   )r   t2t1s     rH   r   z'_remove_dups_flatten.<locals>.<genexpr>  sC      3!"k2}}0 "d#:
2r(:: 3s   AAc              3   ,   K   | ]  }|v s|  y wri   rj   )r   r   
all_paramss     rH   r   z'_remove_dups_flatten.<locals>.<genexpr>  s     6qa:o6s   	)r   r   r   r   extendr  r   r   r   setremover   any)
parametersparamsp
new_paramsr   r$  r"  s        @@rH   _remove_dups_flattenr-  i  sF    F a Q\\U%:MM!**%5!c!fqjQqTU]MM!AB% MM! VJ
:V$
 	%AJ!!!$!!!$	% )z)~ VJ ""d# 3#rd*3 3 b!" 6F666rJ   c           
          | j                   st        dt        |       z        t        |      }t        | j                         }||k7  r't        d||kD  rdnddt        |       d|d|      y )Nz%s is not a generic classzToo manyfewz parameters for z	; actual z, expected )r  r]   r   r   )rc   r)  alenelens       rH   _check_genericr3    sr    3d3i?@@z?Ds!!"Dt|#'$;E949dDR S 	S rJ   c                       t        j                                t        j                  j                         t        j
                          fd       }|S )zInternal wrapper caching __getitem__ of generic types with a fallback to
    original function for non-hashable arguments.
    c                  D    	  | i |S # t         $ r Y nw xY w | i |S ri   r   )rm   rn   cachedfuncs     rH   innerz_tp_cache.<locals>.inner  s:    	4(4(( 		T"T""s    	)	functools	lru_cache	_cleanupsr   cache_clearwraps)r7  r8  r6  s   ` @rH   	_tp_cacher>    sP    
 #Y  "4(FV''(__T# # LrJ   c                   ~     e Zd ZdZdZddd fdZd Zd Z fdZ fd	Z	e
d
        ZddZd Zd Zd Zd Z xZS )r   a  Union type; Union[X, Y] means either X or Y.

    To define a union, use e.g. Union[int, str].  Details:

    - The arguments must be types and there must be at least one.

    - None as an argument is a special case and is replaced by
      type(None).

    - Unions of unions are flattened, e.g.::

        Union[Union[int, str], float] == Union[int, str, float]

    - Unions of a single argument vanish, e.g.::

        Union[int] == int  # The constructor actually returns int

    - Redundant arguments are skipped, e.g.::

        Union[int, str, int] == Union[int, str]

    - When comparing unions, the argument order is ignored, e.g.::

        Union[int, str] == Union[str, int]

    - When two arguments have a subclass relationship, the least
      derived argument is kept, e.g.::

        class Employee: pass
        class Manager(Employee): pass
        Union[int, Employee, Manager] == Union[int, Employee]
        Union[Manager, int, Employee] == Union[int, Employee]
        Union[Employee, Manager] == Employee

    - Similar for object::

        Union[int, object] == object

    - You cannot subclass or instantiate a union.

    - You can use Optional[X] as a shorthand for Union[X, None].
    )r  r  r   __tree_hash__FrX   c                   t        |   | ||g|d|i}|0d |_        d |_        d |_        t        t        d            |_        |S t        |t              st        d      |t        u rt        |      }t        |      dk(  r|d   S t        |      |_        ||_        ||_        |j                         }t        |t              rt        t        |            |_        |S t        |      |_        |S )NrY   )r   zExpected parameters=<tuple>rQ   r   )ra   rb   r  r  r   r   	frozensetr@  r   r   r]   r   r-  r   r   r  )rc   r)  originrY   rm   rl   	subs_treerg   s          rH   rb   z_Union.__new__  s    wsJKKUK>"&D DM"DO!%i
&;!<DK*e,9::U?-j9J:!#!!}$(4"  OO%	i'!%i	&:!;D  "&iDrJ   c                     | j                   | S t        fd| j                   D              }t        | j                        }|| j                   k(  r|| j                  k(  r| S | j	                  ||d      S )Nc              3   8   K   | ]  }t        |        y wri   ru   )r   r   rs   rt   s     rH   r   z$_Union._eval_type.<locals>.<genexpr>  s     PQ
1h8P   TrX   )r  r   ru   r   rg   )rl   rs   rt   ev_args	ev_origins    ``  rH   ru   z_Union._eval_type  si    == KP$--PPt'B	dmm#	T__(DK~~gy~==rJ   c                 d    | j                   r$| j                  rt        | j                  |       y y y ri   r   r  ry   rw   s     rH   ry   z_Union._get_type_vars  (    ??t224..6  3?rJ   c                     | j                   t        | 	         S | j                         }t	        |t
              st        |      S |d   j                  |      S )Nr   )r   ra   r   r  r   r   r   
_tree_repr)rl   treerg   s     rH   r   z_Union.__repr__	  sP    ??"7#%% $&:Aw!!$''rJ   c                     g }|dd  D ]P  }t        |t              s|j                  t        |             .|j                  |d   j	                  |             R t
        |          ddj                  |      z  z   S )NrQ   r   [%s]r[   )r   r   r   r`   rO  ra   r   r^   rl   rP  arg_listr   rg   s       rH   rO  z_Union._tree_repr  su    8 	8Cc5)
30A 1 1# 67		8
 w!FTYYx-@$@@@rJ   c                     |dk(  rt        d      t        |t              s|f}| j                  dndt        fd|D              }| t        urt        | |       | j                  || d      S )Nrj   z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.*Parameters to generic types must be types.c              3   6   K   | ]  }t        |        y wri   r   r   r+  r   s     rH   r   z%_Union.__getitem__.<locals>.<genexpr>$       C1;q#.Cr   T)rC  rY   )r]   r   r   r   r   r3  rg   )rl   r)  r   s     @rH   r   z_Union.__getitem__  ss    >??*e,$J??"=C>CC
CC
u4,~~jT~BBrJ   c                     | t         u rt         S t        | ||      }t        |      }t        |      dk(  r|d   S t         f|z   S )NrQ   r   )r   r  r-  r   rl   rx   rm   r  s       rH   r  z_Union._subs_tree)  sI    5=LtUD1	(3	y>QQ<x)##rJ   c                     t        |t              r| j                  |j                  k(  S | t        ur| j	                         |k(  S | |u S ri   )r   r   r@  r   r  r   s     rH   r   z_Union.__eq__2  sG    eV$%%)<)<<<??$--5= rJ   c                     | j                   S ri   r@  r   s    rH   r   z_Union.__hash__:      !!!rJ   c                     t        d      )Nz(Unions cannot be used with isinstance().r   r   s     rH   r   z_Union.__instancecheck__=      BCCrJ   c                     t        d      )Nz(Unions cannot be used with issubclass().r   r   s     rH   r   z_Union.__subclasscheck__@  ra  rJ   NN)rE   r}   rD   r   r   rb   ru   ry   r   rO  r>  r   r  r   r   r   r   r   r   s   @rH   r   r     sc    )V NI 6>7(A C C$!"DDrJ   r   c                   $    e Zd ZdZdZed        Zy)r   zEOptional type.

    Optional[X] is equivalent to Union[X, None].
    rj   c                 B    t        |d      }t        |t        d       f   S )Nz#Optional[t] requires a single type.)r   r   r   )rl   r   s     rH   r   z_Optional.__getitem__O  s"    #DES$t*_%%rJ   N)rE   r}   rD   r   r   r>  r   rj   rJ   rH   r   r   G  s     
 I& &rJ   r   c                     t         }t        | j                  dd       D ];  \  }}t        |t              s|j
                  t        u s*| j                  |dz      }= |S )zHelper for Generic.__new__.

    Returns the class after the last occurrence of Generic or
    Generic[...] in cls.__mro__.
    NrQ   )objectr  __mro__r   r   r   r   )rc   next_in_mror  cs       rH   _next_in_mrorl  X  s[     K#++cr*+ -1a%!''W*<++a!e,K- rJ   c                 h     t         j                  t        j                        r fd}|S  fd}|S )zConstruct a __subclasshook__ callable that incorporates
    the associated __extra__ class in subclass checks performed
    against cls.
    c                    j                   j                  |       }|t        ur|S j                   | j                  v ryj                   j	                         D ]!  }t        |t              rt        | |      s! y t        S NT)	__extra____subclasshook__r   ri  __subclasses__r   r   r   )subclassressclsrc   s      rH   __extrahook__z)_make_subclasshook.<locals>.__extrahook__o  sw    --00:C.(
}} 0 00446  dK0h-	 
 "!rJ   c                 V    j                   rt        | j                         ryt        S ro  )rp  r   r   )rs  rc   s    rH   rv  z)_make_subclasshook.<locals>.__extrahook__}  s     }}Hcmm!D!!rJ   )r   rp  abcABCMeta)rc   rv  s   ` rH   _make_subclasshookrz  f  s1    
 #---	"$ 		" rJ   c                 \    t        |       }d|v r|d   D ]  }|j                  |d        |S )zInternal helper: copy class __dict__ and clean slots class variables.
    (They will be re-created if necessary by normal class machinery.)
    r   N)dictpop)dct	dict_copyslots      rH   _no_slots_copyr    s=     S	Iik* 	&DMM$%	&rJ   c                        e Zd ZdZ	 d fd	Zed        Zej                  d        Zed        Zej                  d        Zd Z	d Z
 fd	Z fd
ZddZd Zd Zed        Z fdZd Z fdZ xZS )r   ac  Metaclass for generic types.

    This is a metaclass for typing.Generic and generic ABCs defined in
    typing module. User defined subclasses of GenericMeta can override
    __new__ and invoke super().__new__. Note that GenericMeta.__new__
    has strict rules on what is allowed in its bases argument:
    * plain Generic is disallowed in bases;
    * Generic[...] should appear in bases at most once;
    * if Generic[...] is present, then it should list all type variables
      that appear in other bases.
    In addition, type of all generic bases is erased, e.g., C[int] is
    stripped to plain C.
    c	           	         ||J t        d |D              sJ |       |J |       |J |       |J |       t        |      }d}	|D ]R  }
|
t        u rt        d      t	        |
t
              s'|
j                  t        u s:|	t        d      |
j                  }	T |	|}	n]t        |      }t        |	      |k  s@t        ddj                  fd|D              ddj                  d	 |	D              d
      |	}|}|%t        |      t        j                  u r
||vr|f|z   }t        d |D              }t        d |D              rt        d |D              }|j                  |||sdn|j                   d       t"        | I  | |||d      }t"        t
        |O  d|s|n|j                          ||_        |rt        d |D              nd|_        t+        |      |_        |||_        d|vr|st1        |j2                  dd      dk(  rt5        |      |_        t	        |t        j                        r#|j6                  |_        |j8                  |_        n$|"|j6                  |_        |j8                  |_        |rt;        |d      r|j<                  |_        |r t?        |jA                               |_"        |S t"        t
        |         |_"        |S )zCreate a new generic class. GenericMeta.__new__ accepts
        keyword arguments that are used for internal bookkeeping, therefore
        an override should pass unused keyword arguments to super().
        Nc              3   <   K   | ]  }t        |t                y wri   r   r   )r   r   s     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s     =!z!W-=   z!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.zSome type variables (r[   c              3   >   K   | ]  }|vst        |        y wri   r   )r   r   gvarsets     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s     "MaAW<L3q6"Ms   	z) are not listed in Generic[c              3   2   K   | ]  }t        |        y wri   r  )r   gs     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s     "9a3q6"9s   r   c              3   X   K   | ]"  }t        |t              r|j                  n| $ y wri   )r   r   r   r   bs     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s"     RqA{!;aggBRs   (*c              3   P   K   | ]  }t        |t              xr |t        u   y wri   )r   r   r   r  s     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s$     N1z![)>aw.>>Ns   $&c              3   2   K   | ]  }|t         us|  y wri   )r   r  s     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s     ?aw.>!?s   )r   rp  r   TrX   r   c              3   H   K   | ]  }|t         u rd n|t        u rdn|  yw).rj   N)_TypingEllipsis_TypingEmpty)r   as     rH   r   z&GenericMeta.__new__.<locals>.<genexpr>  s1      /$% &'/%9c$%$5b  /s    "rq  rE    rv  rD   )#allr   r   r]   r   r   r   r  r&  r^   r   rx  ry  r   r(  updater   ra   rb   __setattr__r  rl  __next_in_mro____orig_bases__r   rq  rz  _abc_registry
_abc_cacher  rD   r   r  r   r@  )rc   rd   re   rf   rx   rm   rC  extra
orig_basesgvarsbasetvarsetinitial_basesrl   r  rg   s                 @rH   rb   zGenericMeta.__new__  s    %%%=u==DuD= ='%'=<%%<>)6)> u%E E 07?#$GHHt[172('NP P //E0 }e*e*')# "M5"MM"95"99;< <
 e!;U@RHu$ERERR NNN?U??EU/546<<I 	JwsD%$Gk4,W9?TV\\	S#
 37  /)-/ /<@ 	  ,D1"/D i/ED)):r:oM$6t$<D!eS[[)!&!4!4D#..DO!'!5!5D$//DOgfn5 & 3 3D9?d4??#45 $K?A 	rJ   c                     t        | j                  t        j                        r| j                  j                  S | j
                  j                  S ri   )r   rp  rx  ry  _abc_negative_cacher   _abc_generic_negative_cacher   s    rH   r  zGenericMeta._abc_negative_cache  s4    dnnckk2>>555zz555rJ   c                     | j                   >t        | j                  t        j                        r|| j                  _        y || _        y y ri   )r   r   rp  rx  ry  r  r  rl   values     rH   r  zGenericMeta._abc_negative_cache  s7    ??"$..#++65:2380	 #rJ   c                     t        | j                  t        j                        r| j                  j                  S | j
                  j                  S ri   )r   rp  rx  ry  _abc_negative_cache_versionr   #_abc_generic_negative_cache_versionr   s    rH   r  z'GenericMeta._abc_negative_cache_version  s4    dnnckk2>>===zz===rJ   c                     | j                   >t        | j                  t        j                        r|| j                  _        y || _        y y ri   )r   r   rp  rx  ry  r  r  r  s     rH   r  z'GenericMeta._abc_negative_cache_version  s7    ??"$..#++6=B:;@8	 #rJ   c                 d    | j                   r$| j                  rt        | j                  |       y y y ri   rL  rw   s     rH   ry   zGenericMeta._get_type_vars  rM  rJ   c           
         | j                   r| j                   j                        nd }| j                  rt        fd| j                  D              nd }|| j                   k(  r|| j                  k(  r| S | j	                  | j
                  | j                  t        | j                        |rt        |      nd ||| j                  | j                        S )Nc              3   8   K   | ]  }t        |        y wri   rG  )r   r  rs   rt   s     rH   r   z)GenericMeta._eval_type.<locals>.<genexpr>"  s      *Q
1h8 *rH  rx   rm   rC  r  r  )r   ru   r  r   rg   rE   	__bases__r  __dict__r   rp  r  )rl   rs   rt   rJ  rI  s    ``  rH   ru   zGenericMeta._eval_type  s     __//'B-1 	 .2]]  *==* *@D 	'Gt}},DK~~dmm"nn,T]];;BJw$7#*%.$(NN)-)<)<  > 	>rJ   c                 v    | j                   t        | 	         S | j                  | j	                               S ri   r   ra   r   rO  r  rl   rg   s    rH   r   zGenericMeta.__repr__/  1    ??"7#%%t011rJ   c                 ,   g }|dd  D ]g  }|dk(  r|j                  d       t        |t              s|j                  t        |             E|j                  |d   j	                  |             i t
        |          ddj                  |      z  z   S )NrQ   rj   r\   r   rR  r[   )r   r   r   r`   rO  ra   r   r^   rS  s       rH   rO  zGenericMeta._tree_repr4  s    8 	8Cby%U+
30A 1 1# 67	8 w!FTYYx-@$@@@rJ   c                 j    | j                   | S t        | ||      }| j                  ft        |      z   S ri   )r   r  r   r   r[  s       rH   r  zGenericMeta._subs_tree?  s5    ??"KtUD1	

}uY///rJ   c                     t        |t              st        S | j                  |j                  | |u S | j                  |j                  k(  S ri   )r   r   r   r   r@  r   s     rH   r   zGenericMeta.__eq__E  sH    %-!!??"e&6&6&>5= !!U%8%888rJ   c                     | j                   S ri   r^  r   s    rH   r   zGenericMeta.__hash__L  r_  rJ   c           
         t        |t              s|f}|s)| j                  t        urt	        dt        |       z        dt        fd|D              }| t        u rMt        d |D              st	        d      t        t        |            t        |      k7  rt	        d      |}|}nq| t        t        fv rt        |      }|}nU| t        u r|}|}nH| j                  t        t        fv rt	        dt        |       z        t        | |       t        |      }|}| j                  | fnd}| j!                  | j"                  || j$                  z   t'        | j(                        ||| | j*                  | j,                  	      S )
Nz)Parameter list to %s[...] cannot be emptyrV  c              3   6   K   | ]  }t        |        y wri   r   rX  s     rH   r   z*GenericMeta.__getitem__.<locals>.<genexpr>W  s     ;q{1c*;r   c              3   <   K   | ]  }t        |t                y wri   r  )r   r+  s     rH   r   z*GenericMeta.__getitem__.<locals>.<genexpr>Z  s     >!z!W->r  z5Parameters to Generic[...] must all be type variablesz-Parameters to Generic[...] must all be uniquez'Cannot subscript already-subscripted %srj   r  )r   r   r   r   r]   rI   r   r  r   r&  r   r   r   r   r   r3  rg   rE   r  r  r  rp  r  )rl   r*  rx   rm   prependr   s        @rH   r   zGenericMeta.__getitem__O  s   &%(YF$**E1;ioMO O:;F;;7?>v>>KM M3v;3v;.CE EEDeX&&v&EDYED__) 44E J' ( ( 4(v&ED!__44'"~~dmm%6,T]];$)#'%)$(NN)-)<)<  > 	>rJ   c                     | j                   0t        j                  d      j                  d   dvrt	        d      y| t
        u rt	        d| z        t        |   |      S )NrQ   rE   )rx  r9  zCParameterized generics cannot be used with class or instance checksFz5Class %r cannot be used with class or instance checks)r   rB   	_getframe	f_globalsr]   r   ra   r   )rl   rc   rg   s     rH   r   zGenericMeta.__subclasscheck__}  sp    ??&}}Q))*5=QQ !5 6 67? 1378 9 9w(--rJ   c                 .    t        |j                  |       S ri   )r   rg   r  s     rH   r   zGenericMeta.__instancecheck__  s     (,,d33rJ   c                     |j                  d      r|j                  d      s|j                  d      s| j                  t        t        |   ||       y t        t        | j                    ||       y )N___abc_)rR   endswithr   ra   r   r  )rl   attrr  rg   s      rH   r  zGenericMeta.__setattr__  sX     OOD!dmmD&9OOG$JJ+t0u=+tzz6tUCrJ   )NNNNNrc  )rE   r}   rD   r   rb   propertyr  setterr  ry   ru   r   rO  r  r   r   r>  r   r   r   r  r   r   s   @rH   r   r     s     LP[B 6 6
 9  9 > >
 !''A (A7> 2
	A09" +> +>Z	.4	D 	DrJ   r   c                    |j                   _| j                  t        j                  u r-|j                  t        j                  ur| j                  |      S  | j                  |g|i |S |j                  }| j                  t        j                  u r.|j                  t        j                  ur| j                  |      }n | j                  |g|i |}	 ||_         |j                  |i | |S # t        $ r Y w xY wri   )r   rb   rh  ro   r   __orig_class__AttributeError)base_clsrc   rm   rn   rC  r   s         rH   _generic_newr    s     ~~.FOO3##C((#8##C7$7$77.FOO3""6*C"(""69D9D9C	!$C 	d#d#
  		s   C4 4	D ?D c                       e Zd ZdZdZd Zy)r   aC  Abstract base class for generic types.

    A generic type is typically declared by inheriting from
    this class parameterized with one or more type variables.
    For example, a generic mapping type might be defined as::

      class Mapping(Generic[KT, VT]):
          def __getitem__(self, key: KT) -> VT:
              ...
          # Etc.

    This class can then be used as follows::

      def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
          try:
              return mapping[key]
          except KeyError:
              return default
    rj   c                 p    | j                   t        u rt        d      t        | j                  | g|i |S )NzHType Generic cannot be instantiated; it can be used only as a base class)r   r   r]   r  r  rc   rm   rn   s      rH   rb   zGeneric.__new__  s@    99 B C CC//DtDtDDrJ   NrE   r}   rD   r   r   rb   rj   rJ   rH   r   r     s    ( IErJ   r   )r   c                       e Zd ZdZy)r  zInternal placeholder for () or []. Used by TupleMeta and CallableMeta
    to allow empty list/tuple in specific places, without allowing them
    to sneak in where prohibited.
    NrE   r}   rD   r   rj   rJ   rH   r  r    s    rJ   r  c                       e Zd ZdZy)r  z(Internal placeholder for ... (ellipsis).Nr  rj   rJ   rH   r  r    s    2rJ   r  c                   8     e Zd ZdZe fd       Zd Zd Z xZS )	TupleMetazMetaclass for Tuple (internal).c                 x   | j                   | j                  t        urt        |   |      S |dk(  rt        |   t
        f      S t        |t              s|f}t        |      dk(  r-|d   du r&dt        |d         }t        |   |t        f      S dt        fd|D              }t        |   |      S )	Nrj   r   rQ   .z Tuple[t, ...]: t must be a type.r   z*Tuple[t0, t1, ...]: each t must be a type.c              3   6   K   | ]  }t        |        y wri   r   rX  s     rH   r   z(TupleMeta.__getitem__.<locals>.<genexpr>  rY  r   )r   r   r   ra   r   r  r   r   r   r   r  )rl   r)  r+  r   rg   s      @rH   r   zTupleMeta.__getitem__  s    ??&$**E*A 7&z227&77*e,$Jz?aJqMS$84CJqM3/A7&?';<<:C
CC
w":..rJ   c                 P    | j                   t        |t              S t        d      )Nz5Parameterized Tuple cannot be used with isinstance().)r  r   r   r]   r   s     rH   r   zTupleMeta.__instancecheck__  +    == c5)) - . 	.rJ   c                 P    | j                   t        |t              S t        d      )Nz5Parameterized Tuple cannot be used with issubclass().)r  r   r   r]   r   s     rH   r   zTupleMeta.__subclasscheck__  r  rJ   )	rE   r}   rD   r   r>  r   r   r   r   r   s   @rH   r  r    s"    )/ /"..rJ   r  c                       e Zd ZdZdZd Zy)r   a@  Tuple type; Tuple[X, Y] is the cross-product type of X and Y.

    Example: Tuple[T1, T2] is a tuple of two elements corresponding
    to type variables T1 and T2.  Tuple[int, float, str] is a tuple
    of an int, a float and a string.

    To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].
    rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz6Type Tuple cannot be instantiated; use tuple() instead)r   r   r]   r  r   r  s      rH   rb   zTuple.__new__  s7    99 2 3 3E36666rJ   Nr  rj   rJ   rH   r   r     s     I7rJ   r   )r  r   c                   J     e Zd ZdZ fdZ fdZ fdZe fd       Z xZ	S )CallableMetaz"Metaclass for Callable (internal).c                 v    | j                   t        | 	         S | j                  | j	                               S ri   r  r  s    rH   r   zCallableMeta.__repr__  r  rJ   c                    | j                   t        urt        |   |      S g }|dd  D ]P  }t	        |t
              s|j                  t        |             .|j                  |d   j                  |             R |d   dk(  rt        |d         d|d   z  z   S t        |d         ddj                  |d d       d|d   d	z   S )
NrQ   r   r   z	[..., %s]z[[r[   rg  z], r   )
r   r   ra   rO  r   r   r   r`   r   r^   rS  s       rH   rO  zCallableMeta._tree_repr  s    ::X%7%d++ 8 	8Cc5)
30A 1 1# 67		8
 A;%Q=;!#<<<T!W $		(3B- 8(2,GH 	IrJ   c                 V   | j                   | j                  t        urt        |   |      S t        |t              rt        |      dk7  rt        d      |\  }}|t        u r	t        |f}n,t        |t              st        d|fz        t        |      |f}| j                  |      S )zxA thin wrapper around __getitem_inner__ to provide the latter
        with hashable arguments to improve speed.
        r   z6Callable must be used as Callable[[arg, ...], result].z8Callable[args, result]: args must be a list. Got %.100r.)r   r   r   ra   r   r   r   r   r]   Ellipsislist__getitem_inner__)rl   r)  rm   resultrg   s       rH   r   zCallableMeta.__getitem__.  s    
 ??&$**H*D7&z22*e,J10D < = =!f8"F+JdD) !/26!9 : :+v.J%%j11rJ   c                     |\  }}dt        |      }|t        u rt        |   t        |f      S dt        fd|D              }||fz   }t        |   |      S )Nz.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c              3   6   K   | ]  }t        |        y wri   r   )r   r   r   s     rH   r   z1CallableMeta.__getitem_inner__.<locals>.<genexpr>J  s     ;s[c*;r   )r   r  ra   r   r  r   )rl   r)  rm   r  r   rg   s       @rH   r  zCallableMeta.__getitem_inner__B  sk    !f>VS)87&'@AAF;d;;VI%
w":..rJ   )
rE   r}   rD   r   r   rO  r   r>  r  r   r   s   @rH   r  r    s*    ,2
I 2( 	/ 	/rJ   r  c                       e Zd ZdZdZd Zy)r   a  Callable type; Callable[[int], str] is a function of (int) -> str.

    The subscription syntax must always be used with exactly two
    values: the argument list and the return type.  The argument list
    must be a list of types or ellipsis; the return type must be a single type.

    There is no syntax to indicate optional or keyword arguments,
    such function types are rarely used as callback types.
    rj   c                 p    | j                   t        u rt        d      t        | j                  | g|i |S )NzIType Callable cannot be instantiated; use a non-abstract subclass instead)r   r   r]   r  r  r  s      rH   rb   zCallable.__new__\  s@    99  B C CC//DtDtDDrJ   Nr  rj   rJ   rH   r   r   O  s     IErJ   r   c                   F     e Zd ZdZdZd	dZd Zd Z fdZd Z	d Z
 xZS )
r   a3  Special type construct to mark class variables.

    An annotation wrapped in ClassVar indicates that a given
    attribute is intended to be used as a class variable and
    should not be set on instances of that class. Usage::

      class Starship:
          stats: ClassVar[Dict[str, int]] = {} # class variable
          damage: int = 10                     # instance variable

    ClassVar accepts only types and cannot be further subscribed.

    Note that ClassVar is not a class itself, and should not
    be used with isinstance() or issubclass().
    __type__c                     || _         y ri   r  )rl   tprn   s      rH   ro   z_ClassVar.__init__v  s	    rJ   c           
          t        |       }| j                  0 |t        |dj                  |j                  dd              d      S t        dj                  |j                  dd              )Nz{} accepts only single type.rQ   TrX   z {} cannot be further subscripted)r   r  r   formatrE   r]   )rl   itemrc   s      rH   r   z_ClassVar.__getitem__y  so    4j== {45<<S\\!"=MNP!# # :QR 013 	3rJ   c                 x    t        | j                  ||      }|| j                  k(  r| S  t        |       |d      S )NTrX   )ru   r  r   )rl   rs   rt   new_tps       rH   ru   z_ClassVar._eval_type  s8    DMM8W=T]]"KtDz&--rJ   c                     t         |          }| j                  '|dj                  t	        | j                              z  }|S )Nz[{}])ra   r   r  r  r`   )rl   rrg   s     rH   r   z_ClassVar.__repr__  s;    G==$z$--899ArJ   c                 V    t        t        |       j                  | j                  f      S ri   )r   r   rE   r  r   s    rH   r   z_ClassVar.__hash__  s     T$Z(($--899rJ   c                     t        |t              st        S | j                  | j                  |j                  k(  S | |u S ri   )r   r   r   r  r   s     rH   r   z_ClassVar.__eq__  s9    %+!!==$==ENN22u}rJ   ri   )rE   r}   rD   r   r   ro   r   ru   r   r   r   r   r   s   @rH   r   r   c  s-      I3.:rJ   r   c                     |S )zCast a value to a type.

    This returns the value unchanged.  To the type checker this
    signals that the return value has the designated type, but at
    runtime we intentionally don't check anything (we want this
    to be as fast as possible).
    rj   )typvals     rH   r8   r8     s	     JrJ   c                 2   	 | j                   }|j                  }|j                  }|d| }| j                  xs d}| j
                  }|rt        |      ni }|t        |      z
  }t        ||d |      D ]  \  }}	||vsJ |	||<    |S # t        $ r i cY S w xY w)z:Internal helper to extract the default arguments, by name.Nrj   )	__code__r  co_argcountco_varnames__defaults____kwdefaults__r|  r   zip)
r7  r   	pos_count	arg_namesdefaults
kwdefaultsrt  
pos_offsetrd   r  s
             rH   _get_defaultsr	    s    }}   I  I*9%I  &BH$$J($z
bCS]*J9Z[18< e3D	 J  	s   B BBc                    t        | dd      ri S t        | t              ri }t        | j                        D ]  }|(t
        j                  |j                     j                  }n|}|j                  j                  di       }|j                         D ]?  \  }}|t        d      }t        |t              rt        |      }t        |||      }|||<   A  |S |9t        | t        j                        r| j                  }nt        | di       }||}n||}t        | dd      }|,t        | t               ri S t#        dj%                  |             t'        |       }	t)        |      }|j                         D ]Q  \  }}|t        d      }t        |t              rt        |      }t        |||      }||	v r|	|   	t*        |   }|||<   S |S )a  Return type hints for an object.

    This is often the same as obj.__annotations__, but it handles
    forward references encoded as string literals, and if necessary
    adds Optional[t] if a default value equal to None is set.

    The argument may be a module, class, method, or function. The annotations
    are returned as a dictionary. For classes, annotations include also
    inherited members.

    TypeError is raised if the argument is not of a type that can contain
    annotations, and an empty dictionary is returned if no annotations are
    present.

    BEWARE -- the behavior of globalns and localns is counterintuitive
    (unless you are familiar with how eval() and exec() work).  The
    search order is locals first, then globals.

    - If no dict arguments are passed, an attempt is made to use the
      globals from obj (or the respective module's globals for classes),
      and these are also used as the locals.  If the object does not appear
      to have globals, an empty dictionary is used.

    - If one dict argument is passed, it is used for both globals and
      locals.

    - If two dict arguments are passed, they specify globals and
      locals, respectively.
    __no_type_check__N__annotations____globals__z1{!r} is not a module, class, method, or function.)r   r   r   reversedri  rB   modulesr}   r  getitemsr   rM   ru   r   
ModuleType_allowed_typesr]   r  r	  r|  r   )
r   rs   rt   hintsr  base_globalsannrd   r  r  s
             rH   r9   r9     s   > s'.	#tS[[) 	$D"{{4??;DD'--##$5r:C"yy{ $e= JEeS)'.E"5,@#d$	$ c5++,||HsM26H?G	C*D1E}c>*I ++16#;8 8S!HKE{{} e=JEeS!&E5(G48 6UOEd LrJ   c                    t        | t              r| j                  j                         }| j                  j	                         D ])  \  }}|| j
                  | fz   v s|j                  |       + |j                         D ]?  }t        |t        j                        rd|_
        t        |t              s5t        |       A 	 d| _
        | S # t        $ r Y | S w xY w)aI  Decorator to indicate that annotations are not type hints.

    The argument must be a class or function; if it is a class, it
    applies recursively to all methods and classes defined in that class
    (but not to methods defined in its superclasses or subclasses).

    This mutates the function(s) or class(es) in place.
    T)r   r   r  copyr  r  r}  valuesr   r   r  r;   r]   )r   	arg_attrsr  r  r   s        rH   r;   r;     s     #tLL%%'	++- 	$ID#cmmsf,,d#	$ ##% 	#C#u112(,%#t$c"		#
 $ J  Js   C 	CCc                 B     t        j                          fd       }|S )zDecorator to give another decorator the @no_type_check effect.

    This wraps the decorator with something that wraps the decorated
    function in @no_type_check.
    c                  .     | i |}t        |      }|S ri   )r;   )rm   rn   r7  	decorators      rH   wrapped_decoratorz2no_type_check_decorator.<locals>.wrapped_decorator3  s!    $'$'T"rJ   )r9  r=  )r  r  s   ` rH   r<   r<   ,  s(     __Y  
 rJ   c                      t        d      )z*Helper for @overload to raise when called.zYou should not call an overloaded function. A series of @overload-decorated functions outside a stub module should always be followed by an implementation that is not @overload-ed.)NotImplementedError)rm   rn   s     rH   _overload_dummyr!  <  s    
	9: :rJ   c                     t         S )a
  Decorator for overloaded functions/methods.

    In a stub file, place two or more stub definitions for the same
    function in a row, each decorated with @overload.  For example:

      @overload
      def utf8(value: None) -> None: ...
      @overload
      def utf8(value: bytes) -> bytes: ...
      @overload
      def utf8(value: str) -> bytes: ...

    In a non-stub file (i.e. a regular .py file), do the same but
    follow it with an implementation.  The implementation should *not*
    be decorated with @overload.  For example:

      @overload
      def utf8(value: None) -> None: ...
      @overload
      def utf8(value: bytes) -> bytes: ...
      @overload
      def utf8(value: str) -> bytes: ...
      def utf8(value):
          # implementation goes here
    )r!  )r7  s    rH   r>   r>   E  s
    4 rJ   c                   .     e Zd ZdZ fdZd Zd Z xZS )_ProtocolMetaz~Internal metaclass for _Protocol.

    This exists so _Protocol classes can be generic without deriving
    from Generic.
    c                 \    t         | j                  vrt        |   |      S t	        d      )Nz+Protocols cannot be used with isinstance().)r   r  ra   r   r]   )rl   r   rg   s     rH   r   z_ProtocolMeta.__instancecheck__i  s+    DNN*7,S11EFFrJ   c                     | j                   st        S | t        u ry| j                         }|D ]"  t	        fd|j
                  D              r" y y)NTc              3   :   K   | ]  }|j                   v   y wri   r  )r   dr  s     rH   r   z2_ProtocolMeta.__subclasscheck__.<locals>.<genexpr>{  s     ?atqzz)?s   F)r   r   r   _get_protocol_attrsr(  ri  )rl   rc   attrsr  s      @rH   r   z_ProtocolMeta.__subclasscheck__n  sV      !!9 ((* 	D?3;;??	 rJ   c                 X   g }| j                   D ]1  }t        |dd      s|j                  dk7  s!|j                  |       3 t	               }|D ]  }|j
                  j                         D ]  }| j                   D ]%  }||us||j
                  v st        |dd      r% 6 |j                  d      rI|dk7  sO|dk7  sU|dk7  s[|dk7  sa|dk7  sg|d	k7  sm|d
k7  ss|dk7  sy|dk7  s|dk7  s|dk7  s|dk7  s|dk7  s|dk7  s|dk7  s|dk7  s|j                  |         |S )Nr   Fr   r  __abstractmethods__r  r   r   r  r  r   r*  r  r  r   r  rp  r@  r}   )	ri  r   rE   r   r&  r  keysrR   add)rl   protocol_basesrk  r+  r  r  s         rH   r*  z!_ProtocolMeta._get_protocol_attrs  sL    	)Aq.%0QZZ;5N%%a(	)
 " 	(D**, ( (A$!***< '>5 A(
 !OOG4 $99 $55 M1 N2 GO J. J. K/ $99 $55 $44 L0 $44 K/ O3 L0		$1(	(6 rJ   )rE   r}   rD   r   r   r   r*  r   r   s   @rH   r$  r$  b  s    G
"$rJ   r$  c                       e Zd ZdZdZdZy)r   zInternal base class for protocol classes.

    This implements a simple-minded structural issubclass check
    (similar but more general than the one-offs in collections.abc
    such as Hashable).
    rj   TN)rE   r}   rD   r   r   r   rj   rJ   rH   r   r     s     ILrJ   r   	Awaitablec                       e Zd ZdZy)r2  rj   NrE   r}   rD   r   rj   rJ   rH   r2  r2        	rJ   )r  	Coroutinec                       e Zd ZdZy)r6  rj   Nr4  rj   rJ   rH   r6  r6        	rJ   AsyncIterablec                       e Zd ZdZy)r9  rj   Nr4  rj   rJ   rH   r9  r9    r5  rJ   c                       e Zd ZdZy)AsyncIteratorrj   Nr4  rj   rJ   rH   r<  r<    r8  rJ   r<  c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r         IrJ   r   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r     r>  rJ   r   c                   &    e Zd ZdZedefd       Zy)r,   rj   returnc                      y ri   rj   r   s    rH   __int__zSupportsInt.__int__      rJ   N)rE   r}   rD   r   r   intrC  rj   rJ   rH   r,   r,     s     I  rJ   r,   c                   &    e Zd ZdZedefd       Zy)r*   rj   rA  c                      y ri   rj   r   s    rH   	__float__zSupportsFloat.__float__  rD  rJ   N)rE   r}   rD   r   r   floatrH  rj   rJ   rH   r*   r*          I5  rJ   r*   c                   &    e Zd ZdZedefd       Zy)r)   rj   rA  c                      y ri   rj   r   s    rH   __complex__zSupportsComplex.__complex__  rD  rJ   N)rE   r}   rD   r   r   complexrM  rj   rJ   rH   r)   r)     s     IW  rJ   r)   c                   &    e Zd ZdZedefd       Zy)r(   rj   rA  c                      y ri   rj   r   s    rH   	__bytes__zSupportsBytes.__bytes__  rD  rJ   N)rE   r}   rD   r   r   bytesrQ  rj   rJ   rH   r(   r(     rJ  rJ   r(   c                   &    e Zd ZdZedefd       Zy)r+   rj   rA  c                      y ri   rj   r   s    rH   	__index__zSupportsIndex.__index__   rD  rJ   N)rE   r}   rD   r   r   rE  rU  rj   rJ   rH   r+   r+     s     I3  rJ   r+   c                   &    e Zd ZdZedefd       Zy)r'   rj   rA  c                      y ri   rj   r   s    rH   __abs__zSupportsAbs.__abs__  rD  rJ   N)rE   r}   rD   r   r   r  rX  rj   rJ   rH   r'   r'     s     I  rJ   r'   c                   ,    e Zd ZdZeddedefd       Zy)r-   rj   ndigitsrA  c                      y ri   rj   )rl   rZ  s     rH   	__round__zSupportsRound.__round__  rD  rJ   Nr   )rE   r}   rD   r   r   rE  r  r\  rj   rJ   rH   r-   r-     s'    I T  rJ   r-   r&   c                       e Zd ZdZy)r&   rj   Nr4  rj   rJ   rH   r&   r&     r5  rJ   c                   "    e Zd ZdZedd       Zy)r&   rj   c                      y ri   rj   r   s    rH   __reversed__zReversible.__reversed__  s    rJ   N)rA  zIterator[T_co])rE   r}   rD   r   r   ra  rj   rJ   rH   r&   r&     s    			 
	rJ   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r   $  r>  rJ   r   
Collectionc                       e Zd ZdZy)rc  rj   Nr4  rj   rJ   rH   rc  rc  )  r8  rJ   c                       e Zd ZdZyr   rj   Nr4  rj   rJ   rH   r   r   3  r8  rJ   r   c                       e Zd ZdZyrf  r4  rj   rJ   rH   r   r   7  r8  rJ   c                       e Zd ZdZy)r"   rj   Nr4  rj   rJ   rH   r"   r"   <  r>  rJ   r"   c                       e Zd ZdZyr   rj   Nr4  rj   rJ   rH   r   r   B  r8  rJ   r   c                       e Zd ZdZyrj  r4  rj   rJ   rH   r   r   F  r8  rJ   c                       e Zd ZdZy)r    rj   Nr4  rj   rJ   rH   r    r    K  r>  rJ   r    c                       e Zd ZdZyr#   rj   Nr4  rj   rJ   rH   r#   r#   Q      IrJ   r#   c                       e Zd ZdZyrn  r4  rj   rJ   rH   r#   r#   U  ro  rJ   c                       e Zd ZdZyrn  r4  rj   rJ   rH   r#   r#   Y  r8  rJ   c                       e Zd ZdZy)r!   rj   Nr4  rj   rJ   rH   r!   r!   ^  r>  rJ   r!   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r   b  r>  rJ   r   c                       e Zd ZdZd Zy)r2   rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz4Type List cannot be instantiated; use list() instead)r   r2   r]   r  r  r  s      rH   rb   zList.__new__j  7    99 1 2 2D#5555rJ   NrE   r}   rD   r   rb   rj   rJ   rH   r2   r2   f      I6rJ   r2   c                       e Zd ZdZd Zy)r/   rj   c                     | j                   t        u rt        j                  |i |S t	        t        j                  | g|i |S ri   )r   r/   collectionsdequer  r  s      rH   rb   zDeque.__new__u  sA    99$$d3d33K--sBTBTBBrJ   Nrw  rj   rJ   rH   r/   r/   q  s    ICrJ   r/   c                       e Zd ZdZd Zy)r3   rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz2Type Set cannot be instantiated; use set() instead)r   r3   r]   r  r&  r  s      rH   rb   zSet.__new__  s7    99 0 1 1C4t4t44rJ   Nrw  rj   rJ   rH   r3   r3   {  s    I5rJ   r3   c                       e Zd ZdZd Zy)r4   rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz>Type FrozenSet cannot be instantiated; use frozenset() instead)r   r4   r]   r  rB  r  s      rH   rb   zFrozenSet.__new__  s7    99	! 6 7 7Is:T:T::rJ   Nrw  rj   rJ   rH   r4   r4     s    I;rJ   r4   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r     r>  rJ   r   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r     s    IrJ   r   c                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r     s	     IrJ   r   c                       e Zd ZdZy)r%   rj   Nr4  rj   rJ   rH   r%   r%     r>  rJ   r%   AbstractContextManagerc                       e Zd ZdZy)r   rj   Nr4  rj   rJ   rH   r   r     r5  rJ   r   c                   J    e Zd ZdZd Zej                  d        Zed        Z	y)r   rj   c                     | S ri   rj   r   s    rH   	__enter__zContextManager.__enter__  s    KrJ   c                      y ri   rj   )rl   exc_type	exc_value	tracebacks       rH   __exit__zContextManager.__exit__  s    rJ   c                     | t         u r9t        d |j                  D              rt        d |j                  D              ryt        S )Nc              3   8   K   | ]  }d |j                   v   yw)r  Nr(  r   Bs     rH   r   z2ContextManager.__subclasshook__.<locals>.<genexpr>  s     Eaqzz1E   c              3   8   K   | ]  }d |j                   v   yw)r  Nr(  r  s     rH   r   z2ContextManager.__subclasshook__.<locals>.<genexpr>  s     DQ
ajj0Dr  T)r   r(  ri  r   )rc   Cs     rH   rq  zContextManager.__subclasshook__  s9    n$ E199EED!))DD!!rJ   N)
rE   r}   rD   r   r  rx  r   r  classmethodrq  rj   rJ   rH   r   r     s:    		 
			 
	 

	" 

	"rJ   AbstractAsyncContextManagerc                       e Zd ZdZy)AsyncContextManagerrj   Nr4  rj   rJ   rH   r  r    r8  rJ   r  )r      a  
class AsyncContextManager(Generic[T_co]):
    __slots__ = ()

    async def __aenter__(self):
        return self

    @abc.abstractmethod
    async def __aexit__(self, exc_type, exc_value, traceback):
        return None

    @classmethod
    def __subclasshook__(cls, C):
        if cls is AsyncContextManager:
            if sys.version_info[:2] >= (3, 6):
                return _collections_abc._check_methods(C, "__aenter__", "__aexit__")
            if (any("__aenter__" in B.__dict__ for B in C.__mro__) and
                    any("__aexit__" in B.__dict__ for B in C.__mro__)):
                return True
        return NotImplemented

__all__.append('AsyncContextManager')
c                       e Zd ZdZd Zy)r0   rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz4Type Dict cannot be instantiated; use dict() instead)r   r0   r]   r  r|  r  s      rH   rb   zDict.__new__  rv  rJ   Nrw  rj   rJ   rH   r0   r0     rx  rJ   r0   c                       e Zd ZdZd Zy)r1   rj   c                     | j                   t        u rt        j                  |i |S t	        t        j                  | g|i |S ri   )r   r1   r{  defaultdictr  r  s      rH   rb   zDefaultDict.__new__  sA    99#**D9D99K33SH4H4HHrJ   Nrw  rj   rJ   rH   r1   r1     s     IIrJ   r1   c                       e Zd ZdZd Zy)r.   rj   c                     | j                   t        u rt        j                  |i |S t        t        j                  | g|i |S ri   )r   r.   r{  r  r  s      rH   rb   zCounter.__new__  sA    99&&555K//DtDtDDrJ   Nrw  rj   rJ   rH   r.   r.     s    IErJ   r.   ChainMapc                       e Zd ZdZd Zy)r  rj   c                     | j                   t        u rt        j                  |i |S t        t        j                  | g|i |S ri   )r   r  r{  r  r  s      rH   rb   zChainMap.__new__	  sA    yyH$"++T:T:: 4 4cIDIDIIrJ   Nrw  rj   rJ   rH   r  r    s     		JrJ   r6   c                       e Zd ZdZd Zy)r6   rj   c                 d    | j                   t        u rt        d      t        t        | g|i |S )Nz@Type Generator cannot be instantiated; create a subclass instead)r   r6   r]   r  _G_baser  s      rH   rb   zGenerator.__new__  s7    99	! 8 9 9GS848488rJ   Nrw  rj   rJ   rH   r6   r6     s    I9rJ   AsyncGeneratorc                       e Zd ZdZy)r  rj   Nr4  rj   rJ   rH   r  r  $  r8  rJ   CT_co)r   r   c                       e Zd ZdZdZy)r   a  A special construct usable to annotate class objects.

    For example, suppose we have the following classes::

      class User: ...  # Abstract base for User classes
      class BasicUser(User): ...
      class ProUser(User): ...
      class TeamUser(User): ...

    And a function that takes a class argument that's a subclass of
    User and returns an instance of the corresponding class::

      U = TypeVar('U', bound=User)
      def new_user(user_class: Type[U]) -> U:
          user = user_class()
          # (Here we could write the user object to a database)
          return user

      joe = new_user(BasicUser)

    At this point the type checker knows that joe has type BasicUser.
    rj   N)rE   r}   rD   r   r   rj   rJ   rH   r   r   0  s    . IrJ   r   c           	         d}|D cg c]  \  }}|t        ||      f }}}t        j                  | |D cg c]  \  }}|	 c}}      }t        j                  |      x|_        |_        	 t        j                  d      j                  j                  dd      |_
        |S c c}}w c c}}w # t        t        f$ r Y |S w xY w)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typer   rE   __main__)r   r{  
namedtupleOrderedDictr  _field_typesrB   r  r  r  r}   r  r   )rd   r   r   nr   nm_tpls         rH   _make_nmtupler  K  s    
PC278$!QaQ$%8E8##D*?A1*?@F 4?3J3J53QQFV0MM!,66:::zR M 9*? J' Ms   B$B*.4B0 0CC)rb   ro   r   __getnewargs___fields_field_defaultsr  _make_replace_asdict_source)r}   rE   rD   r  c                        e Zd Z fdZ xZS )NamedTupleMetac           
         |j                  dd      rt        | 	  | |||      S t        st	        d      |j                  di       }t        | |j                               }g }i }|D ]]  }||v r||   }	|j                  |	       |	||<   #|s&t	        dj                  |dj                  |j                                            t        j                  |      |j                  _        t        |      |j                  _        ||_        |D ]@  }
|
t"        v rt%        d|
z         |
t&        vs"|
|j(                  vs1t+        ||
||
          B |S )	NrY   Fz<Class syntax for NamedTuple is only supported in Python 3.6+r  zXNon-default namedtuple field {field_name} cannot follow default field(s) {default_names}r[   )
field_namedefault_namesz&Cannot overwrite NamedTuple attribute )r  ra   rb   _PY36r]   r  r  r   r  r^   r.  r{  r  r  r   r  r  _prohibitedr  _specialr  setattr)rc   typenamere   nsr   r  r  defaults_dictr  default_valuekeyrg   s              rH   rb   zNamedTupleMeta.__new__e  se   66'5!7?3%<< . / /("-x7 		XJR ":.,9j) !J!':6:ii@R@R@T6U "( "WX X		X *5)@)@)G&&+Ho#!. 	.Ck!$%MPS%STTH$FNN)BRW-		.
 rJ   )rE   r}   rD   rb   r   r   s   @rH   r  r  c  s     rJ   r  c                   (    e Zd ZdZdZd Zde_        y)r5   a4  Typed version of namedtuple.

    Usage in Python versions >= 3.6::

        class Employee(NamedTuple):
            name: str
            id: int

    This is equivalent to::

        Employee = collections.namedtuple('Employee', ['name', 'id'])

    The resulting class has extra __annotations__ and _field_types
    attributes, giving an ordered dict mapping field names to types.
    __annotations__ should be preferred, while _field_types
    is kept to maintain pre PEP 526 compatibility. (The field names
    are in the _fields attribute, which is part of the namedtuple
    API.) Alternative equivalent keyword syntax is also accepted::

        Employee = NamedTuple('Employee', name=str, id=int)

    In Python versions <= 3.5 use::

        Employee = NamedTuple('Employee', [('name', str), ('id', int)])
    Tc                  <   |rt         st        d      | st        d      | d   | dd  } }| r| d   | dd  } }n=d|v r.|j                  d      }dd l}|j	                  dt
        d       nt        d	      | r	 | \  }nBd|v r<t        |      dk(  r.|j                  d      }dd l}|j	                  dt
        d       nd }||j                         }n|rt        d      t        ||      S # t        $ r' t        d
j                  t        |       dz               w xY w)Nz>Keyword syntax for NamedTuple is only supported in Python 3.6+z*NamedTuple.__new__(): not enough argumentsr   rQ   r  z4Passing 'typename' as keyword argument is deprecatedr   )
stacklevelzGNamedTuple.__new__() missing 1 required positional argument: 'typename'zMNamedTuple.__new__() takes from 2 to 3 positional arguments but {} were givenfieldsz2Passing 'fields' as keyword argument is deprecatedzIEither list of fields or keywords can be provided to NamedTuple, not both)r  r]   r}  warningswarnDeprecationWarningr   r  r   r  r  )rm   kwargsrP   r  r  r  s         rH   rb   zNamedTuple.__new__  s[   % . / /HIIq'484!!Wd12hdH6!zz*-HMMP,  <  3 4 4D
 CK1$4ZZ)FMMN,  < F>\\^F G H HXv..#  D !--3VCIM-BD DDs   8C+ +0Dz*($cls, typename, fields=None, /, **kwargs)N)rE   r}   rD   r   rY   rb   __text_signature__rj   rJ   rH   r5   r5     s    2 E%/N "NGrJ   r5   c                 (    d }| |_         ||_        |S )a%  NewType creates simple unique types with almost zero
    runtime overhead. NewType(name, tp) is considered a subtype of tp
    by static type checkers. At runtime, NewType(name, tp) returns
    a dummy function that simply returns its argument. Usage::

        UserId = NewType('UserId', int)

        def name_by_id(user_id: UserId) -> str:
            ...

        UserId('user')          # Fails type check

        name_by_id(42)          # Fails type check
        name_by_id(UserId(42))  # OK

        num = UserId(5) + 1     # type: int
    c                     | S ri   rj   rF   s    rH   new_typezNewType.<locals>.new_type  s    rJ   )rE   __supertype__)rd   r  r  s      rH   r:   r:     s    & HHOrJ   Fc                      e Zd ZdZdZedefd       Zedefd       Ze	d!d       Z
edefd       Ze	defd	       Ze	d!d
       Ze	defd       Ze	d"dedefd       Ze	defd       Ze	d"dedefd       Ze	d"dedee   fd       Ze	d#dededefd       Ze	defd       Ze	defd       Ze	d$dedefd       Ze	defd       Ze	dedefd       Ze	dee   ddfd       Ze	d%d       Ze	d!d        Zy)&IOa  Generic base class for TextIO and BinaryIO.

    This is an abstract, generic version of the return of open().

    NOTE: This does not distinguish between the different possible
    classes (text vs. binary, read vs. write vs. read/write,
    append-only, unbuffered).  The TextIO and BinaryIO subclasses
    below capture the distinctions between text vs. binary, which is
    pervasive in the interface; however we currently do not offer a
    way to track the other distinctions in the type system.
    rj   rA  c                      y ri   rj   r   s    rH   modezIO.mode  rD  rJ   c                      y ri   rj   r   s    rH   rd   zIO.name	  rD  rJ   Nc                      y ri   rj   r   s    rH   closezIO.close	  rD  rJ   c                      y ri   rj   r   s    rH   closedz	IO.closed		  rD  rJ   c                      y ri   rj   r   s    rH   filenoz	IO.fileno	  rD  rJ   c                      y ri   rj   r   s    rH   flushzIO.flush	  rD  rJ   c                      y ri   rj   r   s    rH   isattyz	IO.isatty	  rD  rJ   r  c                      y ri   rj   )rl   r  s     rH   readzIO.read	  rD  rJ   c                      y ri   rj   r   s    rH   readablezIO.readable	  rD  rJ   limitc                      y ri   rj   )rl   r  s     rH   readlinezIO.readline!	  rD  rJ   hintc                      y ri   rj   )rl   r  s     rH   	readlineszIO.readlines%	  rD  rJ   offsetwhencec                      y ri   rj   )rl   r  r  s      rH   seekzIO.seek)	  rD  rJ   c                      y ri   rj   r   s    rH   seekablezIO.seekable-	  rD  rJ   c                      y ri   rj   r   s    rH   tellzIO.tell1	  rD  rJ   sizec                      y ri   rj   )rl   r  s     rH   truncatezIO.truncate5	  rD  rJ   c                      y ri   rj   r   s    rH   writablezIO.writable9	  rD  rJ   sc                      y ri   rj   rl   r  s     rH   writezIO.write=	  rD  rJ   linesc                      y ri   rj   )rl   r   s     rH   
writelineszIO.writelinesA	  rD  rJ   c                      y ri   rj   r   s    rH   r  zIO.__enter__E	  rD  rJ   c                      y ri   rj   )rl   r   r  r  s       rH   r  zIO.__exit__I	  rD  rJ   )rA  N)rg  r]  ri   )rA  z
IO[AnyStr]) rE   r}   rD   r   r   r   r   r  rd   r   r  r   r  rE  r  r  r  r7   r  r  r  r2   r  r  r  r  r  r  r  r  r  r  rj   rJ   rH   r  r    sL   
 Ic   c                c 6   $   c 6   c 4<   3  C   $   c   S C   $   v #   V       rJ   r  c                   J    e Zd ZdZdZedeeef   de	fd       Z
edd       Zy)	BinaryIOz5Typed version of the return of open() in binary mode.rj   r  rA  c                      y ri   rj   r  s     rH   r  zBinaryIO.writeS	  rD  rJ   c                      y ri   rj   r   s    rH   r  zBinaryIO.__enter__W	  rD  rJ   N)rA  r  )rE   r}   rD   r   r   r   r   rR  	bytearrayrE  r  r  rj   rJ   rH   r  r  N	  sH    ?IuUI-. 3    rJ   r  c                       e Zd ZdZdZedefd       Zedefd       Z	ede
e   fd       Zedefd       Zedefd       Zedd	       Zy
)TextIOz3Typed version of the return of open() in text mode.rj   rA  c                      y ri   rj   r   s    rH   bufferzTextIO.buffera	  rD  rJ   c                      y ri   rj   r   s    rH   encodingzTextIO.encodinge	  rD  rJ   c                      y ri   rj   r   s    rH   errorszTextIO.errorsi	  rD  rJ   c                      y ri   rj   r   s    rH   line_bufferingzTextIO.line_bufferingm	  rD  rJ   c                      y ri   rj   r   s    rH   newlineszTextIO.newlinesq	  rD  rJ   c                      y ri   rj   r   s    rH   r  zTextIO.__enter__u	  rD  rJ   N)rA  r  )rE   r}   rD   r   r   r   r  r  r   r  r   r  r   r  r   r  r   r  rj   rJ   rH   r  r  \	  s    =I   #         #    rJ   r  c                   $    e Zd ZdZg dZeZeZeZy)ioz)Wrapper namespace for IO generic classes.)r  r  r  N)rE   r}   rD   r   __all__r  r  r  rj   rJ   rH   r  r  z	  s    3*G	BFHrJ   r  z.ioPatternr  c                     | j                   S ri   )pattern)r+  s    rH   <lambda>r  	  s
    qyy rJ   Matchc                 .    | j                   j                  S ri   )rer  )ms    rH   r  r  	  s    QTT\\ rJ   c                        e Zd ZdZddgZeZeZy)r   z&Wrapper namespace for re type aliases.r  r  N)rE   r}   rD   r   r  r  r  rj   rJ   rH   r   r   	  s    0'"GGErJ   r   z.rerc  )rx  r   r   r{  
contextlibr9  r   	stdlib_rerB   r   collections.abccollections_abcImportErrorrC   _collections_abcr   r	   r
   r   rh  ro   __str__r   r^   r  rI   rU   rW   rN   rO   rM   rL   ry   r   ru   r   r`   r   r   r   r=   r   r	  r
  r  r  r  r  r  rR  r7   r  r  r-  r3  r;  r>  r   r   r   r   rl  rz  r  ry  r   r   r  r  r  r  r   r   r  r   r   r   r8   r	  r   BuiltinFunctionType
MethodTyper  r  r9   r;   r<   r!  r>   r$  r   r   r  r2  r   r6  r9  r<  r   r   r,   r*   r)   r(   r+   r'   r-   r&   r$   r   rc  r3   r   r"   r   r    r#   r!   rE  r   r  r2   r|  r/   r&  rB  r4   r   r   r   r%   r  r   r  r  execr|  r0   r  r1   r.   r  r6   r  GeneratorTyper  r  r   r  r  r  r  r  r5   r:   r?   r@   r  r  r  r  rE   r  r   r  matchr  rj   rJ   rH   <module>r/     s
   
 0     
 *- BQ6!*TTJb'2 '2T">Jd ">J/{$ /&4;+T 4;n@/D @/F$>&A4 A* F  F, 4 RLk RLn CLT]T]v&v&4(:T2 
5#	&6B&7RS 	$ODT ODd 	T&  & 4 <JD*ckk JD\ 0E E< 3 3. .D7E) 7&6/; 6/rE_-- E(3  3l 4 ( $$e&?&?""E$4$4'):<PR
Od4 ::AK AH
- 
  ## ?K(GDM)B)B  NN; ?K(IdOWT8T-A%B)33 NN; ?O,_-J-J d+-;; NN?#NN?#wt}O$<$< x~_%=%= ) I i I I )D/ IdO  ?L)Xd^?+E+E Yt_  	_%>%>  ?L)UHTNIdO*55 NN< 
 ?L)j&+//eXd^Yt_+//
Q'A'A 
 ?L)*R.'"e)"4'//%"y}gb%i6H'//
WRV_O,J,J  ?L)-	z$'D)9,55		uj.	$,55	5(4.)D/(11
hqk)H)H #o&@&@ 64#4 6CKq19J9J C5#z!}C 5;	;t,I ;%$/J/J {2B$--
E"e),-E"e),-E	"%//U#?+E+E  :/0j.O.O " "0 :45gdm$.$J$J NN()bqV# 
 264B't 6I+))>"b&+A#//IEk!!43<{7J7J E ;
#NN:J;''B)?$--J ?K(''G !!G9h(< =9 ?,-t,gdHn.E.== NN#$ 	4t475> 6 	!&: IT DCN> CNL8  ] ]@r%y RW <  BKK  Y->Y->->r-B(C(*7FDR)@$A)	+  BKK WL  *)*  * 1VX--.>*s$   e 
e& 	e#"e#&A f*)f*