o ?Ogi@s ddlmZmZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl m Z m Z mZmZgdZdddddZdddd d Zd d ZddZdddZddZddZddZddZddZgZdddddZefdd ZGd!d"d"ZGd#d$d$Z Gd%d&d&ed d'Z!Gd(d)d)e!d d'Z"e!d*d+Z#e!d,d-Z$e!d.d/Z%e!d0d1Z&e!d2d3Z'e!d4d5Z(e"ed dd6d7Z)e!d8d9Z*e!d:d;Z+e!dd?d?ed d'Z-Gd@dAdAZ.GdBdCdCee e.d d'Z/GdDdEdEee d d'Z0GdFdGdGee d d'Z1GdHdIdIee e.d d'Z2dJdKZ3GdLdMdMed d'Z4GdNdOdOe4d d'Z5GdPdQdQe4d d'Z6GdRdSdSe5d d'Z7GdTdUdUe6d d'Z8GdVdWdWe6d d'Z9GdXdYdYe5d d'Z:dZd[Z;Gd\d]d]e5d d'ZGdbdcdcZ?GdddedeZ@gdfZAgdgZBeAeBdhgZCdidjZDdkdlZEdmdnZFddqdrZGddtduZHgdvdwdxgdyZIGdzd{d{eZJGd|d}d}e>eJd~ZKGddde5d d'ZLGdddZMddZNddZOddZPe jQe jRe jSe jTe e efZUdddZVddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^ddZ_e/dZ`e/dZae/dZbe/dd dZce/dd dZde/dd dZee/dd dZfe/dd egdZhe/deiejZke6ZlelejjmdZmelejjndoZnelejjodsZoelejjpdoZpelejjqdoZqelejjrdoZrelejjsdoZselejjtdoZtelejjudZuelejjvdoZvelejjwdoZwe8ejjxdZxdex_yelejjzdoddZ{elejj|doZ|elejj}dZ}elejj~dZ~elejjdoZelejjdoZelejjdZe9eddddZde_yeledodddZelejdoddZeledodddZzeledodddZelejjdoZelejjdoZelejjdZelejjdoZelejdoddZelejdoddZeleddddZelejdddZelejdZelejdoZelejdZelejjdsZelejjdZelegdodddZde_yeNGdddeKZeNGdddeKZeNGdddeKZeNGdd„deKZeNGddĄdeKZeNGddƄdeKecZeNGddȄdeKecZddd˄ZehḍZehdͣZGddτdegZdddфZegeddiZddӄZee_GddՄdegZdd d֜dd؄ZegeddiZddڄe_Gdd܄d܃ZejZdZGddބde>ekZGdddeeiZGdddeejZGdddZede_ee jej<ele jdoZele jdoZGdddZede_ee jej<dS))abstractmethodABCMetaN)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorType GenericAlias)T AnnotatedAnyCallableClassVar ConcatenateFinal ForwardRefGenericLiteralOptional ParamSpecProtocolTupleTypeTypeVarUnion AbstractSet ByteString ContainerContextManagerHashable ItemsViewIterableIteratorKeysViewMapping MappingViewMutableMappingMutableSequence MutableSetSequenceSized ValuesView Awaitable AsyncIterator AsyncIterable Coroutine CollectionAsyncGeneratorAsyncContextManager Reversible SupportsAbs SupportsBytesSupportsComplex SupportsFloat SupportsIndex SupportsInt SupportsRoundChainMapCounterDequeDict DefaultDictList OrderedDictSet FrozenSet NamedTuple TypedDict GeneratorBinaryIOIOMatchPatternTextIOAnyStrcastfinalget_args get_originget_type_hints is_typeddictNewType no_type_checkno_type_check_decoratorNoReturnoverload ParamSpecArgsParamSpecKwargsruntime_checkableText TYPE_CHECKING TypeAlias TypeGuardFallow_special_formscCs. |dur tdSt|trt|||dS|S)N)moduleis_class)type isinstancestrr)argr^r]rd-/opt/alt/python310/lib64/python3.10/typing.py _type_converts  rfTc Cs ttf}|s|tf7}|r|tf7}t|||d}t|tr+|j|vr+t|d|t t tt fvr5|St|t s@|ttfvrHtd|dt|t tttjtttfrW|St|sft|d|dd|S)N)r^r]z is not valid as type argumentzPlain z Got z.100.)rrr r rfra _GenericAlias __origin__ TypeErrorr rSrZ _SpecialFormr`rrtypes UnionTyperrUrVcallable)rcmsg is_argumentr^r]Zinvalid_generic_formsrdrdre _type_checks*     rqcCs|dup t|ttttfS)N.)ratuplelistr_ConcatenateGenericAlias)rcrdrdre_is_param_exprs  rucCsh t|tjr t|St|tr!|jdkr|jS|jd|jS|dur'dSt|tjr0|jSt|S)Nbuiltinsrg.z...) rarlrreprr` __module__ __qualname__ FunctionType__name__)objrdrdre _type_reprs    r}csl |durt}g|D]&}t||r|vr|t|tttjfr1fdd|jDq t S)Ncsg|]}|vr|qSrdrd.0ttvarsrdre z&_collect_type_vars..) rraappendrhrrlrmextend__parameters__rr)Ztypes_ typevar_typesrrdrre_collect_type_varss rc CsT |s t|dt|}||kr(td||krdndd|d|d|dS)Nz is not a generic classzToo manyfewz arguments for z ; actual z , expected )rjlen)cls parametersZelenZalenrdrdre_check_genericsrcCs t|jdkr|rt|ds|fSt||t|jg}t||jD]\}}t|tr6t|tr6t|}| |q$t|SNr) rrrurziprarrsrrr)rparamsZ_paramspZtvarrdrdre_prepare_paramspec_paramss  rcCsJt|}t|t|kr#g}|D]}||vr ||||q|}|SN)setrrremove)rZ all_paramsZ new_paramsrrdrdre _deduplicates  rcCsz g}|D]1}t|ttjfr||jqt|tr1t|dkr1|dtur1||ddq| |qtt |S)Nrr) ra_UnionGenericAliasrlrmr__args__rrrrrrrrrrdrdre_remove_dups_flatten s"  rcCs: g}|D]}t|tr||jq||qt|Sr)ra_LiteralGenericAliasrrrrrrrdrdre_flatten_literal_paramss  rtypedcs" fdd}|dur||S|S)Ncs8tjdtjtfdd}|S)Nrcs2z|i|WStyYnw|i|Srrjargskwdscachedfuncrdreinner2s  z+_tp_cache..decorator..inner) functools lru_cache _cleanupsr cache_clearwraps)rrrrre decorator.s  z_tp_cache..decoratorrd)rrrrdrre _tp_cache*s   rcs t|tr |St|tttjfrHtfdd|jD}||jkr+|St|tr6t|j |St|tjrCt t j |S||S|S)Nc3s|] }t|VqdSr) _eval_typeraglobalnslocalnsrecursive_guardrdre Iz_eval_type..)rar _evaluaterhrrlrmrrrrirreduceoperatoror_ copy_with)rrrrZev_argsrdrrer@s      rc@seZdZ dZddZdS)_Final) __weakref__cOsd|vrtddS)N_rootz&Cannot subclass special typing classesrselfrrrdrdre__init_subclass__Zsz_Final.__init_subclass__N)r{rxry __slots__rrdrdrdrerUs rc@s"eZdZ dZddZddZdS) _ImmutablerdcC|Srrdrrdrdre__copy__bz_Immutable.__copy__cCrrrd)rZmemordrdre __deepcopy__erz_Immutable.__deepcopy__N)r{rxryrrrrdrdrdrer^s  rc@sleZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZdS)rk)_name__doc___getitemcCs||_|j|_|j|_dSr)rr{rr)rgetitemrdrdre__init__ns z_SpecialForm.__init__cCs|dvr|jSt|)N>r{ry)rAttributeError)ritemrdrdre __getattr__ssz_SpecialForm.__getattr__cCtd|)NCannot subclass r)rbasesrdrdre__mro_entries__yz_SpecialForm.__mro_entries__cC d|jSNtyping.rrrdrdre__repr__| z_SpecialForm.__repr__cC|jSrrrrdrdre __reduce__z_SpecialForm.__reduce__cOr)NzCannot instantiate rrrdrdre__call__rz_SpecialForm.__call__cC t||fSrrrotherrdrdre__or__ z_SpecialForm.__or__cC t||fSrrrrdrdre__ror__rz_SpecialForm.__ror__cCt|d)Nz! cannot be used with isinstance()rrr|rdrdre__instancecheck__rz_SpecialForm.__instancecheck__cCr)Nz! cannot be used with issubclass()rrrrdrdre__subclasscheck__rz_SpecialForm.__subclasscheck__cCs |||Sr)rrrrdrdre __getitem__s z_SpecialForm.__getitem__N)r{rxryrrrrrrrrrrrrrrdrdrdrerkksrk)rc@eZdZddZdS)_LiteralSpecialFormcCs"t|ts|f}|j|g|RSr)rarrrrrdrdrers z_LiteralSpecialForm.__getitem__N)r{rxryrrdrdrdrers rcC t|dNz is not subscriptablerrrdrdrer  r cCrrrrrdrdrerSs rScC t||d}t||fSNz accepts only single type.rqrhrrrrdrdrer s r cCrrrrrdrdrer s r cs |dkr tdt|ts|f}dtfdd|D}t|}t|dkr,|dSt|dkr?td|vr?t||d d St||S) Nrdz Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3|]}t|VqdSrrqrrrordrerzUnion..rrrname)rjrarrrrr`rrrdrrers   rcCs" t||d}t|tdfS)Nz requires a single type.)rqrr`)rrrcrdrdrer srcGsJ t|}ztddttt|D}Wn tyYnwt||S)Ncss|]\}}|VqdSrrd)rr_rdrdrer0zLiteral..)rrrrrs_value_and_type_iterrjrrrdrdrers"  rcCrrrrrdrdrerZ7rrZcsx |dkr tdt|ts|f}t|dtstddgfdd|ddD|dR}t||ttfdd S) Nrdz&Cannot take a Concatenate of no types.AThe last parameter to Concatenate should be a ParamSpec variable.z/Concatenate[arg, ...]: each arg must be a type.c3rrrrrrdrerZrzConcatenate..T_typevar_types_paramspec_tvars)rjrarrrrtrrrdrrer Fs  (r cCrrrrrdrdrer[`s* r[c@sBeZdZ dZdddddZdd Zd d Zd d ZddZdS)r)__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument____forward_is_class____forward_module__TNF)r_cCstt|ts td|zt|dd}Wnty"td|w||_||_d|_d|_||_ ||_ ||_ dS)Nz*Forward reference must be a string -- got zevalz/Forward reference must be an expression -- got F) rarbrjcompile SyntaxErrorr r r rrrr)rrcrpr^r_coderdrdrers   zForwardRef.__init__cCs|j|vr|S|jr||urW|dur|duri}}n |dur"|}n|dur(|}|jdur9ttj|jdd|}tt|j ||d|j |j d}t |||||jhB|_ d|_|j S)N__dict__z*Forward references must evaluate to types.)rpr]T)r r rgetattrsysmodulesgetrqrr rrrr)rrrrZtype_rdrdrers0    zForwardRef._evaluatecCsJt|tstS|jr|jr|j|jko|j|jkS|j|jko$|j|jkSr)rarNotImplementedr r rrrrdrdre__eq__s      zForwardRef.__eq__cCt|j|jfSr)hashr rrrdrdre__hash__zForwardRef.__hash__cCsd|jdS)Nz ForwardRef())r rrdrdrerrzForwardRef.__repr__TN) r{rxryrrrrrrrdrdrdrers rc@s6eZdZ ddZddZddZddZd d Zd S) _TypeVarLikecCsD |r |r tdt||_t||_|rt|d|_dSd|_dS)Nz"Bivariant types are not supported.zBound must be a type.) ValueErrorbool __covariant____contravariant__rq __bound__)rbound covariant contravariantrdrdrers   z_TypeVarLike.__init__cCrrrrrightrdrdrerrz_TypeVarLike.__or__cCrrrrleftrdrdrerrz_TypeVarLike.__ror__cCs&|jrd}n|jr d}nd}||jS)N+-~)r&r'r{)rprefixrdrdrers  z_TypeVarLike.__repr__cCrr)r{rrdrdrerrz_TypeVarLike.__reduce__N)r{rxryrrrrrrdrdrdrer#s  r#cs,eZdZ dZddddfdd ZZS)r)r{r(__constraints__r&r'rNFr)r*r+c s||_t||||r|durtd|r!t|dkr!tddtfdd|D|_z tdj dd}Wn t t fyHd}Ynw|d krR||_ dSdS) Nz-Constraints cannot be combined with bound=...rz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3rrrr~rrdrer*rz#TypeVar.__init__..r{__main__typing)r{superrrjrrrr4r _getframe f_globalsrrr$rx)rrr)r*r+Z constraintsdef_mod __class__rrer!s   zTypeVar.__init__)r{rxryrr __classcell__rdrdr<rers +rc@&eZdZ ddZddZddZdS)rUcC ||_dSrriroriginrdrdrer?rzParamSpecArgs.__init__cC|jjdS)Nz.argsrir{rrdrdrerBrzParamSpecArgs.__repr__cCt|tstS|j|jkSr)rarUrrirrdrdrerE  zParamSpecArgs.__eq__Nr{rxryrrrrdrdrdrerU3   rUc@r?)rVcCr@rrArBrdrdrerWrzParamSpecKwargs.__init__cCrD)Nz.kwargsrErrdrdrerZrzParamSpecKwargs.__repr__cCrFr)rarVrrirrdrdrer]rGzParamSpecKwargs.__eq__NrHrdrdrdrerVKrIrVcsDeZdZ dZeddZeddZddddfd d ZZS) r)r{r(r&r'rcCt|Sr)rUrrdrdrerzParamSpec.argscCrJr)rVrrdrdrekwargsrKzParamSpec.kwargsNFr5c s`||_t|||z tdjdd}Wn ttfy$d}Ynw|dkr.||_ dSdS)Nrr{r6r7) r{r8rrr9r:rrr$rx)rrr)r*r+r;r<rdrers zParamSpec.__init__) r{rxryrpropertyrrLrr>rdrdr<rercs-  rcCs|do |dS)N__) startswithendswith)attrrdrdre _is_dundersrRcsbeZdZ dddddZddZdd Zd d Zfd d ZddZddZ fddZ Z S)_BaseGenericAliasTNinstrcCs||_||_||_d|_dSr)_instrrir)rrCrUrrdrdrers z_BaseGenericAlias.__init__cOsT|jstd|jd|jjd|j|i|}z||_W|Sty)Y|Sw)NzType z cannot be instantiated; use z () instead)rVrjrrir{__orig_class__r)rrrLresultrdrdrers   z_BaseGenericAlias.__call__cCsjg}|j|vr ||j||}||ddD]}t|ts&t|tr+t|Sq|tt|S)Nr)ririndexrarS issubclassrrr)rrresibrdrdrers    z!_BaseGenericAlias.__mro_entries__cCs<|dvr |jp |jjSd|jvrt|st|j|St|)N>r{ryri)rrir{rrRrrrrQrdrdrers  z_BaseGenericAlias.__getattr__cs4t|s|dvrt||dSt|j||dS)N>r _nparamsrVrr )rRr8 __setattr__setattrri)rrQvalr<rdrer`sz_BaseGenericAlias.__setattr__cC|t|Srrr`rrdrdrerrz#_BaseGenericAlias.__instancecheck__cCtd)NzBSubscripted generics cannot be used with class and instance checksrrrdrdrerz#_BaseGenericAlias.__subclasscheck__cs&tttddt|jDS)NcSsg|]}t|s|qSrd)rRrrQrdrdrerrz-_BaseGenericAlias.__dir__..)rsrr8__dir__dirrirr<rdrerhs z_BaseGenericAlias.__dir__) r{rxryrrrrr`rrrhr>rdrdr<rerSs  rScsxeZdZddeddfdd ZddZd d Zd d Zd dZe ddZ ddZ ddZ ddZ fddZZS)rhTNF)rUrr r csdtj|||dt|ts|f}tdd|D|_t||d|_||_||_|s0|j |_ dSdS)NrTcss,|]}|tur dn|turdn|VqdS).rdN)_TypingEllipsis _TypingEmptyrrdrdrers  z)_GenericAlias.__init__..)r) r8rrarrrrrr r rx)rrCrrUrr r r<rdrers   z_GenericAlias.__init__cC&t|tstS|j|jko|j|jkSr)rarhrrirrrdrdrer   z_GenericAlias.__eq__cCrr)rrirrrdrdrer r z_GenericAlias.__hash__cCrrrr,rdrdrerrz_GenericAlias.__or__cCrrrr.rdrdrerrz_GenericAlias.__ror__csL|jttfvrtd|t|ts|f}tdd|D}|jr2tdd|jDr2t ||}n t ||t |jt t |j|g}|jD]V}t||jrjt|tre|}t|sdtd|n"|}nt|tttjfr|j}|rtfdd|D}||}|jtjjkrt|tr||qH||qH|t|S)Nz%Cannot subscript already-subscripted cs|]}t|VqdSrrfrrdrdrerrz,_GenericAlias.__getitem__..cs|]}t|tVqdSrrarr~rdrdrerrzFExpected a list of types, an ellipsis, ParamSpec, or Concatenate. Got c3s|]}|VqdSrrd)rxsubstrdrer2r)rirrrjrarrr anyrrrrdictrrr rrurhrrlrm collectionsabcr rrr)rrnew_argsrc subparamssubargsrdrsrers>        z_GenericAlias.__getitem__cCs |j|j||j|j|j|jdS)NrrUr r )r=rirrVr r rrrdrdrer;sz_GenericAlias.copy_withcCsB|jr d|j}nt|j}ddd|jD}|d|dS)Nr, cSg|]}t|qSrdr}rrdrdrerEz*_GenericAlias.__repr__..[])rr}rijoinr)rrrrdrdrer@s   z_GenericAlias.__repr__cCsb|jr t|j}n|j}t|j}t|dkr*t|dtr'|tur*|ds*|\}tj ||ffSr) rglobalsrirrrrrarrr)rrCrrdrdrerHs z_GenericAlias.__reduce__cst|jtr td||jrt|S|jtur=t|vr!dS| |}||ddD]}t|t r<||ur<dSq.|jfS)Nrrdr) rarirkrjrr8rrrrYrS)rrr\r]r<rdrerSs    z_GenericAlias.__mro_entries__)r{rxryrrrrrrrrrrrrr>rdrdr<rerhs $ rhcsdeZdZdddfdd ZeddZdd Zd d Zfd d ZddZ ddZ ddZ Z S)_SpecialGenericAliasTNrTcs`|dur|j}tj|||d||_|jdkr"d|jd|_dSd|jd|jd|_dS)NrTrvzA generic version of rg)r{r8rr_rxryr)rrCZnparamsrUrr<rdrerhs z_SpecialGenericAlias.__init__csBt|ts|f}dtfdd|D}t|||j||S)Nz*Parameters to generic types must be types.c3rrrrrrdrerwrz3_SpecialGenericAlias.__getitem__..)rarrrr_rr}rdrrerrs  z _SpecialGenericAlias.__getitem__cCst|j||j|jdS)N)rrU)rhrirrVr}rdrdrer{sz_SpecialGenericAlias.copy_withcCrrrrrdrdrerrz_SpecialGenericAlias.__repr__cs:t|tr t|j|jSt|tst||jSt|Sr)rarrZrirhr8rrr<rdrers    z&_SpecialGenericAlias.__subclasscheck__cCrrrrrdrdrerrz_SpecialGenericAlias.__reduce__cCrrrr,rdrdrerrz_SpecialGenericAlias.__or__cCrrrr.rdrdrerrz_SpecialGenericAlias.__ror__) r{rxryrrrrrrrrrr>rdrdr<rergs  rcs$eZdZfddZddZZS)_CallableGenericAliascsZ|j}t|dkrt|drtSdddd|ddDdt|dd S) Nrrztyping.Callable[[r~cSrrdrrrdrdrerrz2_CallableGenericAlias.__repr__..rz], r)rrrur8rrr}rrr<rdrers  z_CallableGenericAlias.__repr__cCsD|j}t|dkrt|dst|dd|df}tjt|ffS)Nrrr)rrrursrrr rrdrdrersz _CallableGenericAlias.__reduce__)r{rxryrrr>rdrdr<rers  rc@s(eZdZddZddZeddZdS) _CallableTypecCst|j||j|jttfddS)NTr|)rrirrVrrr}rdrdrers z_CallableType.copy_withcCsPt|tr t|dkrtd|\}}t|trt||f}n||f}||S)Nrz6Callable must be used as Callable[[arg, ...], result].)rarrrrjrs__getitem_inner__)rrrrXrdrdrers  z_CallableType.__getitem__cCsb|\}}d}t||}|tur|t|fSt|ts|f}tdd|D}||f}||S)Nz.Callable[args, result]: result must be a type.csrnrro)rrcrdrdrerrz2_CallableType.__getitem_inner__..)rqEllipsisrrjrarr)rrrrXrordrdrers    z_CallableType.__getitem_inner__N)r{rxryrrrrrdrdrdrers rc@seZdZeddZdS) _TupleTypecs|dkr |tfSt|ts|f}t|dkr.|ddur.dt|d}||tfSdtfdd |D}||S) Nrdrr.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3rrrrrrdrerrz)_TupleType.__getitem__..)rrkrarrrrqrj)rrrrdrrers   z_TupleType.__getitem__N)r{rxryrrrdrdrdrersrcsPeZdZddZddZddZfddZd d Zd d Zfd dZ Z S)rcCst|Srrr}rdrdrerrfz_UnionGenericAlias.copy_withcCs(t|ttjfs tSt|jt|jkSr)rarrlrmrrrrrdrdrersz_UnionGenericAlias.__eq__cCstt|jSr)r frozensetrrrdrdrerrz_UnionGenericAlias.__hash__csd|j}t|dkr-|dtdurdt|ddS|dtdur-dt|ddStS)Nrrztyping.Optional[rr)rrr`r}r8rrr<rdrers  z_UnionGenericAlias.__repr__cCrcrrdrrdrdrerrz$_UnionGenericAlias.__instancecheck__cCs |jD] }t||r dSqdSNT)rrZ)rrrcrdrdrers  z$_UnionGenericAlias.__subclasscheck__cst\}\}}|t|ffSr)r8rr)rrrCrr<rdrers z_UnionGenericAlias.__reduce__) r{rxryrrrrrrrr>rdrdr<rers  rcCsdd|DS)Ncss|] }|t|fVqdSr)r`rrdrdrersz'_value_and_type_iter..rd)rrdrdrerrrc@seZdZddZddZdS)rcCs*t|tstStt|jtt|jkSr)rarrrrrrrdrdrers z_LiteralGenericAlias.__eq__cCsttt|jSr)rrrrrrdrdrerz_LiteralGenericAlias.__hash__N)r{rxryrrrdrdrdrers rceZdZfddZZS)rtcszt|dttfrg|dd|dRSt|dtr,g|dd|djR}n t|dts7tdt|S)Nrr) rarsrrrtrrrjr8rr}r<rdrer s z"_ConcatenateGenericAlias.copy_with)r{rxryrr>rdrdr<rertsrtcs2eZdZ dZdZeddZfddZZS)rrdFcCst|ts|f}|s|turtd|jdtdd|D}|ttfvrLtdd|Ds8td|jdt t |t |krKtd|jdnt d d|j Dr\t ||}n t||t |j t||ttfd d S) NzParameter list to z[...] cannot be emptycsrnrrorrdrdrer2rz,Generic.__class_getitem__..css|] }t|ttfVqdSr)rarrrrdrdrer5rzParameters to zF[...] must all be type variables or parameter specification variables.z[...] must all be uniquecsrprrqr~rdrdrer>rTr)rarrrrjryrrallr{rrrurrrrhrr)rrrdrdre__class_getitem__+s0       zGeneric.__class_getitem__c stj|i|g}d|jvrt|jv}n t|jvo|jdk}|r&tdd|jvrt|jt t f}d}|jD]}t |t rO|j turO|durLtd|j}q8|durt|}t||ksdfdd|D}ddd|D} td |d | d |}t||_dS) N__orig_bases__rz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.r~c3s |] }|vrt|VqdSrrbr~Zgvarsetrdrerbz,Generic.__init_subclass__..csrnrr)rgrdrdrercrzSome type variables (z) are not listed in Generic[r)r8rrrr __bases__r{rjrrrrarhrirrrrr) rrrLrerrorZgvarsbaseZtvarsetZs_varsZs_argsr<rrerFs<        zGeneric.__init_subclass__) r{rxryr _is_protocolrrrr>rdrdr<rers rc@ eZdZdS)rkNr{rxryrdrdrdrerkjrkc@r)rjNrrdrdrdrerjqrrj)rrrWr_is_runtime_protocol) __abstractmethods____annotations__rrrrx__new__r__subclasshook__rr_MutableMapping__markercCst t}|jddD],}|jdvrq t|di}t|jt|D]}|ds6|tvr6| |q&q |S)Nr)rrrZ_abc_) r__mro__r{rrsrkeysrOEXCLUDED_ATTRIBUTESadd)rZattrsr annotationsrQrdrdre_get_protocol_attrss   rcstfddtDS)Nc3s |] }tt|dVqdSr)rnrrgrrdrerrz,_is_callable_members_only..)rrrrdrre_is_callable_members_onlysrcOstt|}|jr td|jturdS|jD]}|jdt}|tur'||_nqtj|_|j|g|Ri|dS)Nz Protocols cannot be instantiatedr) r`rrjr_no_init_or_replace_initrrrobject)rrrLrrZinitrdrdrers  rrr6c Cs4z t|djd|WSttfyYdSw)Nrr{)rr9r:rrr$)depthdefaultrdrdre_callers rc Cs2 z t|jddvWSttfyYdSw)Nr{)rxrT)rr9r:rr$rrdrdre_allow_reckless_class_checkss r) r r)rrr+rr'rr-r0AbstractContextManagerAbstractAsyncContextManager)zcollections.abc contextlibcr) _ProtocolMetacstddrtddstddstdtddrtr'tjr'dSjr:tfdd tDr:dSt S) NrFrrrLInstance and class checks can only be used with @runtime_checkable protocolsTc3s:|]}t|ott|d pt|duVqdSr)hasattrrnrrgrinstancerdrers   z2_ProtocolMeta.__instancecheck__..) rrrjrrZr=rrrr8rrr<rrers&     z_ProtocolMeta.__instancecheck__)r{rxryrr>rdrdr<rersrcs*eZdZ dZdZdZfddZZS)rrdTFcstj|i|jddstddjD_fdd}djvr)|_js.dSjD]#}|tt fvsT|j t vrF|j t |j vsTt |t rN|jsTtd|q1t_dS) NrFcss|]}|tuVqdSr)r)rr]rdrdrerrz-Protocol.__init_subclass__..csjdds tStddstrtStdts%tr!tStdt|ts.tdt D];}|j D]1}||jvrM|j|durKtSn t|di}t|t j j rh||vrht|trh|jrhnq7tSq2dS) NrFrrz._proto_hookrz7Protocols can only inherit from other protocols, got %r)r8rrrrurrrrrrx_PROTO_ALLOWLISTr{rZrjrr)rrrLrrr<rrer s*  &    zProtocol.__init_subclass__)r{rxryrrrrr>rdrdr<rers r) metaclasscsReZdZ fddZddZddZddZd d Zd d Zfd dZ Z S)_AnnotatedAliascs2t|tr |j|}|j}t||||_dSr)rar __metadata__rir8r)rrCmetadatar<rdrerUs   z_AnnotatedAlias.__init__cCs|d}t||jS)Nr)rr)rrZnew_typerdrdrer\s z_AnnotatedAlias.copy_withcCs$dt|jddd|jDS)Nztyping.Annotated[{}, {}]r~csrnr)rwrrdrdrerdrz+_AnnotatedAlias.__repr__..)formatr}rirrrrdrdrerasz_AnnotatedAlias.__repr__cCstjt|jf|jffSr)rrrrirrrdrdrergsz_AnnotatedAlias.__reduce__cCrlr)rarrrirrrdrdrerlrmz_AnnotatedAlias.__eq__cCrr)rrirrrdrdrerrr z_AnnotatedAlias.__hash__cs|dvrdSt|S)N>r{ryr)r8rr^r<rdrerus z_AnnotatedAlias.__getattr__) r{rxryrrrrrrrr>rdrdr<rerMs rc@s.eZdZ dZddZeddZddZdS) rrdcOre)Nz&Type Annotated cannot be instantiated.rrrrLrdrdrerrfzAnnotated.__new__cCsNt|tr t|dkrtdd}t|d|dd}t|dd}t||S)NrzUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rTr\r)rarrrrjrqr)rrrorCrrdrdrers  zAnnotated.__class_getitem__cOstd|j)NzCannot subclass {}.Annotated)rjrrxrrdrdrers zAnnotated.__init_subclass__N)r{rxryrrrrrrdrdrdrer{s  rcCs( t|tr |jstd|d|_|S)NzB@runtime_checkable can be only applied to protocol classes, got %rT)rZrrrjrrrdrdrerWsrWcCs |Srrd)typrbrdrdrerJsrJc Cs z|j}Wn tyiYSw|j}|j}|d|}|jp"d}|j}|r,t|ni}|t|}t||d|D]\}} | ||<q=|S)Nrd) __code__r co_argcount co_varnames __defaults____kwdefaults__rvrr) rrZ pos_countZ arg_namesdefaultsZ kwdefaultsr[Z pos_offsetrvaluerdrdre _get_defaultss       rc CsB t|ddr iSt|tri}t|jD]d}|dur(ttj|jddi}n|}|j di}t|t j r9i}|durCt t |n|}|durR|durR||}}|D]"\} } | durbtd} t| trnt| ddd} t| ||} | || <qVq|r~|Sdd|DS|durt|t jr|j }n|} t| d r| j} t| d st| d i}|dur|}n|dur|}t|dd}|durt|triStd |t|} t |}|D]7\} } | durtd} t| trt| t|t j dd} t| ||} | | vr| | durt| } | || <q|r|Sd d|DS) N__no_type_check__rrFT)rpr_cSi|] \}}|t|qSrd_strip_annotationsrkrrdrdre +z"get_type_hints.. __wrapped__ __globals__z1{!r} is not a module, class, method, or function.cSrrdrrrdrdrerSr)rrar`reversedrrrrrxrrlGetSetDescriptorTypervvarsitemsrbrr ModuleTyperr_allowed_typesrjrrr) r|rrZinclude_extrasZhintsrZ base_globalsannZ base_localsrrZnsobjrrdrdrerNsx                rNcCs t|tr t|jSt|tr&tdd|jD}||jkr!|S||St|trBtdd|jD}||jkr<|St|j|St|t j r`tdd|jD}||jkrY|St t j|S|S)Ncsrnrrrrdrdrer\rz%_strip_annotations..csrnrrrrdrdrerarcsrnrrrrdrdrerfr)rarrrirhrrrrrrlrmrrrr)rZ stripped_argsrdrdrerVs&          rcCsJ t|trtSt|ttttfr|jS|turtSt|t j r#t j SdSr) rarrrSrrUrVrirrlrmtprdrdrerMns  rMcCs t|tr |jf|jSt|ttfr8|j}|jtjj ur6t |dkr*t |ds6t |dd|df}|St|t jrA|jSdS)Nrrrrd)rarrirrhrrrwrxr rrursrlrm)rr[rdrdrerLs  rLcCs t|tSr)ra_TypedDictMetarrdrdrerOs rOcCs t|tr;|j}|jD]\}}||j|fvr!||q|D]}t|tj r1d|_ t|tr:t |q&zd|_ W|St yKY|Swr) rar`rcopyrrpopvaluesrlrzrrQrj)rcZ arg_attrsrQrbr|rdrdrerQs(       rQcs tfdd}|S)Ncs|i|}t|}|Sr)rQ)rrrrrdrewrapped_decoratorsz2no_type_check_decorator..wrapped_decorator)rr)rrrdrrerRsrRcOs td)NzYou 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.)NotImplementedErrorrrdrdre_overload_dummysrcCs tSr)r)rrdrdrerTsrTcCs |Srrd)frdrdrerKsrKTKTVTT_co)r*V_coVT_coT_contra)r+CT_co)r*r)rIraCallable 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. rrrrrTa@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, ...]. r=r:r?r@rr/r;r<raA 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. c@$eZdZ dZedefddZdS)r6rdreturncCdSrrdrrdrdre__int__zSupportsInt.__int__N)r{rxryrrintrrdrdrdrer6 r6c@r)r4rdrcCrrrdrrdrdre __float__rzSupportsFloat.__float__N)r{rxryrrfloatrrdrdrdrer4rr4c@r)r3rdrcCrrrdrrdrdre __complex__rzSupportsComplex.__complex__N)r{rxryrrcomplexrrdrdrdrer3rr3c@r)r2rdrcCrrrdrrdrdre __bytes__rzSupportsBytes.__bytes__N)r{rxryrrbytesrrdrdrdrer2rr2c@r)r5rdrcCrrrdrrdrdre __index__rzSupportsIndex.__index__N)r{rxryrrrrrdrdrdrer5rr5c@r)r1rdrcCrrrdrrdrdre__abs__rzSupportsAbs.__abs__N)r{rxryrrrrrdrdrdrer1rr1c@s*eZdZ dZeddedefddZdS) r7rdrndigitsrcCrrrd)rrrdrdre __round__rzSupportsRound.__round__Nr)r{rxryrrrrrrdrdrdrer7s r7rdcCs@dd|D}dd|D}tj||||d}||_|j_|S)NcSsg|]\}}|qSrdrdrnrrdrdrerrz!_make_nmtuple..cSs$i|]\}}|t|d|dqS)zfield z annotation must be a typerrrdrdrersz!_make_nmtuple..rr^)rw namedtuplerr)rrlr^rfieldsnm_tplrdrdre _make_nmtuplesr > _makerr_field_defaults_replace_asdict_fieldsr__getnewargs__Z_source>rxrr{c@r)NamedTupleMetac sdi}g}|D]&}|vr||q |r0td|dt|dkr%dnddd|q t||fd d |Dd d }D]}|tvrRtd ||t vrc||j vrct |||qF|S)NrzNon-default namedtuple field z cannot follow default fieldrs r~csg|]}|qSrdrd)rrnsrdrerrz*NamedTupleMeta.__new__..rxrz&Cannot overwrite NamedTuple attribute ) rrrjrrr r _prohibitedr_specialrra) rtypenamerrrlZ default_namesZ field_namer keyrdrrers.     zNamedTupleMeta.__new__N)r{rxryrrdrdrdrers rc Ksb |dur |}n|rtdz tdjdd}Wn ttfy)d}Ynwt|||dS)NzIEither list of fields or keywords can be provided to NamedTuple, not bothrr{r6r^) rrjrr9r:rrr$r )rrrLr^rdrdrerAs rAcCst|dkr tdtfS)Nrz5Multiple inheritance with NamedTuple is not supported)rrj _NamedTuplerrdrdre_namedtuple_mro_entries s rc@s&eZdZdddZeZddZeZdS)rTc s |D] }t|turtdqtt|tf|i}|di}t|}dfdd|D}t} t} |D] }| |j di| |j dd| |j ddq=| ||rk| |n| ||_ t | _ t | _td s|_S) NzHcannot inherit from both a TypedDict type and a non-TypedDict base classrz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecs"i|] \}}|t|jdqS)r)rqrx)rrrroZtp_dictrdrer4 sz*_TypedDictMeta.__new__..__required_keys__rd__optional_keys__ __total__)r`rrjrrvrrrrupdaterrrr r!rr") rrrrtotalrrZown_annotationsZown_annotation_keysZ required_keysZ optional_keysrdrrer" s:          z_TypedDictMeta.__new__cCre)Nz4TypedDict does not support instance and class checksr)rrrdrdrerO rKz _TypedDictMeta.__subclasscheck__N)T)r{rxryrrvrrrrdrdrdrer! s  +rr$c Ksl |dur|}n|rtddt|i}ztdjdd|d<Wn ttfy-Ynwt|d||dS) Nz@TypedDict takes either a dict or keyword arguments, but not bothrrr{r6rxrdr%) rjrvrr9r:rrr$r)rrr$rLrrdrdrerBV s) rBcCstfSr) _TypedDictrrdrdre sr'c@s>eZdZ ddZddZddZddZd d Zd d Zd S)rPcCsD||_d|vr|dd}||_||_t}|dkr ||_dSdS)Nrgrr7)ry rpartitionr{Z __supertype__rrx)rrrr;rdrdrer s zNewType.__init__cCs|jd|jS)Nrg)rxryrrdrdrer rzNewType.__repr__cCs|Srrd)rrrrdrdrer rzNewType.__call__cCrr)ryrrdrdrer rzNewType.__reduce__cCrrrrrdrdrer rzNewType.__or__cCrrrrrdrdrer rzNewType.__ror__N) r{rxryrrrrrrrdrdrdrerP s  rPc@seZdZ dZeedefddZeedefddZed7dd Z eede fd d Z ede fd d Z ed7ddZede fddZed8de defddZede fddZed8de defddZed8de deefddZed9de d e de fd!d"Zede fd#d$Zede fd%d&Zed:d'e de fd(d)Zede fd*d+Zed,ede fd-d.Zed/eeddfd0d1Zed;d3d4Zed7d5d6ZdS)eZdZ dZedeeefdefddZ ed ddZ dS) rDrdrrcCrrrdr>rdrdrer?0 rzBinaryIO.writecCrrrdrrdrdrerC4 rzBinaryIO.__enter__N)rrD) r{rxryrrrr bytearrayrr?rCrdrdrdrerD+ srDc@seZdZ dZeedefddZeedefddZ eede efddZ eede fd d Z eedefd d Zedd dZdS)rHrdrcCrrrdrrdrdrebuffer> r*z TextIO.buffercCrrrdrrdrdreencodingC r*zTextIO.encodingcCrrrdrrdrdreerrorsH r*z TextIO.errorscCrrrdrrdrdreline_bufferingM r*zTextIO.line_bufferingcCrrrdrrdrdrenewlinesR r*zTextIO.newlinescCrrrdrrdrdrerCW rzTextIO.__enter__N)rrH)r{rxryrrMrrDrGrbrHrrIr%rJr rKrCrdrdrdrerH9 s(rHc@s"eZdZ gdZeZeZeZdS)io)rErHrDN)r{rxry__all__rErHrDrdrdrdrerL\ s rLz.ioc@seZdZ ddgZeZeZdS)rerGrFN)r{rxryrMrGrFrdrdrdrerNk s rNz.rerr")rr6)r)NNF)rd)rxrrrwZcollections.abcrrrrNZ stdlib_rerrlrrrrrMrfrqrur}rrrrrrrrrrrrrkrr rSr r rrrrZr r[rr#rrUrVrrRrSrhrrrrrrrrtrrkrjZ_TYPING_INTERNALSZ_SPECIAL_NAMESrrrrrrrrrrrrWrJrrzBuiltinFunctionType MethodTyperrrNrrMrLrOrQrRrrTrKrrrrrrrr`rrrbrIZ_aliasrr)r,r+r*rrr0r'rr-r rr?rr%r!r#r&r$rrrrrsr=dequer:rr@r"r rr(rrrr/rvr; defaultdictr<r>r9r8rCr.rr6r4r3r2r5r1r7r rrrrArrrrrrBr&rPrXrYrErDrHrLr{rrGrFrdrdrdresg "     +     '  !   /@"ADMp+#"  V    b.5  i                   #59 .c#