a DOg,@sddlmZmZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl m Z m Z mZmZgdZdddddZdddd d Zd d ZddZddZddZddZddZgZdddddZefddZGdddZGdd d ZGd!d"d"ed d#ZGd$d%d%ed d#Z ed&d'Z!ed(d)Z"ed*d+Z#ed,d-Z$ed.d/Z%ed0d1Z&e ed dd2d3Z'Gd4d5d5ed d#Z(Gd6d7d7eed d#Z)d8d9Z*Gd:d;d;ed d#Z+Gdd?d?e+d d#Z-Gd@dAdAe,d d#Z.GdBdCdCe-d d#Z/GdDdEdEe-d d#Z0GdFdGdGe,d d#Z1dHdIZ2GdJdKdKe,d d#Z3GdLdMdMZ4GdNdOdOZ5GdPdQdQZ6gdRZ7gdSZ8e7e8dTgZ9dUdVZ:dWdXZ;dYdZZGdadbdbeZ?Gdcdddde4e?deZ@Gdfdgdge,d d#ZAGdhdidiZBdjdkZCdldmZDdndoZEe jFe jGe jHe jIe e efZJddpdqZKdrdsZLdtduZMdvdwZNdxdyZOdzd{ZPd|d}ZQd~dZRddZSe)dZTe)dZUe)dZVe)dd dZWe)dd dZXe)dd dZYe)dd dZZe)dd e[dZ\e)de]e^Z_e-Z`e`ejjadZae`ejjbdZbe`ejjcdZce`ejjddZde`ejjedZee`ejjfdZfe`ejjgdZge`ejjhdZhe`ejjidZie`ejjjdZje`ejjkdZke/ejjldZldel_me`ejjndddZoe`ejjpdZpe`ejjqdZqe`ejjrdZre`ejjsdZse`ejjtdZte`ejjudZue0evddddZwdew_me`exddddZye`ejzdddZ{e`e|ddddZne`eddddZ}e`ejj~dZ~e`ejjdZe`ejjdZe`ejjdZe`ejdddZe`ejdddZe`eddddZe`ejdddZe`ejdZe`ejdZe`ejdZe`ejjdZe`ejjdZe`e[ddddZde_meCGddde@ZeCGddde@ZeCGddde@ZeCGddde@ZeCGddde@ZeCGddde@eWZeCGddde@eWZdddZehdZehdZGddde[ZdddZe[eddiZddZee_Gddde[Zdd dddZe[eddiZdde_ddÄZe^ZdZGddńde4e_ZGddDŽdee]ZGddɄdee^ZGdd˄d˃Zede_ee jej<e`e jdZe`e jdZGdd΄d΃Zede_ee jej<dS))abstractmethodABCMetaN)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorType GenericAlias)M AnnotatedAnyCallableClassVarFinal ForwardRefGenericLiteralOptionalProtocolTupleTypeTypeVarUnion 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_hintsNewType no_type_checkno_type_check_decoratorNoReturnoverloadruntime_checkableText TYPE_CHECKINGFallow_special_formscCs,|durtdSt|tr(t|||dS|S)N)moduleis_class)type isinstancestrr )argrWrVr]+/opt/alt/python39/lib64/python3.9/typing.py _type_converts  r_TcCsttf}|s$|tf7}|r$|tf7}t|||d}t|trT|j|vrTt|d|t t tfvrf|St|t s||ttfvrtd|dt|t t tfr|St|st|d|dd|S)N)rWrVz is not valid as type argumentzPlain z Got z.100.)rrr r r_rZ _GenericAlias __origin__ TypeErrorr rP _SpecialFormrYrr callable)r\msg is_argumentrWrVinvalid_generic_formsr]r]r^ _type_checks&    ricCsft|tjrt|St|tr@|jdkr.|jS|jd|jS|durLdSt|tjr^|jSt|S)Nbuiltinsr`.z...) rZtypesrreprrY __module__ __qualname__ FunctionType__name__)objr]r]r^ _type_reprs    rrcsZg|D]H}t|tr(|vr(|t|ttfrfdd|jDqtS)Ncsg|]}|vr|qSr]r].0ttvarsr]r^ z&_collect_type_vars..)rZrappendrarextend__parameters__tuple)rkrur]rvr^_collect_type_varss r~c CsR|st|dt|}||krNtd||kr2dndd|d|d|dS)Nz is not a generic classzToo manyfewz parameters for z ; actual z , expected )rclen)cls parameterselenalenr]r]r^_check_genericsrcCsJt|}t|t|krFg}|D] }||vr ||||q |}|SN)setrrzremove)params all_params new_paramsrur]r]r^ _deduplicates  rcCsrg}|D]\}t|tr$||jqt|trZt|dkrZ|dturZ||ddq||qtt|S)Nr) rZ_UnionGenericAliasr{__args__r}rrrzrrrpr]r]r^_remove_dups_flattens " rcCs8g}|D]&}t|tr$||jq||qt|Sr)rZ_LiteralGenericAliasr{rrzr}rr]r]r^_flatten_literal_paramss   rtypedcs fdd}|dur||S|S)Ncs8tjdtjtfdd}|S)Nrcs2z|i|WSty"Yn0|i|Srrcargskwdscachedfuncr]r^inners  z+_tp_cache..decorator..inner) functools lru_cache _cleanupsrz cache_clearwraps)rrrrr^ decorator s  z_tp_cache..decoratorr])rrrr]rr^ _tp_caches rcstt|tr|St|ttfrptfdd|jD}||jkrP|St|trft|j|S||S|S)Nc3s|]}t|VqdSr) _eval_typertaglobalnslocalnsrecursive_guardr]r^ &ryz_eval_type..) rZr _evaluaterarr}rrb copy_with)rurrrev_argsr]rr^rs     rc@seZdZdZddZdS)_Final) __weakref__cOsd|vrtddS)N_rootz&Cannot subclass special typing classesrselfrrr]r]r^__init_subclass__5sz_Final.__init_subclass__N)rprmrn __slots__rr]r]r]r^r0src@s eZdZdZddZddZdS) _Immutabler]cCs|Srr]rr]r]r^__copy__=sz_Immutable.__copy__cCs|Srr])rmemor]r]r^ __deepcopy__@sz_Immutable.__deepcopy__N)rprmrnrrrr]r]r]r^r9src@sTeZdZdZddZddZddZdd Zd d Zd d Z ddZ e ddZ dS)rd)_name__doc___getitemcCs||_|j|_|j|_dSr)rrprr)rgetitemr]r]r^__init__Isz_SpecialForm.__init__cCstd|dS)NzCannot subclass r)rbasesr]r]r^__mro_entries__Nsz_SpecialForm.__mro_entries__cCs d|jSNtyping.rrr]r]r^__repr__Qsz_SpecialForm.__repr__cCs|jSrrrr]r]r^ __reduce__Tsz_SpecialForm.__reduce__cOstd|dS)NzCannot instantiate rrr]r]r^__call__Wsz_SpecialForm.__call__cCst|ddS)Nz! cannot be used with isinstance()rrrqr]r]r^__instancecheck__Zsz_SpecialForm.__instancecheck__cCst|ddS)Nz! cannot be used with issubclass()rrrr]r]r^__subclasscheck__]sz_SpecialForm.__subclasscheck__cCs |||Sr)rrrr]r]r^ __getitem__`sz_SpecialForm.__getitem__N) rprmrnrrrrrrrrrrr]r]r]r^rdFsrd)rc@seZdZddZdS)_LiteralSpecialFormcCs"t|ts|f}|j|g|RSr)rZr}rrr]r]r^rfs z_LiteralSpecialForm.__getitem__N)rprmrnrr]r]r]r^resrcCst|ddSNz is not subscriptablerrr]r]r^r ls r cCst|ddSrrrr]r]r^rPzs rPcCst||d}t||fSNz accepts only single type.rirarritemr]r]r^r sr cCst||d}t||fSrrrr]r]r^r sr cs`|dkrtdt|ts |f}dtfdd|D}t|}t|dkrV|dSt||S)Nr]z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3s|]}t|VqdSrrirtrrfr]r^rryzUnion..rr)rcrZr}rrrrr]rr^rs  rcCs t||d}t|tdfS)Nz requires a single type.)rirrY)rrr\r]r]r^rsrcGsHt|}z"tddttt|D}Wnty<Yn0t||S)Ncss|]\}}|VqdSrr])rtr_r]r]r^rryzLiteral..)rr}rlist_value_and_type_iterrcrrr]r]r^rs " rc@s@eZdZdZdddddZdd Zd d Zd d ZddZdS)r )__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument____forward_is_class____forward_module__TNF)rXcCsxt|tstd|zt|dd}Wn tyHtd|Yn0||_||_d|_d|_||_ ||_ ||_ dS)Nz*Forward reference must be a string -- got zevalz/Forward reference must be an expression -- got F) rZr[rccompile SyntaxErrorrrrrrrr)rr\rgrWrXcoder]r]r^r s  zForwardRef.__init__cCs|j|vr|S|jr||ur|dur6|dur6i}}n|durD|}n |durP|}|jdurrttj|jdd|}tt|j ||d|j |j d}t |||||jhB|_ d|_|j S)N__dict__z*Forward references must evaluate to types.)rgrVT)rrrgetattrsysmodulesgetrirrrrrr)rrrrtype_r]r]r^rs0    zForwardRef._evaluatecCsJt|tstS|jr2|jr2|j|jko0|j|jkS|j|jkoH|j|jkSr)rZr NotImplementedrrrrrotherr]r]r^__eq__5s      zForwardRef.__eq__cCst|j|jfSr)hashrrrr]r]r^__hash__>szForwardRef.__hash__cCsd|jdS)Nz ForwardRef())rrr]r]r^rAszForwardRef.__repr__)TN) rprmrnrrrrrrr]r]r]r^r s  r c@s2eZdZdZddddddZddZd d ZdS) r)rp __bound____constraints__ __covariant____contravariant__rNF)bound covariant contravariantc s||_|r|rtdt||_t||_|r>|dur>td|rVt|dkrVtddtfdd|D|_|rt |d|_ nd|_ zt dj d d }Wnttfyd}Yn0|d kr||_dS) Nz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|VqdSrrrsrr]r^rryz#TypeVar.__init__..zBound must be a type.rp__main__typing)rp ValueErrorboolrrrcrr}rrirr _getframe f_globalsrAttributeErrorrm)rnamerrr constraintsdef_modr]rr^rts(    zTypeVar.__init__cCs&|jr d}n|jrd}nd}||jS)N+-~)rrrp)rprefixr]r]r^rs zTypeVar.__repr__cCs|jSr)rprr]r]r^rszTypeVar.__reduce__)rprmrnrrrrr]r]r]r^rEs ,  rcCs|do|dS)N__) startswithendswith)attrr]r]r^ _is_dundersrcsTeZdZdddddZddZdd Zd d Zfd d ZddZddZ Z S)_BaseGenericAliasTNinstrcCs||_||_||_d|_dSr)_instrrbr)roriginrrr]r]r^rsz_BaseGenericAlias.__init__cOsT|js"td|jd|jjd|j|i|}z ||_WntyNYn0|S)NzType z cannot be instantiated; use z () instead)rrcrrbrp__orig_class__r)rrkwargsresultr]r]r^rs    z_BaseGenericAlias.__call__cCsdg}|j|vr||j||}||ddD]}t|tsLt|tr4q\q4|tt|S)Nr)rbrzindexrZr issubclassrr})rrresibr]r]r^rs    z!_BaseGenericAlias.__mro_entries__cCs*d|jvrt|st|j|St|dS)Nrb)rrrrbr)rr r]r]r^ __getattr__s z_BaseGenericAlias.__getattr__cs2t|s|dvr t||nt|j||dS)N)rr_nparams)rsuper __setattr__setattrrb)rr val __class__r]r^rsz_BaseGenericAlias.__setattr__cCs|t|Sr)rrYrr]r]r^rsz#_BaseGenericAlias.__instancecheck__cCs tddS)NzBSubscripted generics cannot be used with class and instance checksrrr]r]r^rsz#_BaseGenericAlias.__subclasscheck__) rprmrnrrrrrrr __classcell__r]r]r"r^rs    rcsdeZdZdddfdd ZddZdd Zed d Zd d ZddZ ddZ fddZ Z S)raTNrcsPtj|||dt|ts"|f}tdd|D|_t||_|sL|j|_dS)Nrcss*|]"}|turdn|turdn|VqdS).r]N)_TypingEllipsis _TypingEmptyrr]r]r^rs  z)_GenericAlias.__init__..)rrrZr}rr~r|rm)rrrrrr"r]r^rs   z_GenericAlias.__init__cCs&t|tstS|j|jko$|j|jkSr)rZrarrbrrr]r]r^rs    z_GenericAlias.__eq__cCst|j|jfSr)rrbrrr]r]r^rsz_GenericAlias.__hash__cs|jttfvrtd|t|ts,|f}dtfdd|D}t||t|jt t |j|g}|j D]X}t|t r|}n6t|t tfr|j}|rtfdd|D}||}||qr|t|S)Nz%Cannot subscript already-subscripted *Parameters to generic types must be types.c3s|]}t|VqdSrrrrr]r^rryz,_GenericAlias.__getitem__..c3s|]}|VqdSrr])rtx)substr]r^r ry)rbrrrcrZr}rrr|dictziprrrarrzr)rrnew_argsr\ subparamssubargsr])rfr)r^rs&     z_GenericAlias.__getitem__cCs|j|j||j|jdSN)rr)r#rbrrrrr]r]r^rsz_GenericAlias.copy_withcCsB|jrd|j}n t|j}ddd|jD}|d|dS)Nr, cSsg|] }t|qSr]rrrr]r]r^rxryz*_GenericAlias.__repr__..[])rrrrbjoinr)rrrr]r]r^rs   z_GenericAlias.__repr__cCsR|jrt|j}n|j}t|j}t|dkrDt|dtsD|\}tj||ffS)Nrr) rglobalsrbr}rrrZoperatorr)rrrr]r]r^rs z_GenericAlias.__reduce__csh|jrt|S|jtur`t|vr(dS||}||ddD]}t|trB||urBdSqB|jfS)Nr]r) rrrrbrrrrZr)rrrrr"r]r^r$s   z_GenericAlias.__mro_entries__) rprmrnrrrrrrrrrr$r]r]r"r^ras   racsTeZdZdddfdd ZeddZdd Zd d Zfd d ZddZ Z S)_SpecialGenericAliasTNrcs^|dur|j}tj|||d||_|jdkrBd|jd|_nd|jd|jd|_dS)NrrjzA generic version of r`)rprrrrmrnr)rrnparamsrrr"r]r^r6s z_SpecialGenericAlias.__init__csBt|ts|f}dtfdd|D}t|||j||S)Nr'c3s|]}t|VqdSrrrrr]r^rEryz3_SpecialGenericAlias.__getitem__..)rZr}rrrr0r]rr^r@s  z _SpecialGenericAlias.__getitem__cCst|j||j|jdSr/)rarbrrr0r]r]r^rIsz_SpecialGenericAlias.copy_withcCs d|jSrrrr]r]r^rMsz_SpecialGenericAlias.__repr__cs:t|trt|j|jSt|ts.t||jSt|Sr)rZr8rrbrarrrr"r]r^rPs    z&_SpecialGenericAlias.__subclasscheck__cCs|jSrrrr]r]r^rWsz_SpecialGenericAlias.__reduce__) rprmrnrrrrrrrr$r]r]r"r^r85s   r8cs$eZdZfddZddZZS)_CallableGenericAliascs\t|jdkr&|jdtur&tSdddd|jddDdt|jdd S) Nrztyping.Callable[[r1cSsg|] }t|qSr]r2rr]r]r^rxaryz2_CallableGenericAlias.__repr__..z], r4)rrEllipsisrrr5rrrr"r]r^r\s  z_CallableGenericAlias.__repr__cCsD|j}t|dkr|ddus6t|dd|df}tjt|ffS)Nr;r.r<)rrrr7rr rrr]r]r^rdsz _CallableGenericAlias.__reduce__)rprmrnrrr$r]r]r"r^r:[s r:c@s(eZdZddZddZeddZdS) _CallableTypecCst|j||j|jdSr/)r:rbrrr0r]r]r^rlsz_CallableType.copy_withcCsPt|trt|dkrtd|\}}t|tr>t||f}n||f}||S)Nr;z6Callable must be used as Callable[[arg, ...], result].)rZr}rrcr__getitem_inner__)rrrrr]r]r^rps z_CallableType.__getitem__cCsb|\}}d}t||}|tur,|t|fSt|ts<|f}tdd|D}||f}||S)Nz.Callable[args, result]: result must be a type.css|]}t|VqdSr)r_)rtr\r]r]r^rryz2_CallableType.__getitem_inner__..)rir=rr%rZr})rrrrrfr]r]r^r@~s   z_CallableType.__getitem_inner__N)rprmrnrrrr@r]r]r]r^r?ksr?c@seZdZeddZdS) _TupleTypecs|dkr|tfSt|ts$|f}t|dkr\|ddur\dt|d}||tfSdtfdd |D}||S) Nr]r;r.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|VqdSrrrrr]r^rryz)_TupleType.__getitem__..)rr&rZr}rrir%)rrrr]rr^rs  z_TupleType.__getitem__N)rprmrnrrr]r]r]r^rAsrAcs4eZdZddZddZddZfddZZS) rcCst|Sr)rr0r]r]r^rsz_UnionGenericAlias.copy_withcCs"t|tstSt|jt|jkSr)rZrrrrrr]r]r^rs z_UnionGenericAlias.__eq__cCstt|jSr)r frozensetrrr]r]r^rsz_UnionGenericAlias.__hash__csd|j}t|dkrZ|dtdur6dt|ddS|dtdurZdt|ddStS)Nr;rztyping.Optional[rr4)rrrYrrrrr>r"r]r^rs z_UnionGenericAlias.__repr__)rprmrnrrrrr$r]r]r"r^rsrcCsdd|DS)Ncss|]}|t|fVqdSr)rYrr]r]r^rryz'_value_and_type_iter..r])rr]r]r^rsrc@seZdZddZddZdS)rcCs*t|tstStt|jtt|jkSr)rZrrrrrrr]r]r^rs z_LiteralGenericAlias.__eq__cCsttt|jSr)rrBrrrr]r]r^rsz_LiteralGenericAlias.__hash__N)rprmrnrrr]r]r]r^rsrcs0eZdZdZdZeddZfddZZS)rr]Fcst|ts|f}|s.|tur.td|jddtfdd|D}|ttfvrtdd|Dsxtd|jdt t |t |krtd|jd nt ||t |j t ||S) NzParameter list to z[...] cannot be emptyr'c3s|]}t|VqdSrrrrr]r^rryz,Generic.__class_getitem__..css|]}t|tVqdSr)rZrrr]r]r^rryzParameters to z [...] must all be type variablesz[...] must all be unique)rZr}rrcrnrrallrprrrr|ra)rrr]rr^__class_getitem__s&      zGeneric.__class_getitem__c stj|i|g}d|jvr,t|jv}nt|jvo>|jdk}|rLtdd|jvrt|j}d}|jD].}t |t rl|j turl|durtd|j }ql|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.r1c3s|]}|vrt|VqdSrr[rsgvarsetr]r^r ryz,Generic.__init_subclass__..css|]}t|VqdSrrF)rtgr]r]r^r ryzSome type variables (z) are not listed in Generic[r4)rrrrrE __bases__rprcr~rZrarbr|rr5r}) rrrrwerrorgvarsbasetvarsets_varss_argsr"rGr^rs<          zGeneric.__init_subclass__) rprmrnr _is_protocolrrDrr$r]r]r"r^rs  rc@s eZdZdS)r&Nrprmrnr]r]r]r^r&sr&c@s eZdZdS)r%NrRr]r]r]r^r%sr%)r|rErrQ_is_runtime_protocol) __abstractmethods____annotations__rrrrm__new__r__subclasshook__rrD_MutableMapping__markercCsrt}|jddD]X}|jdvr$qt|di}t|jt|D] }|dsJ|tvrJ| |qJq|S)Nr<)rrrU_abc_) r__mro__rprrrkeysr EXCLUDED_ATTRIBUTESadd)rattrsrM annotationsr r]r]r^_get_protocol_attrs)s  r`cstfddtDS)Nc3s|]}tt|dVqdSr)rerrtr rr]r^r<ryz,_is_callable_members_only..)rCr`rbr]rbr^_is_callable_members_only:srccOstt|}|jrtd|jtur$dS|jD]$}|jdt}|tur*||_qXq*tj|_|j|g|Ri|dS)Nz Protocols cannot be instantiatedr) rYrQrcr_no_init_or_replace_initrZrrobject)rrrrrMinitr]r]r^rd?s  rdc Cs4ztdjddvWSttfy.YdS0dS)Nrp)abcrT)rrrrrr]r]r]r^_allow_reckless_class_cheks]sri) r r'rrr)rr%rr+r.AbstractContextManagerAbstractAsyncContextManager)zcollections.abc contextlibcseZdZfddZZS) _ProtocolMetacsVtddrtr$tjr$dSjrJtfddtDrJdStS)NrQFTc3s8|]0}t|o.tt|d p.t|duVqdSr)hasattrrerrarinstancer]r^r}s z2_ProtocolMeta.__instancecheck__..) rrcrr#rQrCr`rrror"ror^rus  z_ProtocolMeta.__instancecheck__)rprmrnrr$r]r]r"r^rmrsrmcs(eZdZdZdZdZfddZZS)rr]TFcstj|i|jdds6tddjD_fdd}djvrR|_js\dSjD]F}|tt fvsb|j t vr|j t |j vsbt |t r|jsbtd|qbt_dS) NrQFcss|]}|tuVqdSr)r)rtrr]r]r^rryz-Protocol.__init_subclass__..csjddstStdds0tr(tStdtsJtrBtStdt|ts\tdt D]v}|j D]b}||jvr|j|durtSqdt|di}t|t j j rn||vrnt|trn|jrnqdqntSqddS) NrQFrSzLInstance and class checks can only be used with @runtime_checkable protocolsz._proto_hookrWz7Protocols can only inherit from other protocols, got %r)rrrranyrJrQrWrerrm_PROTO_WHITELISTrprrcrdr)rrrrrrMr"rbr^rs, &   zProtocol.__init_subclass__)rprmrnrrQrSrr$r]r]r"r^rsr) metaclasscsDeZdZfddZddZddZddZd d Zd d ZZ S) _AnnotatedAliascs2t|tr|j|}|j}t||||_dSr)rZrv __metadata__rbrr)rrmetadatar"r]r^rs   z_AnnotatedAlias.__init__cCs|d}t||jS)Nr)rvrw)rrnew_typer]r]r^rsz_AnnotatedAlias.copy_withcCs$dt|jddd|jDS)Nztyping.Annotated[{}, {}]r1css|]}t|VqdSr)rlrr]r]r^rryz+_AnnotatedAlias.__repr__..)formatrrrbr5rwrr]r]r^rsz_AnnotatedAlias.__repr__cCstjt|jf|jffSr)r7rrrbrwrr]r]r^rsz_AnnotatedAlias.__reduce__cCs&t|tstS|j|jko$|j|jkSr)rZrvrrbrwrr]r]r^rs    z_AnnotatedAlias.__eq__cCst|j|jfSr)rrbrwrr]r]r^r sz_AnnotatedAlias.__hash__) rprmrnrrrrrrr$r]r]r"r^rvs  rvc@s,eZdZdZddZeddZddZdS) rr]cOs tddS)Nz&Type Annotated cannot be instantiated.rrrrr]r]r^rV2szAnnotated.__new__cCsNt|trt|dkrtdd}t|d|dd}t|dd}t||S)Nr;zUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rTrUr)rZr}rrcrirv)rrrfrrxr]r]r^rD5s zAnnotated.__class_getitem__cOstd|jdS)NzCannot subclass {}.Annotated)rcrzrmr{r]r]r^r@s zAnnotated.__init_subclass__N)rprmrnrrVrrDrr]r]r]r^rs  rcCs&t|tr|jstd|d|_|S)NzB@runtime_checkable can be only applied to protocol classes, got %rT)rrrQrcrSrbr]r]r^rRFs rRcCs|Srr])typr!r]r]r^rH_srHc Csz |j}Wnty iYS0|j}|j}|d|}|jpBd}|j}|rVt|ni}|t|}t||d|D]\}} | ||<qx|S)Nr]) __code__r co_argcount co_varnames __defaults____kwdefaults__r*rr+) rr pos_count arg_namesdefaults kwdefaultsr pos_offsetrvaluer]r]r^ _get_defaultsjs       rc Cst|ddriSt|tri}t|jD]|}|durDtj|jj}n|}|j di}| D]D\}} | durvtd} t| t rt | ddd} t | ||} | ||<q^q(|r|Sdd| DS|durt|tjr|j}n"|} t| dr| j} qt| d i}|dur|}n|dur|}t|dd}|durRt|trDiStd |t|} t|}| D]t\}} | durtd} t| t rt | t|tj dd} t | ||} || vr| |durt| } | ||<qj|r|Sd d| DS) N__no_type_check__rUFT)rgrXcSsi|]\}}|t|qSr]_strip_annotationsrtkrur]r]r^ ryz"get_type_hints.. __wrapped__ __globals__z1{!r} is not a module, class, method, or function.cSsi|]\}}|t|qSr]rrr]r]r^rry)rrZrYreversedrZrrrmrritemsr[r rrk ModuleTypernr_allowed_typesrcrzrr*r) rqrrinclude_extrashintsrM base_globalsannrrnsobjrr]r]r^rLsf                   rLcCst|trt|jSt|trJtdd|jD}||jkr@|S||St|trtdd|jD}||jkrv|St|j|S|S)Ncss|]}t|VqdSrrrr]r]r^rryz%_strip_annotations..css|]}t|VqdSrrrr]r]r^rry) rZrvrrbrar}rrr)ru stripped_argsr]r]r^rs        rcCs2t|trtSt|ttfr"|jS|tur.tSdSr)rZrvrrrrbr)tpr]r]r^rKs rKcCsft|tr|jf|jSt|ttfrb|j}|jtjj ur^|dt ur^t |dd|df}|SdS)Nrr<r]) rZrvrbrwrarrrqrhr r=r)rrr]r]r^rJ s rJcCst|trt|j}|jD]"\}}||j|fvr||q|D](}t|tj r`d|_ t|trJt |qJz d|_ Wnt yYn0|S)NT) rZrYrcopyrrJpopvaluesrkrorrNrc)r\ arg_attrsr r!rqr]r]r^rNs         rNcstfdd}|S)Ncs|i|}t|}|Sr)rN)rrrrr]r^wrapped_decorator?sz2no_type_check_decorator..wrapped_decorator)rr)rrr]rr^rO8srOcOs tddS)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.)NotImplementedErrorrr]r]r^_overload_dummyHsrcCstSr)r)rr]r]r^rQQsrQcCs|Srr])fr]r]r^rInsrITKTVTT_co)rV_coVT_coT_contra)rCT_co)rrrGrrgr;aCallable 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. r)rr<rra@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;r8r=r>rr-r9r: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@s"eZdZdZeedddZdS)r4r]returncCsdSrr]rr]r]r^__int__szSupportsInt.__int__N)rprmrnrrintrr]r]r]r^r4sr4c@s"eZdZdZeedddZdS)r2r]rcCsdSrr]rr]r]r^ __float__szSupportsFloat.__float__N)rprmrnrrfloatrr]r]r]r^r2sr2c@s"eZdZdZeedddZdS)r1r]rcCsdSrr]rr]r]r^ __complex__ szSupportsComplex.__complex__N)rprmrnrrcomplexrr]r]r]r^r1sr1c@s"eZdZdZeedddZdS)r0r]rcCsdSrr]rr]r]r^ __bytes__szSupportsBytes.__bytes__N)rprmrnrrbytesrr]r]r]r^r0sr0c@s"eZdZdZeedddZdS)r3r]rcCsdSrr]rr]r]r^ __index__szSupportsIndex.__index__N)rprmrnrrrrr]r]r]r^r3sr3c@s"eZdZdZeedddZdS)r/r]rcCsdSrr]rr]r]r^__abs__'szSupportsAbs.__abs__N)rprmrnrrrrr]r]r]r^r/"sr/c@s&eZdZdZedeedddZdS)r5r]r)ndigitsrcCsdSrr])rrr]r]r^ __round__1szSupportsRound.__round__N)r)rprmrnrrrrrr]r]r]r^r5,sr5r]cCs@dd|D}dd|D}tj||||d}||_|j_|S)NcSsg|] \}}|qSr]r]rtnrur]r]r^rx7ryz!_make_nmtuple..cSs$i|]\}}|t|d|dqS)zfield z annotation must be a typerrr]r]r^r8sz!_make_nmtuple..rrW)rq namedtuplerUrV)rrkrWrfieldsnm_tplr]r]r^ _make_nmtuple6sr> rV_make__getnewargs___field_defaults_fieldsr_asdict_sourcer_replace>rUrprmc@seZdZddZdS)NamedTupleMetac sdi}g}|D]L}|vr,||q|rtd|dt|dkrJdnddd|qt||fd d |Dd d }D]<}|tvrtd |q|t vr||j vrt |||q|S)NrUzNon-default namedtuple field z cannot follow default fieldrs r1csg|] }|qSr]r])rtrnsr]r^rxWryz*NamedTupleMeta.__new__..rmrz&Cannot overwrite NamedTuple attribute ) rrzrcrr5rr _prohibitedr_specialrr ) rtypenamerrrk default_names field_namerkeyr]rr^rVJs*     zNamedTupleMeta.__new__N)rprmrnrVr]r]r]r^rHsrc Ks`|dur|}n |rtdztdjdd}WnttfyPd}Yn0t|||dS)NzIEither list of fields or keywords can be provided to NamedTuple, not bothrrprrW) rrcrrrrrrr)rrrrWr]r]r^r?bs  r?cCst|dkrtdtfS)Nrz5Multiple inheritance with NamedTuple is not supported)rrc _NamedTuplerr]r]r^_namedtuple_mro_entriess rc@s&eZdZdddZeZddZeZdS)_TypedDictMetaTc s|D]}t|turtdqtt|tf|i}|di}t|}dfdd|D}t} t} |D]@}| |j di| |j dd| |j ddqx| ||r| |n | ||_ t | _ t | _td s |_S) NzHcannot inherit from both a TypedDict type and a non-TypedDict base classrUz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecs"i|]\}}|t|jdqS)r)rirm)rtrrrftp_dictr]r^rsz*_TypedDictMeta.__new__..__required_keys__r]__optional_keys__ __total__)rYrrcrVr*rrr[rupdaterrUrBrrrnr) rrrrtotalrMr_own_annotationsown_annotation_keys required_keys optional_keysr]rr^rVs6           z_TypedDictMeta.__new__cCs tddS)Nz4TypedDict does not support instance and class checksr)rrr]r]r^rsz _TypedDictMeta.__subclasscheck__N)T)rprmrnrVr*rrrr]r]r]r^rs +rrc Ksj|dur|}n |rtddt|i}ztdjdd|d<WnttfyXYn0t|d||dS) Nz@TypedDict takes either a dict or keyword arguments, but not bothrUrrprrmr]r) rcr*rrrrrrr)rrrrrr]r]r^r@s* r@cCstfSr) _TypedDictrr]r]r^ryrcCsdd}||_||_|S)NcSs|Srr])r(r]r]r^ryszNewType..new_type)rp __supertype__)rrryr]r]r^rMsrMc@seZdZdZeeedddZeeedddZedddd Z eee dd d Z ee dd d Z eddddZee dddZed6e edddZee dddZed7e edddZed8e eedddZed9e e e dd d!Zee dd"d#Zee dd$d%Zed:e e d&d'd(Zee dd)d*Zeee d+d,d-Zeeedd.d/d0Zed1dd2d3Zeddd4d5ZdS);rCr]rcCsdSrr]rr]r]r^mode4szIO.modecCsdSrr]rr]r]r^r9szIO.nameNcCsdSrr]rr]r]r^close>szIO.closecCsdSrr]rr]r]r^closedBsz IO.closedcCsdSrr]rr]r]r^filenoGsz IO.filenocCsdSrr]rr]r]r^flushKszIO.flushcCsdSrr]rr]r]r^isattyOsz IO.isattyr<)rrcCsdSrr])rrr]r]r^readSszIO.readcCsdSrr]rr]r]r^readableWsz IO.readable)limitrcCsdSrr])rrr]r]r^readline[sz IO.readline)hintrcCsdSrr])rrr]r]r^ readlines_sz IO.readlinesr)offsetwhencercCsdSrr])rrrr]r]r^seekcszIO.seekcCsdSrr]rr]r]r^seekablegsz IO.seekablecCsdSrr]rr]r]r^tellkszIO.tell)sizercCsdSrr])rrr]r]r^truncateosz IO.truncatecCsdSrr]rr]r]r^writablessz IO.writablerrcCsdSrr]rrr]r]r^writewszIO.write)linesrcCsdSrr])rrr]r]r^ writelines{sz IO.writelinesz IO[AnyStr]cCsdSrr]rr]r]r^ __enter__sz IO.__enter__cCsdSrr])rrYr tracebackr]r]r^__exit__sz IO.__exit__)r<)r<)r<)r)N)rprmrnrpropertyrr[rrrrrrrrrrGrrrr;rrrrrrrrrrr]r]r]r^rC%sX rCc@s>eZdZdZeeeefedddZ eddddZ dS) rBr]rcCsdSrr]rr]r]r^rszBinaryIO.writercCsdSrr]rr]r]r^rszBinaryIO.__enter__N) rprmrnrrrr bytearrayrrrr]r]r]r^rBs rBc@seZdZdZeeedddZeeedddZ eee edddZ eee dd d Z eeedd d Zeddd dZdS)rFr]rcCsdSrr]rr]r]r^buffersz TextIO.buffercCsdSrr]rr]r]r^encodingszTextIO.encodingcCsdSrr]rr]r]r^errorssz TextIO.errorscCsdSrr]rr]r]r^line_bufferingszTextIO.line_bufferingcCsdSrr]rr]r]r^newlinesszTextIO.newlinescCsdSrr]rr]r]r^rszTextIO.__enter__N)rprmrnrrrrBrr[rrr rr r r rr]r]r]r^rFs$rFc@s eZdZgdZeZeZeZdS)io)rCrFrBN)rprmrn__all__rCrFrBr]r]r]r^r sr z.ioc@seZdZddgZeZeZdS)rerErDN)rprmrnr rErDr]r]r]r^rsrz.re)N)TN)N)NNF)r])N)N)rhrrrqcollections.abcrlrr7r stdlib_rerrkrrrrr r_rirrr~rrrrrrrBrrrrdrr rPr r rrrr rrrrar8r:r?rArrrrr&r%_TYPING_INTERNALS_SPECIAL_NAMESr\r`rcrdrirtrmrrvrrRrHrroBuiltinFunctionType MethodTyperrrLrrKrJrNrOrrQrIrrrrrrrrYrrr[rG_aliasrr'r*r)r(rrr.r%rr+r rr=rr#rr!r$r"rr}rrr;dequer8rr>r rrr&rjrrkr-r*r9 defaultdictr:r<r7r6rAr,rr4r2r1r0r3r/r5rrrrr?rVrrrrr@rrMrSrTrCrBrFr rprrErDr]r]r]r^sf` !         %  !ATFS&! Q  b)5  ]                    #59 c#