UiI*ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZe jdkrddlZgdZdZeZe jdkZdejjvZGddZeZe jd krd Znd ZejZejd Zejd Z ejdZ!ejddZ"ejddZ#e jdkrddlm$Z$nGddeZ%Gdde%Z$ej&Z&Gddej'dZ(Gddej(dZ)ej*Z*e jdkrej+Z+ndZ+e,ed rej-Z-nd!Z-d"Z.e jd#krej/Z/n7d$Z0d%Z1Gd&d'ej2dZ3Gd(d)e)dZ4e4d*+Z/ej5Z5e,ed,rej6Z6ej7Z7ej8Z8n-ej9ej:ej9e;ZZ>ej?Z?ej@Z@ejAZAejBZBejCZCejDZDejEZEejFZFejGZGejHZHe jdkr dd0lmIZImJZJmKZKmLZLnd1ZMGd2d3ejNdZNedZOeNejjLd4eOeOf5ZLeNejjJd6eOf5ZJeNejPd6d7ejQeRf8ZKeNejSd6d9ejQeRf8ZIgd:d;dZTeUejVhd?zZWd@ZXd dCZYe jdDkrejZZZnGd dEZ[dFZ\dGZ]GdHdIeejZZ^e_dJZ`GdKdLejae^ZZe jdDkrejbZbndMZbebZce jdNkr2ejdZdejeZeejfZfejgZgejhZhejiZiejjZjnebGdOdPeZZdebGdQdReZZeebGdSdTeZZfebGdUdVeZZgebGdWdXeZZhebGdYdZeZe"ZiebGd[d\eZe"Zje,ed]re,ed^rejkZkejlZln8ebGd_d]eZe"ZkebGd`d^eZe#Zle,eda p e,edb ZmemrGdcddeZne,edarejoZonGdedfenZpepZo[pe,edbrejqZqnGdgdhenZrerZq[remr[ndiZsesrejtZtejuZuejvZvnodjejwejxjyvZzdkZ{GdldmeZue|eudndoiZ}dpZ~Gdqdre(dZedsZtejueufZdtZve,edurejZndvZe,edwrejZndxZddyZedZOdzZdd{Ze jd krejZejZnd|Zd}Ze,ed~rejZn e)dZdZdZGddZGddeZerddlmZnGddeZe,edrejZejZn)GddZGddeZGddeZerddlmZn+e,edrGddeZnGddeeZe,eds+e,eds ddiddZnejZGddeZn'ejZe jdkrGddejdZGddZdZejdZe jdkrejZn e)dZe,edrejZn e)dZe,edrejZn e)dZe,edrejZnGdde)dZedZe,edrejZn e(dZe,edrejZn e(dZe,edrejZn e(dZe,edrejZejZne)dZe)dZe,edwrejZn e)dZdZe jdNkr ejZdZn3Gdde)dZGddej2dZedZdZdZerddlmZn*e,edrGddeZnGddeZe,edrejZndedefdZe,ed¦rejZndZe,edĦrejZndedefdƄZe jdNkrejZnhddidididodǜdeRdeRdeRdeRdejejej=ej$ejdej$ffdfdej$dejegeffdτZe,edЦrejZn,ejdejdej$fҦZdedefdӄZe jdkrejZnejdզZGdքdצZe jd krd؄ZndلZe,edsefdڄZndۄZesee_deRfd܄ZeeeddhZdeRfd݄Ze,edަr dd߄Zee_n dZesee_e jdDkrejZnNddZejZeUhdZGddeZe|eddoiZdZefdZee_e,ejd=r ejjZnRGdd=ejZeƠeɦeƠeʦeƠe˦e,e dre jZndZe jdkrejZn GddZe jdkrejZnLe jdNkrdZndZe jd kr"eUhdZGddej2dZGddZe,edrejZejZndedeRfdZdedejefdZe,edrejZn GddZee ddZe׀+ ddlZeeddZeف ee٦Zn #e$rYnwxYweׁeZede jdkr ddlmZmZn"GddejZdddiejddZe,edrejZn ddddddZdddddeUddZGddZe jdkrejZnd Zgd Zed eDejaZaejZejZdS(N)wAnyClassVar ConcatenateFinal LiteralString ParamSpec ParamSpecArgsParamSpecKwargsSelfTypeTypeVar TypeVarTupleUnpack Awaitable AsyncIterator AsyncIterable CoroutineAsyncGeneratorAsyncContextManagerBufferChainMapContextManagerCounterDeque DefaultDict NamedTuple OrderedDict TypedDict SupportsAbs SupportsBytesSupportsComplex SupportsFloat SupportsIndex SupportsInt SupportsRoundReaderWriter Annotated assert_never assert_typeclear_overloadsdataclass_transform deprecated disjoint_baseDocevaluate_forward_ref get_overloadsfinalFormatget_annotationsget_args get_originget_original_basesget_protocol_membersget_type_hintsIntVar is_protocol is_typeddictLiteralNewTypeoverloadoverrideProtocolSentinel reveal_typeruntimeruntime_checkableText TypeAlias TypeAliasTypeTypeForm TypeGuardTypeIs TYPE_CHECKING type_reprNeverNoReturnReadOnlyRequired NotRequired NoDefault NoExtraItems AbstractSetAnyStrBinaryIOCallable Collection ContainerDict ForwardRef FrozenSet GeneratorGenericHashableIO ItemsViewIterableIteratorKeysViewListMapping MappingViewMatchMutableMappingMutableSequence MutableSetOptionalPattern ReversibleSequenceSetSizedTextIOTupleUnion ValuesViewcast no_type_checkno_type_check_decoratorT)r rbeta__forward_is_class__ceZdZdZdS) _SentinelcdS)Nz selfs q/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/typing_extensions.py__repr__z_Sentinel.__repr__s|N__name__ __module__ __qualname__rrrrrrs#rrr cdt|tjtjtjfSN) isinstancetyping _GenericAlias_types GenericAlias UnionTypets r_should_collect_from_parametersrs) $f&96;KL   rcNt|tjtjfSr)rrrrrrs rrrs!f2F4GHIIIrTKTVTT_co) covariantT_contra) contravariantr )rc(eZdZfdZfdZxZS)_AnyMetacv|turtdt|S)Nz6typing_extensions.Any cannot be used with isinstance())r TypeErrorsuper__instancecheck__)robj __class__s rrz_AnyMeta.__instancecheck__s3s{{ XYYY77,,S11 1rcZ|turdStS)Nztyping_extensions.Any)rrr)rrs rrz_AnyMeta.__repr__s(s{{..77##%% %r)rrrrr __classcell__rs@rrrsQ 2 2 2 2 2  & & & & & & & & &rrc"eZdZdZfdZxZS)raqSpecial 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 checks. cn|turtdtj|g|Ri|S)NzAny cannot be instantiated)rrr__new__clsargskwargsrs rrz Any.__new__sAczz <==="577?3888888 8r)rrr__doc__rrrs@rrrsB   9 9 9 9 9 9 9 9 9rr) metaclasscneZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ejd Zd S) _SpecialForm)_namer_getitemcD||_|j|_|j|_dSr)rrrr)rgetitems r__init__z_SpecialForm.__init__s  %  rc6|dvr|jSt|)N>rr)rAttributeError)ritems r __getattr__z_SpecialForm.__getattr__s$ / / /: T"""rc&td|)NzCannot subclass rrbasess r__mro_entries__z_SpecialForm.__mro_entries__s3433444rcd|jSNztyping_extensions.rrs rrz_SpecialForm.__repr__s0DJ000rc|jSrrrs r __reduce__z_SpecialForm.__reduce__ zrc&td|)NzCannot instantiate rrrkwdss r__call__z_SpecialForm.__call__s6d66777rc*tj||fSrrrxrothers r__or__z_SpecialForm.__or__s|D%K((rc*tj||fSrrrs r__ror__z_SpecialForm.__ror__s|E4K((rc&t|d)Nz! cannot be used with isinstance()rrrs rrz_SpecialForm.__instancecheck__ 4BBBCCCrc&t|d)Nz! cannot be used with issubclass()r)rrs r__subclasscheck__z_SpecialForm.__subclasscheck__ rrc.|||Sr)rr parameterss r __getitem__z_SpecialForm.__getitem__s}}T:...rN)rrr __slots__rrrrrrrrrrr _tp_cacherrrrrrs0I''' ### 555111888))))))DDDDDD /////rr)_rootceZdZdZdS)_ExtensionsSpecialFormcd|jzSrrrs rrz_ExtensionsSpecialForm.__repr__s#dj00rNrrrrrrs#11111rrcF d|_n#ttf$rYnwxYw|S)aThis decorator can be used to indicate to type checkers that the decorated method cannot be overridden, and decorated class cannot be subclassed. For example: class Base: @final def done(self) -> None: ... class Sub(Base): def done(self) -> None: # Error reported by type checker ... @final class Leaf: ... class Other(Leaf): # Error reported by type checker ... There is no runtime checking of these properties. The decorator sets the ``__final__`` attribute to ``True`` on the decorated object to allow runtime introspection. T) __final__rr)fs rr5r5%s>, AKK *    D     r1cd|_|S)a<This decorator marks a class as a disjoint base. Child classes of a disjoint base cannot inherit from other disjoint bases that are not parent classes of the disjoint base. For example: @disjoint_base class Disjoint1: pass @disjoint_base class Disjoint2: pass class Disjoint3(Disjoint1, Disjoint2): pass # Type checker error Type checkers can use knowledge of disjoint bases to detect unreachable code and determine when two types can overlap. See PEP 800.T)__disjoint_base__rs rr1r1Hs(!% rc*tj|Sr)rr)names rr=r=`s >$  r)rrcg}|D]G}t|tr||j2||Ht |S)zJAn internal helper for Literal creation: flatten Literals among parameters)r_LiteralGenericAliasextend__args__appendtuple)rparamsps r_flatten_literal_paramsrisa ! !A!122 ! aj)))) a    V}}rc#:K|D]}|t|fVdSr)type)rrs r_value_and_type_iterrss8  AT!WW*      rceZdZdZdZdS)rct|tstStt |j}tt |j}||kSr)rrNotImplementedsetrr)rrthese_args_dedupedother_args_dedupeds r__eq__z_LiteralGenericAlias.__eq__xsYe%9:: &%%!$%9$-%H%H!I!I !$%9%.%I%I!J!J %);; ;rc^ttt|jSr)hash frozensetrrrs r__hash__z_LiteralGenericAlias.__hash__s# "6t}"E"EFFGG GrN)rrrrrrrrrrws7 < < < H H H H Hrrc eZdZdefdZdZdS) _LiteralFormdocc0d|_|x|_|_dS)Nr@)r_docr)rr s rrz_LiteralForm.__init__s"DJ'* *DI rct|ts|f}t|}tt |} t |}t |t |krVg}|D]6}||vr0||d||7|r J|t|}n#t$rYnwxYwt||S)Nr) rrrlistrrlenrremoverr)rrval_type_pairs deduped_pairsnew_parameterspairs rrz_LiteralForm.__getitem__sj%00 +(] 0< + + + + + : : : : :rr a A type that can be used to indicate to type checkers that the corresponding value has a value literally equivalent to the provided parameter. For example: var: Literal[4] = 4 The type checker understands that 'var' is literally equal to the value 4 and no other value. Literal[...] cannot be subclassed. There is no runtime checking verifying that the parameter is actually a value instead of a type.)r r4ct|d|} |t|j|j|jj<n#t $rYnwxYwtS)aDecorator 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 The overloads for a function can be retrieved at runtime using the get_overloads() function. __func__)getattr_overload_registryrr__code__co_firstlinenor_overload_dummy)funcrs rrBrBsn< D*d + +  q| ,Q^ < )      D s*> A  A ct|d|}|jtvrgSt|j}|j|vrgSt ||jS)z6Return all defined overloads for *func* as a sequence.r)rrrrrvalues)rrmod_dicts rr4r4sg D*d + + <1 1 1I%al3 > ) )IHQ^,3355666rc8tdS)z$Clear all overloads in the registry.N)rclearrrrr.r.s  """""r)rrrracV|do|dS)N__) startswithendswith)attrs r _is_dunderr) s%t$$<t)<)<_instr_nparamsr/)r)object __setattr__setattr __origin__)rr(val allowed_attrss rr6z _SpecialGenericAlias.__setattr__s_GGGM$ 44=#8#8""4s33333s33333rc t|ts|f}dtfd|D}|jrnt||jkrVt|t|jz|jkr)g||jt||jz dR}t|}||jkr||jr d|jt|jz }nt |j}|jst |dt d||jkrdndd|d |d |||S) Nz*Parameters to generic types must be types.c3BK|]}tj|VdSrr _type_check.0rmsgs r z3_SpecialGenericAlias.__getitem__..s0FF!6-a55FFFFFFr at least  is not a generic classToo manyfew arguments for ; actual , expected )rrr/rr4rr copy_with)rr actual_lenexpectedrAs @rrz _SpecialGenericAlias.__getitem__sfe,, # >CFFFFvFFFFFF RKK$-//KK#dn"5"55FFQ6QDN3v;;3N3O3O$PQQVJT]**>2P4=3t~;N;N+NPPHH"4=11H}F#t$D$D$DEEEAZ$-%?%?66UAA&*AA)AA6>AA >>&)) )r) rrrrr6rrrrrs@rr+r+sw48tb & & & & & & & 4 4 4   * *   * * * * *rr+r)r-r)rr-r) r[rrfrgrrcrur]r\rrrAbstractContextManagerAbstractAsyncContextManagerr)zcollections.abc contextlibtyping_extensions>r__match_args____protocol_attrs____non_callable_proto_members__ct}|jddD]_}|jdvr t|di}g|j|RD]5}|ds|t vr||6`|S)N>rbrD__annotations___abc_)r__mro__rr__dict__r&_EXCLUDED_ATTRSadd)rattrsbase annotationsr(s r_get_protocol_attrsra[s EEE CRC    =3 3 3 d$5r:: 2dm2k22  DOOG,, _1L1L $  Lrr__main__c tj|dzp|S#t$rYnwxYw tj|dzjd|S#tt f$rYnwxYwdS)Nrr)sys_getframemodulenamer _getframe f_globalsget ValueError)depthdefaults r_callerrlgs &uqy11Nabc functools)rlrjs r_allow_reckless_class_checksrrys u~~!;;;rcLt|jrtddS)Nz Protocols cannot be instantiated)r _is_protocolrrrrs r_no_initrvs/ :: " @>?? ? @ @rcNt|tstddS)aRaise TypeError if `arg` is not an instance of `type` in `issubclass(arg, )`. In most cases, this is verified by type.__subclasscheck__. Checking it again unnecessarily would slow down issubclass() checks, so, we don't perform this check unless we absolutely have to. For various error paths, however, we want to ensure that *this* error message is shown to the user where relevant, rather than a typing.py-specific error message. z"issubclass() arg 1 must be a classN)rrrargs r_type_check_issubclass_arg_1rzs2#t$$ B@AA A B Brc8eZdZdZdZdZdZdZdefdZ dS) _ProtocolMetac |dkrt|dkrnttjht|zrs|D]p}|ttjttjhvsH|jt|j gvs!t|std|qtj j||||fi|S)NrDrNz5Protocols can only inherit from other protocols, got )rrDrrr5rbr_PROTO_ALLOWLISTrhrr>rroABCMetar)mclsrr namespacerr_s rrz_ProtocolMeta.__new__sz!!c%jj1nnFO,s5zz9 !  D6? SSS=,<,@,@RT,U,UUU&t,,V(,#',,;&tT5)NNvNN Nrctjj|g|Ri|t|ddrt ||_dSdS)NrtF)rorrrrarTrrrs rrz_ProtocolMeta.__init__s\ K  6t 6 6 6v 6 6 6sNE22 B))rrr(r_r`s rrrs|66 "! !* & &D  & &4=((}T*2------E&d,=rBB {KO,CDD ++#E**,E%%%%trcBeZdZejjZdZdZdZfdZ xZ S)rDrTFc4tj|i||jdds#t d|jD|_d|jvr t|_|jr!|j tj urt|_ dSdSdS)NrtFc3(K|] }|tuVdSr)rDr@bs rrBz-Protocol.__init_subclass__..s&&L&LqH}&L&L&L&L&L&Lrr) r__init_subclass__r[rhany __bases__rtrrrrDrvrs rrzProtocol.__init_subclass__s %EGG %t 6v 6 6 6<##NE:: M#&&L&Lcm&L&L&L#L#L "55'2$ (CLH4E$E$E'  ( ($E$Er) rrrrrDrrrtrrrrs@rrDrDsR/)  $ ( ( ( ( ( ( ( ( (rrDct|tjrt|ddst d|d|_t |tstj dkr~t|_ |j D]c} tt||d}|s|j |>#t$r}t d|d|d}~wwxYw|S) ajMark a protocol class as a runtime protocol. Such protocol can be used with isinstance() and issubclass(). Raise TypeError if applied to a non-protocol class. This allows a simple-minded structural check very similar to one trick ponies in collections.abc such as Iterable. For example:: @runtime_checkable class Closable(Protocol): def close(self): ... assert isinstance(open('/some/file'), Closable) Warning: this will check only the presence of the required methods, not their type signatures! rtFz@@runtime_checkable can be only applied to protocol classes, got T)r rNNz,Failed to determine whether protocol member z is a method member) issubclassrrbrrrrr|rd version_inforrUrTcallabler] Exception)rr( is_callablees rrHrH.s3&#v~.. -gc>SX6Y6Y -,$',,-- -#'  c= ) ) ES-=-K-K 25C .. E E E"*73d+C+C"D"DK'E:>>tDDD!#-t--- sC C% C  C%rrc<eZdZdZdZejdefdZdS)r'z(An ABC with one abstract method __int__.rrcdSrrrs r__int__zSupportsInt.__int__v DrN) rrrrrroabstractmethodrrrrrr'r'qsH66  S        rr'c<eZdZdZdZejdefdZdS)r%z*An ABC with one abstract method __float__.rrcdSrrrs r __float__zSupportsFloat.__float__rrN) rrrrrrorfloatrrrrr%r%zH88  u        rr%c<eZdZdZdZejdefdZdS)r$z,An ABC with one abstract method __complex__.rrcdSrrrs r __complex__zSupportsComplex.__complex__rrN) rrrrrrorcomplexrrrrr$r$sH::          rr$c<eZdZdZdZejdefdZdS)r#z*An ABC with one abstract method __bytes__.rrcdSrrrs r __bytes__zSupportsBytes.__bytes__rrN) rrrrrrorbytesrrrrr#r#rrr#c8eZdZdZejdefdZdS)r&rrcdSrrrs r __index__zSupportsIndex.__index__rrN)rrrrrorrrrrrr&r&sB  s        rr&c<eZdZdZdZejdefdZdS)r"z_ An ABC with one abstract method __abs__ that is covariant in its return type. rrcdSrrrs r__abs__zSupportsAbs.__abs__rrN) rrrrrrorrrrrrr"r"sN    T        rr"cBeZdZdZdZejddedefdZ dS) r(za An ABC with one abstract method __round__ that is covariant in its return type. rrndigitsrcdSrr)rrs r __round__zSupportsRound.__round__rrNr) rrrrrrorrrrrrrr(r(sZ     S         rr(r)r*cBeZdZdZdZejddedefdZ dS) r)zeProtocol for simple I/O reader instances. This protocol only supports blocking I/O. r.sizercdS)zRead data from the input stream and return it. If *size* is specified, at most *size* items (bytes/characters) will be read. Nr)rrs rreadz Reader.readrN).) rrrrrrorrrrrrrr)r)sZ     S d        rc@eZdZdZdZejdedefdZ dS)r*zeProtocol for simple I/O writer instances. This protocol only supports blocking I/O. rdatarcdS)zIWrite *data* to the output stream and return the number of items written.Nr)rrs rwritez Writer.writerrN) rrrrrrorrrrrrrr*r*s]    \h \c \ \ \   \ \ \rrVrWceZdZdZdS) SingletonMetac6td|d|j)Nz cannot set z attribute of immutable type rr)rr(values rr6zSingletonMeta.__setattr__s)SdSS3<SS rN)rrrr6rrrrrs#     rrc(eZdZdZdZdZdZdZdS) NoDefaultTypez$The type of the NoDefault singleton.rcxtdpt|SNrVglobalsrhr5rrs rrzNoDefaultType.__new__s)99==--D1D1D DrcdS)Nztyping_extensions.NoDefaultrrs rrzNoDefaultType.__repr__s00rcdSrrrs rrzNoDefaultType.__reduce__s;rNrrrrrrrrrrrrrsO22  E E E 1 1 1     rrc(eZdZdZdZdZdZdZdS)NoExtraItemsTypez'The type of the NoExtraItems singleton.rcxtdpt|SNrWrrs rrzNoExtraItemsType.__new__s)99==00GFNN34G4G GrcdS)Nztyping_extensions.NoExtraItemsrrs rrzNoExtraItemsType.__repr__s33rcdSrrrs rrzNoExtraItemsType.__reduce__s!>rNrrrrrrsO55  H H H 4 4 4 " " " " "rrFmodulec#NK t|}|turt|}|r |d}npdS|turtVt|\}nJ|turtVt|\}n&|t urt Vt|\}ndS)NTr)r9r+r8rTrUrS)annotation_typeannotation_originannotation_argss r_get_typeddict_qualifiersr&s  *? ; ;  I--"*?";";"&5a&8OOE"h..#+O#<#< "k11!!!!#+O#<#< "h..#+O#<#< % rc,eZdZddeddZeZdZeZdS)_TypedDictMetaTNtotalclosed extra_itemsc D]5}t|tur|tjurt d6||t urt d|dt dDrtjf}nd}|dd} ttdg|tR||_ j dkr|_ td s_ i} d| | nxtjd krftt d rt!j|n|d "t!jt(j ninidt,r"fdDn fdDt1} t1} t1} t1}|}D]}|j}tjd kr)| |di| |dd| |dd| |dd||dd|rwtjd krgdvrcd}t1t7|}t8|vrt dt:|vrt d|}| D]\}}t1t7|}t8|vr| |nLt:|vr| |n-|r| |n| |t>|vr+| || |||| |tjd krfd}|_!n| _"tG| _$tG| _%tG| _&tG|_'|_(|_)|_*S)aICreate new typed dict class object. This method is called when TypedDict is subclassed, or when TypedDict is instantiated. This way TypedDict supports all three syntax forms described in its docstring. Subclasses and instances of TypedDict return actual dictionaries. zHcannot inherit from both a TypedDict type and a non-TypedDict base classNzCannot combine closed=z and extra_itemsc3JK|]}t|tjVdSr)rrrbrs rrBz)_TypedDictMeta.__new__..Ms.@@Q:a00@@@@@@rrrXrD__orig_bases__r!get_annotate_from_class_namespace __annotate__ownerz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecPi|]"\}}|tj|j#Srrr>rr@ntprAtp_dicts r z*_TypedDictMeta.__new__..rsD+++2v)"c':LMMM+++rcBi|]\}}|tj|Srr=)r@rrrAs rrz*_TypedDictMeta.__new__..ws<+++2v)"c22+++r__required_keys____optional_keys____readonly_keys____mutable_keys____extra_items__z5Special key __extra_items__ does not support Requiredz8Special key __extra_items__ does not support NotRequiredci}D]B}|tur |j}|tj|||}||CItj| }|t jkr! fd|D}nQ|t jkrtj }n,|t j t j fvr }nt||||S)NrcPi|]"\}}|tj|j#Srrrs rrz@_TypedDictMeta.__new__..__annotate__..sD###$)Ar!"6#5b#gFX#Y#Y#Y###r) rbr annotationlibcall_annotate_functionupdater6STRINGitemsannotations_to_string FORWARDREFVALUENotImplementedError) formatannosr_ base_annotate base_annosownrrA own_annotateown_annotationsown_checked_annotationsrs rrz,_TypedDictMeta.__new__..__annotate__s3E %117??$(,(9 (0$%2%I)6&?&?&?  Z0000#/+B(&AAA!V]22#####-0YY[[###C 6=00+A/RRF$5v|#DDD51&999LL%%% Lr)+rrrrbrrWrpoprdictrrhasattrrrdrrrrhrr6r  _TAKES_MODULEr rr[rrrTrUr]rSdiscardrrXrrrrr __total__ __closed__r)rrrnsrrrr_ generic_basens_annotationsr` required_keys optional_keys readonly_keys mutable_keysextra_items_type base_dictr qualifiersannotation_keyrrArrrrs ` @@@@@rrz_TypedDictMeta.__new__=s F F::^33FN8R8R#%EFFF!k&E&E S S S STTT@@%@@@@@ " &0 ! VV$5t<:?T?Tt?T?TVXYYG#G #z11'+$7$455 /).&KL)"0!W,,=*MNN:#0#RSU#V#VLL$&66.#9#9L+&3&J$f&7w'''OO')OO"$SC +++++!0!6!6!8!8+++'' ++++!0!6!6!8!8+++' EEMEEMEEM55L*  K K M #w..&&y}}5F'K'KLLL$$Y]]3F%K%KLLL$$Y]]3F%K%KLLL$$Y]]3F%K%KLLL##IMM2Db$I$IJJJJ  33+g55,0GGG"9"="=>O"P"P !:?!K!KLL z))##*,,#&$3   6 7 7 73J3P3P3R3R : :/ !:?!K!KLL z))!%%n5555 J..!%%n55556!%%n5555!%%n555z)) ((888!%%n5555 $$^444!)).99997**!!!!!!!!!!8(4$$*5'(1-(@(@G %(1-(@(@G %(1-(@(@G %'0'>'>G $ %G !'G &6G #Nrc td)Nz4TypedDict does not support instance and class checksrrs rrz _TypedDictMeta.__subclasscheck__sRSS Sr) rrrrWrrrrrrrrrr;sX37 ,\ \ \ \ \ | T T T.rrr!rc "|tus|g|turd}nd}d|d|d}|d|zdz} tj| td |d ur |d ur |||d <d}|tur ||d <t}|}n|rt d|r;t jdkrt dtjdtd dt|i} t|rdnd} | | | d<t|d| |||} tf| _ | S)N2Failing to pass a value for the 'fields' parameter(Passing `None` as the 'fields' parameter`z = TypedDict(z, {})`z is deprecated and will be disallowed in Python 3.15. To create a TypedDict class with 0 fields using the functional syntax, pass an empty dictionary, e.g. rrN stacklevelFTrrz@TypedDict takes either a dict or keyword arguments, but not bothrmz$TypedDict takes no keyword argumentszThe kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.rXrqrrr) _markerwarningswarnDeprecationWarningrWrrdrrrlrr!r) typenamefieldstyping_is_inlinerrrrdeprecated_thingexampledeprecation_msgrrtds r_create_typeddictr<s W    H! $N E(EEEEEG#OOO  O M/+=! L L L LU""vT'9'9f>P#)x ,..(3}%* FF  -,-- -  7** FGGG M;#      f .$4;qq!<<<   &B|  Hb"E&(3555&L rc(eZdZefddeddZdZdS)_TypedDictSpecialFormTNrc (t||fd|||d|S)NFr7rrr)r<)rr5r6rrrrs rrz_TypedDictSpecialForm.__call__$s>%"''  rctfSr) _TypedDictrs rrz%_TypedDictSpecialForm.__mro_entries__9s = r)rrrr1rWrrrrrr>r>#sQ  $     * ! ! ! ! !rr>c~t|tstdtd|dddtS)aqA simple typed namespace. At runtime it is equivalent to a plain dict. TypedDict creates a dictionary type such that a type checker will expect all instances to have a certain set of keys, where each key is associated with a value of a consistent type. This expectation is not checked at runtime. Usage:: class Point2D(TypedDict): x: int y: int label: str a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') The type info can be accessed via the Point2D.__annotations__ dict, and the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets. TypedDict supports an additional equivalent form:: Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) By default, all keys must be present in a TypedDict. It is possible to override this by specifying totality:: class Point2D(TypedDict, total=False): x: int y: int This means that a Point2D TypedDict can have any of the keys omitted. A type checker is only expected to support a literal False or True as the value of the total argument. True is the default, and makes all items defined in the class body be required. The Required and NotRequired special forms can also be used to mark individual keys as being required or not required:: class Point2D(TypedDict): x: int # the "x" key must always be present (Required is the default) y: NotRequired[int] # the "y" key can be omitted See PEP 655 for more details on Required and NotRequired. z9TypedDict[...] should be used with a single dict argumentzTr@)rrrr<rW)rrs rr!r!<sWb$%% K ! !$     rc,t|tS)aCheck if an annotation is a TypedDict class For example:: class Film(TypedDict): title: str year: int is_typeddict(Film) # => True is_typeddict(Union[list, str]) # => False )r_TYPEDDICT_TYPESrs rr?r?}s".///rr-c|S)aAssert (to the type checker) that the value is of the given type. When the type checker encounters a call to assert_type(), it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # ok assert_type(name, int) # type checker error At runtime this returns the first argument unchanged and otherwise does nothing. r)r9typs rr-r-s  rrSczt|tjrt|jSt |dr5|jt ttfvrt|j dSt|tj r@td|j D}||j kr|S| |St tdr_t|tjrEtd|j D}||j kr|Stj|j|St tdrdt|tjrJtd|j D}||j kr|St!jt$j|S|S)z=Strips Annotated, Required and NotRequired from a given type.r8rc34K|]}t|VdSr _strip_extrasr@as rrBz _strip_extras..*!G!Gq-"2"2!G!G!G!G!G!Grrc34K|]}t|VdSrrKrMs rrBz _strip_extras..rOrrc34K|]}t|VdSrrKrMs rrBz _strip_extras..rOr)rr_AnnotatedAliasrLr8rrTrUrSrrrrKrrrrpreduceoperatoror_)r stripped_argss rrLrLs a/ 0 0 / .. . 1l # # 0 ;PX8Y(Y(Y A// / a- . . .!!G!GAJ!G!G!GGGM **;;}-- - 6> * * Dz!V=P/Q/Q D!!G!GAJ!G!G!GGGM **&q|]CC C 6; ' ' AJq&:J,K,K A!!G!GAJ!G!G!GGGM **#HL-@@ @rctj|||d}tjdkrt |||||r|Sd|DS)aReturn type hints for an object. This is often the same as obj.__annotations__, but it handles forward references encoded as string literals, adds Optional[t] if a default value equal to None is set and recursively replaces all 'Annotated[T, ...]', 'Required[T]' or 'NotRequired[T]' with 'T' (unless 'include_extras=True'). 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. T)globalnslocalnsinclude_extrasrc4i|]\}}|t|SrrK)r@krs rrz"get_type_hints..s&===1=##===r)rr<rdr_clean_optionalr )rrXrYrZhints rr<r<sr@$ (GD     g % % Cx 9 9 9  K== ====rcjt|tjsdS|jdturdSdS)z detects Union[..., None] patternFrWT)rr_UnionGenericAliasr _NoneTypers r_could_be_inserted_optionalrbs7!V677 5 :b> * *5trc(|rt|trdStj|}|sdS|j}|D]C\}}t |r ||vs||"||}|t}t|tr|at|tj r|j }n:|} t| dr| j } t| dt| di}||}n||}t|t|tj  }tj|||} | |ksIttdr9t| tjrt|tjs| ||<EdS)N __wrapped__ __globals__) is_argumentr)rrr _get_defaultsrXr rbrarr ModuleTyper[rrdrr_ _eval_typer) rhintsrXrYr-original_hintsrroriginal_valuensobjoriginal_evaluateds rr]r]s  3--  F',,  F, ;;==( 1( 1KD%/66 x''D>-+D1N%!*.#.. #!#v'899E#&< #%e];;6$)$5E&e];;6#*5-#D#D"*_&G!+"$.sF4E$F$F F""""(!2>8W!U!U "U** ,,+163CDD+#5&*:;; + 1d Q( 1( 1rct|tjrtSt|tjt jttfr|j S|tj ur tj SdS)a6Get the unsubscripted version of a type. This supports generic types, Callable, Tuple, Union, Literal, Final, ClassVar and Annotated. Return None for unsupported types. Examples:: get_origin(Literal[42]) is Literal get_origin(int) is None get_origin(ClassVar[int]) is ClassVar get_origin(Generic) is Generic get_origin(Generic[T]) is Generic get_origin(Union[T, int]) is Union get_origin(List[Tuple[T, T]][int]) == list get_origin(P.args) is P N) rrrRr+_BaseGenericAliasrrr r r8rbrFs rr9r9-si b&0 1 1   b63V5H(/; < < !=   > !trcTt|tjr|jg|jRSt|tjt jfrW|j}t|tj j ur.|dturt|dd|df}|SdS)aGet type arguments with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. Examples:: get_args(Dict[str, int]) == (str, int) get_args(int) == () get_args(Union[int, Union[T, int], str][int]) == (int, str) get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int]) get_args(Callable[[], T][int]) == ([], int) rNrWr)rrrRr8 __metadata__rrrrr9rror[Ellipsisr)rress rr8r8Es b&0 1 1 5M4BO44 4 b6/1DE F F +C"~~!999c!fH>T>TCH~~s2w/JrrrJc&t|d)a&Special marker indicating that an assignment should be recognized as a proper type alias definition by type checkers. For example:: Predicate: TypeAlias = Callable[..., bool] It's invalid when used anywhere except as in the example above.  is not subscriptablerrs rrJrJ_s4666777rc*fd|_|_dS)NctuSr)rVrksrz_set_default..os WI%=r) has_default __default__) type_paramrks `r _set_defaultr~ns"====J$JrcDtd}|dkr ||_dSdS)NrNrqrR)rlr) typevarlikedef_mods r _set_modulerss4AG%%%!( &%rceZdZdZdZeZdS) _DefaultMixinzMixin for TypeVarLike defaults.rN)rrrrrr~rrrrrrzs))IHHHrrceZdZdedefdZdS)_TypeVarLikeMeta_TypeVarLikeMeta__instancerc,t||jSr)r_backported_typevarlike)rrs rrz"_TypeVarLikeMeta.__instancecheck__s*c&ABBBrN)rrrrboolrrrrrrs>C3C4CCCCCCrr)rc<eZdZdZejZdddedddZddZ dS) rzType variable.NF)boundrrrkinfer_variancec  ttdrtj|g|R||||d n3tj|g|R|||d |r|s|rtd| _t |t  fd}| _ S)NrKrrrrrrrz1Variance cannot be specified with infer_variance.cr6|jt|kr |jfz }|Sr)r{__parameters__indexrr|)aliasrtypevars r_tvar_prepare_substz,TypeVar.__new__.._tvar_prepare_substsN''))3,227;;s4yyHHW022D r)rrrri__infer_variance__r~r__typing_prepare_subst__) rrrrrrkr constraintsrrs @rrzTypeVar.__new__sv// < .H HH53._paramspec_prepare_substs-LL++D >>i&;&;&=&=>9T99#89DD >>#$DU$D$DEEEv;;!##F,A$q',J,J#6666 7DDQ..FET"1"XEuT!W~~EQUVV EED r)rrr rr~rr) rrrrrrrkrrs @rrzParamSpec.__new__sv// >",T7@;H , G , , ,  " " "      2JI . rrc2tdtd)Nrz*.ParamSpec' is not an acceptable base typerrs rrzParamSpec.__init_subclass__!sYXYYYZZ Zrr) rrrrrr rrVrrrrrr r sd&&"("2(,#5#()# # # # # J [ [ [ [ [ [rc~eZdZdZejZedZedZ dddde ddZ dZ d Z d Zd Zd ZdS) r a'Parameter specification variable. Usage:: P = ParamSpec('P') Parameter specification variables exist primarily for the benefit of static type checkers. They are used to forward the parameter types of one callable to another callable, a pattern commonly found in higher order functions and decorators. They are only valid when used in ``Concatenate``, or s the first argument to ``Callable``. In Python 3.10 and higher, they are also supported in user-defined Generics at runtime. See class Generic for more information on generic types. An example for annotating a decorator:: T = TypeVar('T') P = ParamSpec('P') def add_logging(f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner @add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y Parameter specification variables defined with covariant=True or contravariant=True can be used to declare covariant or contravariant generic types. These keyword arguments are valid, but their actual semantics are yet to be decided. See PEP 612 for details. Parameter specification variables can be introspected. e.g.: P.__name__ == 'T' P.__bound__ == None P.__covariant__ == False P.__contravariant__ == False Note that only parameter specification variables defined in global scope can be pickled. c t|Sr)r rs rrzParamSpec.argsZs && &rc t|Sr)r rs rrzParamSpec.kwargs^s"4(( (rNFrc|t||g||_t||_t||_t||_|rtj|d|_ nd|_ t||t}|dkr ||_ dSdS)NzBound must be a type.rR) rrrr __covariant____contravariant__rrr> __bound__rrlr)rrrrrrrkrs rrzParamSpec.__init__bs MM$ ' ' ' DM!%iD %)-%8%8D "&*>&:&:D # &!'!3E;R!S!S!%  " "4 1 1 1iiG---").-rcV|jrd}n|jrd}n |jrd}nd}||jzS)N+-~)rrrr)rprefixs rrzParamSpec.__repr__tsJ& # ' DM) )rc6t|Srr5rrs rrzParamSpec.__hash__??4(( (rc ||uSrrrs rrzParamSpec.__eq__ 5= rc|jSrrrs rrzParamSpec.__reduce__ = rcdSrrrus rrzParamSpec.__call__ Dr)rrrrrrrpropertyrrrVrrrrrrrrrr r (s, , ^N  ' '  '  ) )  )+/%u$)9 * * * * *$ * * * ) ) ) ! ! ! ! ! !     rr _type_convert)allow_special_formsc|tdSt|trRtjdkrt |Stjdkrt ||St |||S|S)z=For converting None to type(None), and strings to ForwardRef.N)r )rrr)ris_class)rrrrdrr_)ryrrs rrrs|{Dzz!#s## T#y00%c??*#y00%c&9999!#f?RSSSSJrc`eZdZejZfdZdZdZdZ e dZ dZ dZ xZS)_ConcatenateGenericAliascft|||_||_dSr)rrr8r)rr0rrs rrz!_ConcatenateGenericAlias.__init__s- GG  T " " "$DO DMMMrctj|jddfd|jDdS)N[, c3.K|]}|VdSrr)r@ry _type_reprs rrBz4_ConcatenateGenericAlias.__repr__..s+!K!Kc**S//!K!K!K!K!K!Kr])rrr8joinr)rrs @rrz!_ConcatenateGenericAlias.__repr__sd*J!z$/22OO !K!K!K!KT]!K!K!KKKOOO Prc8t|j|jfSr)rr8rrs rrz!_ConcatenateGenericAlias.__hash__s$-899 9rcdSrrrus rrz!_ConcatenateGenericAlias.__call__rrc>td|jDS)Nc3\K|]'}t|tjtf#|V(dSr)rrrr )r@rs rrBz:_ConcatenateGenericAlias.__parameters__..sLjfni=X.Y.Yr)rrrs rrz'_ConcatenateGenericAlias.__parameters__s2!] rczt|dtrg|dd|djR}nkt|dttfrg|dd|dRS|ddus*t|dt st d||j|SNrW.MThe last parameter to Concatenate should be a ParamSpec variable or ellipsis.) rrrrrr rrr8rrs rrKz"_ConcatenateGenericAlias.copy_withs&*&>?? ;=6#2#;=)<==F2Ju 66 ;22vbz222bzS((Jvbz9,M,M(!:;;;>>$/6:: :rc H |jttfvrtd||jst|dt |t s|f}td|D}|j}|D]G}t|dd}| |||}#t |tr| |}|t|kr(t|dttur g||j }|t|krtd|t|dkr!t|ds |dksJ|f}t ||trJt ||t s/g|d|t ||||dzdR}It|}t|}||kr#td ||krd nd d |d |d|t#t%|j| g}|jD]O} t | t(r|| .t | t,r | } t | t.jrt3| s@t5t6dr=t | t6jr#t| ddrt| dnst | t5t6ds t.jnt.jt6jfr,| j} | r#t fd| D} | | } || Q|t |S)Nz%Cannot subscript already-subscripted rDc34K|]}t|VdSr)rr@rs rrBz7_ConcatenateGenericAlias.__getitem__..s*!A!Aq-"2"2!A!A!A!A!A!Arrr|rrrrErFrGrHrIrJr __unpacked__Fz is not valid as type argumentc3(K|] }|V dSrr)r@xsubsts rrBz7_ConcatenateGenericAlias.__getitem__..s''D'DQa'D'D'D'D'D'Dr)r8rbrDrrrr _unpack_argsrr rrrVr|rrrrziprrrrrr _is_unpackrrrrK) rrrparamprepareralenplennew_argsry subparamssubargsrs @rrz$_ConcatenateGenericAlias.__getitem__s7H"555 N N NOOO& B4 @ @ @AAAdE** w!A!AD!A!A!ABD(F J J!%)CTJJ&"74..DDy11J U++ASYY#E=)DDIUU99u'89CII~~'(G(G(GHHH6{{a''tAw0G0G' Avvvv $w"47D11J!+474L M M J JbqbI5a>>IDQLIIt99Dv;;Dt||7TD[[66e77D77#770477 T0$7788EH} % %c4((OOC(((c7+++*C#C)=>>PCMc??P$FN;;P!+30C D D P !(^U C C P(3(N(N(NOOO"6>::@F(()6+>?+ !$ 2I +"''D'D'D'D)'D'D'D"D"D!'l$$$$>>%//22 2r)rrrrrrrrrrrrrKrrrs@rrrs(  ! ! ! ! !  P P P  : : :          ; ; ;J 3J 3J 3J 3J 3J 3J 3rrc,eZdZdZfdZfdZxZS)rrct|dttfrg|dd|dRSt|dtjrg|dd|djR}n4|ddus*t|dt stdttj| |Sr) rrrrrrr rrrK)rrrs rrKz"_ConcatenateGenericAlias.copy_with sfRj4-8876VCRC[66":666fRj&*IJJ?Avcrc{AVBZ-@AAFF *++z&*i/P/P+#%>???V.,s(3Q3QaJqMM3Q3Q3Q3Q3Q3Qrc3K|]}|VdSrr)r@rs rrBz7_ConcatenateGenericAlias.__getitem__..-s"/A/Aa/A/A/A/A/A/Ar)rrrrrr)rrrrs rrz$_ConcatenateGenericAlias.__getitem__*ss++D11eU++D3Q3Q53Q3Q3Q0Q0QD /A/A5/A/A/A!BCCC r)rrrrKrrrs@rrrs[!J V V V V V         rceZdZdS)_EllipsisDummyN)rrrrrrrr2srrc|ddur$tjdkrg|ddtR}tjdkr t||tt fd}nt||}|dtur|St d|jD|_tjdkr|St d |jD|_|S) NrW.)rrrN)rrrT)_typevar_types_paramspec_tvarsc30K|]}|tur|ndVdS).Nrrs rrBz,_create_concatenate_alias..CsL!C!C()'(~&=&=3!C!C!C!C!C!Crrc3,K|]}|tu |VdSrr rs rrBz,_create_concatenate_alias..Hs<'D'DQ+,N+B+B()+B+B+B+B'D'Dr) rdrrrrr rrr)r0r concatenates r_create_concatenate_aliasr 6s"~!1I!=!=7z#2#777  :%%.vz8?7K9=??? /vzBB "~^++ !C!C-8-A!C!C!CCCK '!!!&'D'D+2L'D'D'D"D"DK rc,|dkrtdt|ts|f}|ddus*t|dtstddgfd|ddD|dR}t ||S)Nrz&Cannot take a Concatenate of no types.rW.rz/Concatenate[arg, ...]: each arg must be a type.c3BK|]}tj|VdSrr=r?s rrBz'_concatenate_getitem..Xs0HH1F&q#..HHHHHHr)rrrr r )rrrAs @r_concatenate_getitemrNsR@AAA j% ( (# ] rNc ! !Z 2 %J%J !:;; ; ;C$HHHH 3B3HHH$rN$$J $T: 6 66rc"t||S)a&Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a higher order function which adds, removes or transforms parameters of a callable. For example:: Callable[Concatenate[int, P], int] See PEP 612 for detailed information. )rrs rrrcs$D*555rrMc^tj||d}tj||fS)a Special typing form used to annotate the return type of a user-defined type guard function. ``TypeGuard`` only accepts a single type argument. At runtime, functions marked this way should return a boolean. ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static type checkers to determine a more precise type of an expression within a program's code flow. Usually type narrowing is done by analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type guard". Sometimes it would be convenient to use a user-defined boolean function as a type guard. Such a function should use ``TypeGuard[...]`` as its return type to alert static type checkers to this intention. Using ``-> TypeGuard`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the type inside ``TypeGuard``. For example:: def is_str(val: Union[str, float]): # "isinstance" type guard if isinstance(val, str): # Type of ``val`` is narrowed to ``str`` ... else: # Else, type of ``val`` is narrowed to ``float``. ... Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower form of ``TypeA`` (it can even be a wider form) and this may lead to type-unsafe results. The main reason is to allow for things like narrowing ``List[object]`` to ``List[str]`` even though the latter is not a subtype of the former, since ``List`` is invariant. The responsibility of writing type-safe type guards is left to the user. ``TypeGuard`` also works with type variables. For more information, see PEP 647 (User-Defined Type Guards).  accepts only a single type.rr>rrrrs rrMrMws5X!*.S.S.STT#D4'222rrNc^tj||d}tj||fS)awSpecial typing form used to annotate the return type of a user-defined type narrower function. ``TypeIs`` only accepts a single type argument. At runtime, functions marked this way should return a boolean. ``TypeIs`` aims to benefit *type narrowing* -- a technique used by static type checkers to determine a more precise type of an expression within a program's code flow. Usually type narrowing is done by analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type guard". Sometimes it would be convenient to use a user-defined boolean function as a type guard. Such a function should use ``TypeIs[...]`` as its return type to alert static type checkers to this intention. Using ``-> TypeIs`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the intersection of the type inside ``TypeIs`` and the argument's previously known type. For example:: def is_awaitable(val: object) -> TypeIs[Awaitable[Any]]: return hasattr(val, '__await__') def f(val: Union[int, Awaitable[int]]) -> int: if is_awaitable(val): assert_type(val, Awaitable[int]) else: assert_type(val, int) ``TypeIs`` also works with type variables. For more information, see PEP 742 (Narrowing types with TypeIs). rrrs rrNrNs5L!*.S.S.STT#D4'222rrLceZdZdZdS) _TypeFormFormc|Srrrs rrz_TypeFormForm.__call__JrN)rrrrrrrrrs#     rrc^tj||d}tj||fS)aA special form representing the value that results from the evaluation of a type expression. This value encodes the information supplied in the type expression, and it represents the type described by that type expression. When used in a type expression, TypeForm describes a set of type form objects. It accepts a single type argument, which must be a valid type expression. ``TypeForm[T]`` describes the set of all type form objects that represent the type T or types that are assignable to T. Usage: def cast[T](typ: TypeForm[T], value: Any) -> T: ... reveal_type(cast(int, "x")) # int See PEP 747 for more information. rrrs rrLrLs4&!*.S.S.STT#D4'222rr c&t|d)aDRepresents an arbitrary literal string. Example:: from typing_extensions import LiteralString def query(sql: LiteralString) -> ...: ... query("SELECT * FROM table") # ok query(f"SELECT * FROM {input()}") # not ok See PEP 675 for details. rvrrs rr r s"4666777rrc&t|d)zUsed to spell the type of "self" in classes. Example:: from typing import Self class ReturnsSelf: def parse(self, data: bytes) -> Self: ... return self rvrrs rrr s4666777rrQc&t|d)aThe bottom type, a type that has no members. This can be used to define a function that should never be called, or a function that never returns:: from typing_extensions import Never def never_call_me(arg: Never) -> None: pass def int_or_str(arg: int | str) -> None: never_call_me(arg) # type checker error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # ok, arg is of type Never rvrrs rrQrQ) s04666777rrTchtj||jd}tj||fS)aA special typing construct to mark a key of a total=False TypedDict as required. For example: class Movie(TypedDict, total=False): title: Required[str] year: int m = Movie( title='The Matrix', # typechecker error if key is omitted year=1999, ) There is no runtime checking that a required key is actually provided when instantiating a related TypedDict. rrr>rrrs rrTrTH s6"!*.Y.Y.YZZ#D4'222rchtj||jd}tj||fS)a`A special typing construct to mark a key of a TypedDict as potentially missing. For example: class Movie(TypedDict): title: str year: NotRequired[int] m = Movie( title='The Matrix', # typechecker error if key is omitted year=1999, ) rr rs rrUrU\ s6!*.Y.Y.YZZ#D4'222rchtj||jd}tj||fS)aA special typing construct to mark an item of a TypedDict as read-only. For example: class Movie(TypedDict): title: ReadOnly[str] year: int def mutate_movie(m: Movie) -> None: m["year"] = 1992 # allowed m["title"] = "The Matrix" # typechecker error There is no runtime checking for this property. rr rs rrSrSq s6 !*.Y.Y.YZZ#D4'222raType unpack operator. The type unpack operator takes the child types from some container type, such as `tuple[int, str]` or a `TypeVarTuple`, and 'pulls them out'. For example: # For some generic class `Foo`: Foo[Unpack[tuple[int, str]]] # Equivalent to Foo[int, str] Ts = TypeVarTuple('Ts') # Specifies that `Bar` is generic in an arbitrary number of types. # (Think of `Ts` as a tuple of an arbitrary number of individual # `TypeVar`s, which the `Unpack` is 'pulling out' directly into the # `Generic[]`.) class Bar(Generic[Unpack[Ts]]): ... Bar[int] # Valid Bar[int, str] # Also valid From Python 3.11, this can also be done using the `*` operator: Foo[*tuple[int, str]] class Bar(Generic[*Ts]): ... The operator can also be used along with a `TypedDict` to annotate `**kwargs` in a function signature. For instance: class Movie(TypedDict): name: str year: int # This function expects two keyword arguments - *name* of type `str` and # *year* of type `int`. def foo(**kwargs: Unpack[Movie]): ... Note that there is only some runtime checking of this operator. Not everything the runtime allows may be accepted by static type checkers. For more information, see PEP 646 and PEP 692. c.t|tuSr)r9rrs rrr s#&((rceZdZfdZxZS)_UnpackSpecialFormcbt|t|_dSr)rr _UNPACK_DOCr)rrrs rrz_UnpackSpecialForm.__init__ s& GG  W % % %&DLLLr)rrrrrrs@rr&r& s8 ' ' ' ' ' ' ' ' 'rr&cneZdZejdkrejZedZ edZ fdZ xZ S) _UnpackAliasrc|jtusJt|jdksJ|j\}t |t jtjfr$|jturtd|jSdS)Nrz*Unpack[...] must be used with a tuple type) r8rrrrrrrrrr)rrys r__typing_unpacked_tuple_args__z+_UnpackAlias.__typing_unpacked_tuple_args__ s?f,,,,t}%%****=DC# 4f6IJKK $>..#$PQQQ|#4rc|jtusJt|jdksJt |jdt S)Nrr)r8rrrrrrs r#__typing_is_unpacked_typevartuple__z0_UnpackAlias.__typing_is_unpacked_typevartuple__ sG?f,,,,t}%%****dmA. == =rcX|jr|St|Sr)r.rr)rrrs rrz_UnpackAlias.__getitem__ s+7  77&&t,, ,r) rrrrdrrrrrr,r.rrrs@rr*r* s  g % %I       > >  >  - - - - - - - - -rr*c^tj||jd}t||fS)Nr)rr>rr*rs rrr s1!*.Y.Y.YZZD4'***rc,t|tSr)rr*r$s rrr s#|,,,rcg}|D]L}t|dd}|"|r |ddus||7||M|S)Nr,rW.)rrr)rnewargsryrs rrr spG  #?FF   WR[C5G5G NN7 # # # # NN3     Nr)rrc2eZdZdZejZeddZdZ dS)rzType variable tuple.ryctj|t|tfd}|_S)Nc r|j}|}||dzdD])}t|trt d|*t |}t |}|}||z dz }d} d} t |D]e\} } t| tsKt| dd} | r8t | dkr%| ddur| t d| } | d} f| 't|| }t||| z dz }n$||z|krt d |d |d |dz |||z kr) rtj }n ||||z }g|d|| g||z z|| g||z |z |z dz z|||z dRS) Nrz(More than one TypeVarTuple parameter in r,rNrW.z6More than one unpacked arbitrary-length tuple argumentrrrIz, expected at least ) rrrrrr enumeraterrminr{rr|)rrrtypevartuple_indexrrrleftrightvar_tuple_indexfillargr\ryr replacementtvts r_typevartuple_prepare_substz9TypeVarTuple.__new__.._typevartuple_prepare_subst s-%+\\#%6%6"#$6$:$;$;<E!%66'NuNN 4yy6{{)11A5"&'oo 1 1FAs%c400 1")#/OQU"V"V"1s7||q'8'8WR[C=O=O.:&/%F'"'"!"/0O&-ajG".t_55Dto'='ABBEEE\D((#%TU%T%T/3%T%TIMPQ%T%TUUU4%<''COO,=,='".s"?"?KK"&tTE\'9":K%4%[i#5#<= i4%<$#69K#Ka#OP  $,--( r)rrr~rr)rrrkr@r?s @rrzTypeVarTuple.__new__ s[%d++C g & & &    + + + + + Z,GC (Jrc td)N&Cannot subclass special typing classesrrs rrzTypeVarTuple.__init_subclass__, sDEE ErN) rrrrrrrrVrrrrrrr sT"""("5*33 3 3 3 3 j F F F F FrcPeZdZdZejZdZeddZ dZ dZ dZ dZ d Zd S) raType variable tuple. Usage:: Ts = TypeVarTuple('Ts') In the same way that a normal type variable is a stand-in for a single type such as ``int``, a type variable *tuple* is a stand-in for a *tuple* type such as ``Tuple[int, str]``. Type variable tuples can be used in ``Generic`` declarations. Consider the following example:: class Array(Generic[*Ts]): ... The ``Ts`` type variable tuple here behaves like ``tuple[T1, T2]``, where ``T1`` and ``T2`` are type variables. To use these type variables as type parameters of ``Array``, we must *unpack* the type variable tuple using the star operator: ``*Ts``. The signature of ``Array`` then behaves as if we had simply written ``class Array(Generic[T1, T2]): ...``. In contrast to ``Generic[T1, T2]``, however, ``Generic[*Shape]`` allows us to parameterise the class with an *arbitrary* number of type parameters. Type variable tuples can be used anywhere a normal ``TypeVar`` can. This includes class definitions, as shown above, as well as function signatures and variable annotations:: class Array(Generic[*Ts]): def __init__(self, shape: Tuple[*Ts]): self._shape: Tuple[*Ts] = shape def get_shape(self) -> Tuple[*Ts]: return self._shape shape = (Height(480), Width(640)) x: Array[Height, Width] = Array(shape) y = abs(x) # Inferred type is Array[Height, Width] z = x + x # ... is Array[Height, Width] x.get_shape() # ... is tuple[Height, Width] c#K|jVdSr)rrs r__iter__zTypeVarTuple.__iter___ s# # # # # #rryc||_t||t}|dkr||_t ||_dS)NrR)rrrrlrrr)rrrkrs rrzTypeVarTuple.__init__b sO DM  " "4 1 1 1iiG---") &t D   rc|jSrrrs rrzTypeVarTuple.__repr__m rrc6t|Srrrs rrzTypeVarTuple.__hash__p rrc ||uSrrrs rrzTypeVarTuple.__eq__s rrc|jSrrrs rrzTypeVarTuple.__reduce__v rrc,d|vrtddS)NrrBrrs rrzTypeVarTuple.__init_subclass__y s$d"" HIII#"rN)rrrrrrrrErVrrrrrrrrrrr0 s) ) XN  $ $ $-6 - - - - - ! ! ! ) ) ) ! ! ! ! ! ! J J J J JrrFrrcftdt|jtj|S)aReveal the inferred type of a variable. When a static type checker encounters a call to ``reveal_type()``, it will emit the inferred type of the argument:: x: int = 1 reveal_type(x) Running a static type checker (e.g., ``mypy``) on this example will produce output similar to 'Revealed type is "builtins.int"'. At runtime, the function prints the runtime type of the argument and returns it unchanged. zRuntime type is )file)printrrrdstderrr$s rrFrF s0 7c!377cjIIII r_ASSERT_NEVER_REPR_MAX_LENGTHdr,ryct|}t|tkr|dtdz}td|)a1Assert to the type checker that a line of code is unreachable. Example:: def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _: assert_never(arg) If a type checker finds that a call to assert_never() is reachable, it will emit an error. At runtime, this throws an exception when called. N...z*Expected code to be unreachable, but got: )reprrrPAssertionError)ryrs rr,r, sN(S  u::5 5 58889EAEQ%QQRRRr) eq_default order_defaultkw_only_defaultfrozen_defaultfield_specifiersrVrWrXrYrZ.rc &fd}|S)aDecorator that marks a function, class, or metaclass as providing dataclass-like behavior. Example: from typing_extensions import dataclass_transform _T = TypeVar("_T") # Used on a decorator function @dataclass_transform() def create_model(cls: type[_T]) -> type[_T]: ... return cls @create_model class CustomerModel: id: int name: str # Used on a base class @dataclass_transform() class ModelBase: ... class CustomerModel(ModelBase): id: int name: str # Used on a metaclass @dataclass_transform() class ModelMeta(type): ... class ModelBase(metaclass=ModelMeta): ... class CustomerModel(ModelBase): id: int name: str Each of the ``CustomerModel`` classes defined in this example will now behave similarly to a dataclass created with the ``@dataclasses.dataclass`` decorator. For example, the type checker will synthesize an ``__init__`` method. The arguments to this decorator can be used to customize this behavior: - ``eq_default`` indicates whether the ``eq`` parameter is assumed to be True or False if it is omitted by the caller. - ``order_default`` indicates whether the ``order`` parameter is assumed to be True or False if it is omitted by the caller. - ``kw_only_default`` indicates whether the ``kw_only`` parameter is assumed to be True or False if it is omitted by the caller. - ``frozen_default`` indicates whether the ``frozen`` parameter is assumed to be True or False if it is omitted by the caller. - ``field_specifiers`` specifies a static list of supported classes or functions that describe fields, similar to ``dataclasses.field()``. At runtime, this decorator records its arguments in the ``__dataclass_transform__`` attribute on the decorated object. See PEP 681 for details. c$d|_|S)N)rVrWrXrYrZr)__dataclass_transform__) cls_or_fnrVrZrYrXrrWs r decoratorz&dataclass_transform..decorator s,(!.#2"0$4 11I - rr)rVrWrXrYrZrr_s`````` rr/r/ sCR          rrC_F)rcF d|_n#ttf$rYnwxYw|S)aHIndicate that a method is intended to override a method in a base class. Usage: class Base: def method(self) -> None: pass class Child(Base): @override def method(self) -> None: super().method() When this decorator is applied to a method, the type checker will validate that it overrides a method with the same name on a base class. This helps prevent bugs that may occur when a base class is changed without an equivalent change to a child class. There is no runtime checking of these properties. The decorator sets the ``__override__`` attribute to ``True`` on the decorated object to allow runtime introspection. See PEP 698 for details. T) __override__rrrxs rrCrC s@4 #C   *    D    r)rr}r_Tc neZdZdZedddedejeje de ddfd Z d e de fd Z dS) r0aIndicate that a class, function or overload is deprecated. When this decorator is applied to an object, the type checker will generate a diagnostic on usage of the deprecated object. Usage: @deprecated("Use B instead") class A: pass @deprecated("Use g instead") def f(): pass @overload @deprecated("int support is deprecated") def g(x: int) -> int: ... @overload def g(x: str) -> int: ... The warning specified by *category* will be emitted at runtime on use of deprecated objects. For functions, that happens on calls; for classes, on instantiation and on creation of subclasses. If the *category* is ``None``, no warning is emitted at runtime. The *stacklevel* determines where the warning is emitted. If it is ``1`` (the default), the warning is emitted at the direct caller of the deprecated object; if it is higher, it is emitted further up the stack. Static type checker behavior is not affected by the *category* and *stacklevel* arguments. The deprecation message passed to the decorator is saved in the ``__deprecated__`` attribute on the decorated object. If applied to an overload, the decorator must be after the ``@overload`` decorator for the attribute to exist on the overload as returned by ``get_overloads()``. See PEP 702 for details. rcategoryr/messagerfr/rNct|ts$tdt|j||_||_||_dS)Nz2Expected an object of type str for 'message', not )rrrrrrgrfr/)rrgrfr/s rrzdeprecated.__init__m s^gs++ 2G}}-22#DL$DM(DOOOrrych |j |j |j _St t rddl}ddlm}j |j  fd}t|_ j t |r: j |j  fd}t|_ n%|j  fd}|_ x_|_ |_Strddl}ddl}ddl}|j  fd}|jr2t(jdkr|j|}n|jj|_ x_|_|St1d) Nr) MethodTypec|urtjdztjur |g|Ri|S|jtjur|s|rt |jd|S)Nrrez() takes no arguments)r2r3r5rrrr)rrrryrfrA original_newr/s rrz$deprecated.__call__..__new__ sczz cHVWXXXX#6>99+|CA$AAA&AAA88d8f8'3<(N(N(NOOO+|C000rcHtjdz|i|SNrrer2r3rrrfrAoriginal_init_subclassr/s rrz.deprecated.__call__..__init_subclass__ 5 cHVWXXXX55tFvFFFrcHtjdz|i|Srnrorps rrz.deprecated.__call__..__init_subclass__ rrrcHtjdz|i|Srnro)rrryrfrAr/s rwrapperz$deprecated.__call__..wrapper s4M#ZRS^TTTT3////rrzY@deprecated decorator with non-None category must be applied to a class or callable, not )rgrfr/__deprecated__rrrptypesrjrwraps staticmethodrr classmethodrasyncio.coroutinesr coroutinesiscoroutinefunctionrdrmarkcoroutinefunction _is_coroutiner)rryrprjrrasynciorrurfrArqrlr/s ` @@@@@rrzdeprecated.__call__~ s,C}HJ%(" C&&D     ,,,,,,"{  .. 1 1 1 1 1 1 1 1/. 1+733 ),)>&4jAA>-C-L*$Y_%;<<GGGGGGG=<G-88I,J,JC))%Y_%;<<GGGGGGG=<G->C)>AA"W%;36!0 # ))))     %%0000000&%0%99#>>Q'722"?'"?"H"H070B0P->AA"W%;80388r)rrrrr4rrrprWarningrrrcrrrrr0r0C s( ( \?Q  ) ) ) ) ofk'&:;  )   ) ) ) ) )"M M "M M M M M M rr0cZ|dup't|ttttfSN.)rrrr rrxs rrr s.cz Z %y*BC   rcp|dup2t|ttttt jfSr)rrrr rrrxs rrr s9cz  Z (/     rc tj|rkt|tjrQt |jdkr9t|jdtr|rt|dsdS|st|d|tur=t|dr|jst|dt |j}t |}||kr|}t|drd|jD}td|D}|dkr |||z krdS||krHt||dtturdStd |D}||z}d |}t jd krd nd }td||krdndd|d|d|d| dS)Check correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. rrNrDrc0g|]}t||Srrrs r z"_check_generic.. #QQQA:a==QaQQQrc3@K|]}t|tVdSr)rrrs rrBz!_check_generic.. s,#T#TAJq,$?$?#T#T#T#T#T#Trr|c3PK|]!}t|dttuV"dSr|NrrVrs rrBz!_check_generic.. R)O)O>?*1M9)M)M09*:)O)O)O)O)O)OrrCr argumentsrrErFrG z for rIrJ)risclassrrrbrrrr rrr1rsumrrVrdr)rrelenr expect_val num_tv_tuplesnum_default_tvthingss r_check_genericr sx OC  ZV^%D%D C&''1,,3-a0)<<--#:a=11- F =s;;;<< < 7??3 011 A9K A3 ? ? ?@@@s)**D: 4<<Js,-- 4QQ);QQQ ##T#T#T#T#T T T !A%%DD=4H,H,HF$;; 4 0-KK())%()O)OCM)O)O)O&O&ONN*D!3T!3!3J%($4$?$?[[\FPTD[[66ePPfPP$'PP26PPCMPPQQ Q9 ., rrr|Nc3PK|]!}t|dttuV"dSrrrs rrBz!_check_generic..9 rrrCrErFrGrHrIrJ)rrrrrrVr)rrrrrrs rrr! sN  =s;;;<< <: 4<<Js,-- 4QQ);QQQ $;; 4 0-KK())%()O)OCM)O)O)O&O&ONN*D!3T!3!3JPTD[[66ePP$'PP26PPCMPPQQ Q/ . sLLLAQe^^a^^^r)rrrrrr*rrVrrrrrrr) rw typevar_typesenforce_default_orderingdefault_encounteredtype_var_tuple_encounteredrr{r collectedrs @rrrj s  "NM$F#G#G #&+" 4 4A(++ -1**1m,, 5?<5P5P UNN+ R")!]I"F"Fi"WK"R5E"+-D#E#EE.2++,R')Q!)Q)Q)QRRR Q.q11 4 LLLL)9LLLMMMMAu%% 444A%7%<%<44 $E11!LL3334U||rcxg}t}d}d}|D]}t|trt|tr2|D].}t |gD]}||vr||/`t |drf||vra|rJt|dttu}|r|rtd|rd}n|rtd|d||t|rd}t|dd D]}||vr||t|S) zCollect all type variables and parameter specifications in args in order of first appearance (lexicographic order). For example:: assert _collect_parameters((T, Callable[P, T])) == (T, P) F__typing_subst__r|rTrrrr) rrrr_collect_parametersrrrrVrr) rrrrrrrrr{s rrr s $F#G#G #&+"" -" -A!T""! -Au%% -99A%8!%=%=99 $J66&--i88899.// -J&&/ V#A}i@@ Q$6E+E"+-D#E#EE'V26//0V"+-Ua-U-U-U#V#VV%%a(((,Q//615. $4b99--A **"))!,,,-Z   rcd|D}d|D}tj||||}|x|_|j_|S)Ncg|]\}}|Srrr@rrs rrz!_make_nmtuple.. s&&&1!&&&rc Hi|]\}}|tj|d|d S)zfield z annotation must be a typer=rs rrz!_make_nmtuple.. sG***1a&,Q0V0V0V0VWW***rr-r)r namedtuplerXr)rrwrr-r6r`nm_tpls r _make_nmtupler sm&&&&&**#(*** 'f19&JJJBMM!? r>rrrXceZdZdZdS)_NamedTupleMetac <t|vsJ|D](}|tur|tjurtd)t d|D}dvr d}ndvrdd}ni}g}|D]^}|vr|||r@td|dt |dkrdnd d d |_t|| fd |Dd }||_ tj|vr^ttdrttj |_n*tjjj} t| |_ D]\} } | t vrt#d| z| t$vr| |jvrt)|| |  t+| j} | | || m#t.$rX} dt+| jd| d|}t2jdkr| |t9|| d} ~ wwxYw#t"$rYwxYwtj|vr||S)Nz3can only inherit from a NamedTuple type and Genericc3:K|]}|turtn|VdSr) _NamedTupler)r@r_s rrBz*_NamedTupleMeta.__new__.. s0SST4;#6#6%%DSSSSSSrrXrrzNon-default namedtuple field z cannot follow default fieldsrrrc g|] }| Srr)r@rrs rrz+_NamedTupleMeta.__new__.. s777A"Q%777rrr_generic_class_getitemz&Cannot overwrite NamedTuple attribute zError calling __set_name__ on z instance z in r)rrrbrrrrrrr rrrzr__class_getitem__r_prohibited_namedtuple_fieldsr_special_namedtuple_fields_fieldsr7r __set_name__ BaseExceptionrrdradd_note RuntimeErrorr)rr5rrr_rw default_names field_namer class_getitemkeyr9set_namerrAs ` rrz_NamedTupleMeta.__new__ sy%'''' O O{**t6>/I/I#MOOOSSUSSSSSE B&&,-2%%*>*1--M# C C ##!((4444"C#%BJ%B%B.1-.@.@1.D.Dss"%B%B(,yy'?'?%B%BCCCC #%++--7777777,'F %F ~&&6#;<<J/:6;X/Y/YF,,$*N$D$MM/:=/I/IF,HHJJ ? ?S777()QTW)WXXX :::&.00RW555?#'99#9?$HS&#6666,???!DcAS!D!D,/!D!D7?!D!D  #/7:: ! 3 %&23&7&7Q >? * ;6~&&((***Ms+!I)6 H I&AI!!I&) I65I6N)rrrrrrrrr s(D D D D D rrrc(t|vsJtfSr)rr)rs r_namedtuple_mro_entriesr5 sU""""~rc |tur|rd}d}nLd}d|d|d}d|zdz}n8|%|rtd d }d|d|d}d|zdz}n|rtd |tus|Etj||d t d|}t||t}tf|_ |S)aoTyped version of namedtuple. Usage:: class Employee(NamedTuple): name: str id: int This is equivalent to:: Employee = collections.namedtuple('Employee', ['name', 'id']) The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) An alternative equivalent functional syntax is also accepted:: Employee = NamedTuple('Employee', [('name', str), ('id', int)]) z3Creating NamedTuple classes using keyword argumentszq{name} is deprecated and will be disallowed in Python {remove}. Use the class-based or functional syntax instead.r+r-z = NamedTuple(z, [])`z{name} is deprecated and will be disallowed in Python {remove}. To create a NamedTuple class with 0 fields using the functional syntax, pass an empty list, e.g. rNz\Cannot pass `None` as the 'fields' parameter and also specify fields using keyword argumentsr,zIEither list of fields or keywords can be provided to NamedTuple, not bothz3.15)rrrNr.r) r1rr2r3rr4r rrlrr)r5r6rr8r:r9nts rrr9 sn( W   "#X H  $X HhHHhHHH0 # " #" ^ "F $N HhHHhHHH0 # " #"  HGHH H W   M&&, > >'M rceZdZdZdS)raBase class for classes that implement the buffer protocol. The buffer protocol allows Python objects to expose a low-level memory buffer interface. Before Python 3.12, it is not possible to implement the buffer protocol in pure Python code, or even to check whether a class implements the buffer protocol. In Python 3.12 and higher, the ``__buffer__`` method allows access to the buffer protocol from Python code, and the ``collections.abc.Buffer`` ABC allows checking whether a class implements the buffer protocol. To indicate support for the buffer protocol in earlier versions, inherit from this ABC, either in a stub file or at runtime, or use ABC registration. This ABC provides no methods, because there is no Python-accessible methods shared by pre-3.12 buffer classes. It is useful primarily for static checks. N)rrrrrrrrr s    rr:c |jd|jS#t$r&t dt |jdwxYw)aReturn the class's "original" bases prior to modification by `__mro_entries__`. Examples:: from typing import TypeVar, Generic from typing_extensions import NamedTuple, TypedDict T = TypeVar("T") class Foo(Generic[T]): ... class Bar(Foo[int], float): ... class Baz(list[str]): ... Eggs = NamedTuple("Eggs", [("a", int), ("b", str)]) Spam = TypedDict("Spam", {"a": int, "b": str}) assert get_original_bases(Bar) == (Foo[int], float) assert get_original_bases(Baz) == (list[str],) assert get_original_bases(Eggs) == (NamedTuple,) assert get_original_bases(Spam) == (TypedDict,) assert get_original_bases(int) == (object,) rz"Expected an instance of type, not N)r[rhrrrrrrs rr:r: sf* <##$4cmDD D   KT#YY5GKK  s "0AcVeZdZdZdZdZdZdZdZe j dkrdZ d Z d Sd S) rAaLNewType 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 callable 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|Srrrs rrzNewType.__call__ rrc||_d|vr|dd}||_||_t }|dkr ||_dSdS)NrrWrR)r rpartitionr __supertype__rlr)rrrrs rrzNewType.__init__ s` $D d{{s++B/ DM!#D iiG---").-rc6|jGfdd}|fS)NceZdZfdZdS)&NewType.__mro_entries__..Dummyc D|j}td|d|dd)NzGCannot subclass an instance of NewType. Perhaps you were looking for: `z = NewType(rz)`)rr)r subcls_name supercls_names rrz8NewType.__mro_entries__..Dummy.__init_subclass__ sU"%,K#W'WW4?WWERWWWrN)rrrr)rsrDummyr s.rrr)rrrrs @rrzNewType.__mro_entries__ sG!MM          8Orc$|jd|jS)Nr)rrrs rrzNewType.__repr__ so;;(9;; ;rc|jSr)rrs rrzNewType.__reduce__ s $ $rrc*tj||fSrrrs rrzNewType.__or__ s|D%K00rc*tj||fSrrrs rrzNewType.__ror__ s|E4K00rN) rrrrrrrrrrdrrrrrrrArA s     * * *     < < < % % %  w & & 1 1 1 1 1 1 1 1 ' &rrAc|dup$;*S# $ 3## rcn|dup1t|ttjtjt fSr)rrrrrrKr$s rrrs8$;*S#  3## r> rrrrr8rrr __reduce_ex__rrr,ceZdZdZdS)_TypeAliasGenericAliasct|tvrt||St|j|Sr) _ATTRIBUTE_DELEGATION_EXCLUSIONSr5rrr8)rr(s rrz"_TypeAliasGenericAlias.__getattr__.s6;;;!--dD999t555rN)rrrrrrrrr-s# 6 6 6 6 6rrceZdZdZdddefdZdededdffd Zdedefd Z dedefd Z defd Z e j d krddZdZdZdZdZdZe j dkr dZdZxZSxZS)rKaCreate named, parameterized type aliases. This provides a backport of the new `type` statement in Python 3.12: type ListOrSet[T] = list[T] | set[T] is equivalent to: T = TypeVar("T") ListOrSet = TypeAliasType("ListOrSet", list[T] | set[T], type_params=(T,)) The name ListOrSet can then be used as an alias for the type it refers to. The type_params argument should contain all the type parameters used in the value of the type alias. If the alias is not generic, this argument is omitted. Static type checkers should only support type aliases declared using TypeAliasType that follow these rules: - The first argument (the name) must be a string literal. - The TypeAliasType instance must be immediately assigned to a variable of the same name. (For example, 'X = TypeAliasType("Y", int)' is invalid, as is 'X, Y = TypeAliasType("X", int), TypeAliasType("Y", int)'). r) type_paramsrct|tstdt|tstd||_||_d}g}|D]}t|t ttfrt|rtd|t|dttu}|r|std|d|rd}t|tr| || |t||_t}|d kr||_||_dS) Nz#TypeAliasType name must be a stringztype_params must be a tupleFzExpected a type param, got r|znon-default type parameter 'z ' follows default type parameterTrR)rrrr __value____type_params__rrr rrrVrrrrlrr) rrrrdefault_value_encounteredrr}r{rs rrzTypeAliasType.__init__PsdC(( G EFFFk511 ? =>>>"DN#.D (- %J) 2 2 ":y/QRRR"*-- R $$P*$P$PQQQJ yAAR-G[G#%F:%F%F%FGGG504-j,772%%j1111%%j1111"' "3"3D iiG---") DMMMrrrNct|dr||t||dS)Nr)r_raise_attribute_errorrr6)rrrrs rr6zTypeAliasType.__setattr__usItZ(( 2++D111 GG  e , , , , ,rc0||dSr)rrrs r __delattr__zTypeAliasType.__delattr__zs  ' ' - - - - -rc|dkrtd|dvrtd|dtd|d)Nrzreadonly attribute>rrrrz attribute 'z3' of 'typing.TypeAliasType' objects is not writablez0'typing.TypeAliasType' object has no attribute '')rrs rrz$TypeAliasType._raise_attribute_error}srz!!$%9:::YYY$&$&&& %NtNNNrc|jSrrrs rrzTypeAliasType.__repr__rrrrc|durdS|dSt|trdkrfd|DStj|djdS)N.rcBg|]}|dzS)r_check_single_param)r@ry recursionrs rrz5TypeAliasType._check_single_param..s=... #!44S)A+FF...r Subscripting  requires a type.)rrrr>r)rrrs` `rrz!TypeAliasType._check_single_paramsC<<3=4eT**.yA~~.....',....)Ot}OOOrctjdkrtfd|DStfd|DS)Nrc3BK|]}|VdSrrr@rrs rrBz2TypeAliasType._check_parameters..sE,,T22rc3TK|]"}tj|djdV#dS)rrN)rr>rrs rrBz2TypeAliasType._check_parameters..sY +NdmNNNr)rdrrrs` r_check_parameterszTypeAliasType._check_parameterss')) *!+ rc8|jstdt|ts|f}tjdkrt j||St|}| |}t||}|j |kr||_ |S)Nz+Only generic type aliases are subscriptabler) rrrrrdrrrrrrr)rr type_varsrs rrzTypeAliasType.__getitem__s' O MNNNj%00 +(] 7***4<<<*:66I// ;;J*4<rc|t|to't|ddo|tuo |tjuS)aZReturn True if the given type is a Protocol. Example:: >>> from typing_extensions import Protocol, is_protocol >>> class P(Protocol): ... def a(self) -> str: ... ... b: int >>> is_protocol(P) True >>> is_protocol(int) False rtF)rrrrDrrFs rr>r>sH r4  *NE22 *(" *&/)  rct|st|dt|drt|jStt |S)aReturn the set of members defined in a Protocol. Example:: >>> from typing_extensions import Protocol, get_protocol_members >>> class P(Protocol): ... def a(self) -> str: ... ... b: int >>> get_protocol_members(P) frozenset({'a', 'b'}) Raise a TypeError for arguments that are not Protocols. z is not a ProtocolrT)r>rrrrTrarFs rr;r;sd2 9r77788 8 2+ , , 4R233 3,R00111rr2cJeZdZdZdeddfdZdefdZdefdZde de fd Z dS) r2afDefine the documentation of a type annotation using ``Annotated``, to be used in class attributes, function and method parameters, return values, and variables. The value should be a positional-only string literal to allow static tools like editors and documentation generators to use it. This complements docstrings. The string value passed is available in the attribute ``documentation``. Example:: >>> from typing_extensions import Annotated, Doc >>> def hi(to: Annotated[str, Doc("Who to say hi to")]) -> None: ... documentationrNc||_dSrr)rrs rrz Doc.__init__s!.D   rcd|jdS)NzDoc()rrs rrz Doc.__repr__s1$,111 1rc*t|jSr)rrrs rrz Doc.__hash__s*++ +rrcZt|tstS|j|jkSr)rr2rrrs rrz Doc.__eq__!s+eS)) &%%%)<< .sM"U*UC"8"8Vf>OPU>V>VrTrdrrci|] }|j| Srr)r@rs rrz#get_annotations..sEEEeneEEErchi|].\}}|t|ts|nt|/Sr)rreval)r@rrrrs rrz#get_annotations..sO,,,U#E3// QEET%&5Q5Q,,,r)r6rrir rrrrrhrGetSetDescriptorTyperdmodulesrvarsrhr[rrXrr r rdrppartialrre)rrrrrobj_dictann obj_globals module_namer obj_localsunwrapr return_values `` rr7r7EsmJ V3 3 3M   Yfl22WXX X c4 $ MsJ55H GHe44 ll#4d;;c6#>??CK!#|T::K Dd;;D")&*d"C"CKd3iiJFF V. / / M#0$77C,KJFF c]] M#0$77C!#}d;;KJFF S+ , , M%C04 4K 4*vvsKKKLL L ;I#t$$ TRRRSS S I &&&)iikk99    6=11#/Ffi&788#[Fv}-- 1$0 ?!G >%2F "#'8"== =; OEEEEENF,,,,,!iikk,,, rr3rrrrc|jr|jSt|dd- |jj}d|_||_|S#t $rYnwxYw|t|dd}|Et|dd4tt j|j ddd}|t|dd}|t|trGt|dd}|r3t j|d}|rt|dd}nLt|tj rt|dd}n t|rt|dd}|i}|9i}t|tr"|t!|||t|dd}|t#|}|D] }|||j< |j} | rgt+j| sS| |vr || }n^| |vr || }nQt/t0| rtt0| St3| |j} t7| ||}d|_||_|S) N__cell__T __owner____forward_module__r[rerr)__forward_evaluated____forward_value__rr2 cell_contentsrirdr&rhr4rrrrhrrr'rr__forward_arg__ isidentifierkeyword iskeywordrbuiltins NameError__forward_code__r$) forward_refrrrrrr,rrrycodes r_eval_with_ownerrAs  , 10 0 ; D 1 1 = #,:59 105 -      =Kd;;E O %94@@L  >EEzSWG ?k=$??G ?%&& >%e\4@@ D [__[$??FD")&*d"C"CE6#455 >!%T::% >!%== ?G >F%&& + d5kk***  5#4"%):DAAK  "7mmG$ 0 0*/'')      0g&7&<&< 0f}}s  3'' %x---nn$/Dw//E,0 )(- % s = A  A )rrrrr_recursive_guardc |tjkr|jS|j|vr|S t|||||}n##t$r|tjkr|cYSwxYwt |trt|}t |tr)t|ddd}t|||||||Stj dkr-|r+|rt|ni}|D]}|j|vr |||j<tj dkr!tj|||||jhzStj||||||jhzS)aEvaluate a forward reference as a type hint. This is similar to calling the ForwardRef.evaluate() method, but unlike that method, evaluate_forward_ref() also: * Recursively evaluates forward references nested within the type hint. * Rejects certain objects that are not valid type hints. * Replaces type hints that evaluate to None with types.NoneType. * Supports the *FORWARDREF* and *STRING* formats. *forward_ref* must be an instance of ForwardRef. *owner*, if given, should be the object that holds the annotations that the forward reference derived from, such as a module, class object, or function. It is used to infer the namespaces to use for looking up names. *globals* and *locals* can also be explicitly given to provide the global and local namespaces. *type_params* is a tuple of type parameters that are in scope when evaluating the forward reference. This parameter must be provided (though it may be an empty tuple) if *owner* is not given and the forward reference does not already have an owner set. *format* specifies the format of the annotation and is a member of the annotationlib.Format enum. r0r4TN)rrrrrBr)rr)recursive_guard)r6r r8rAr=r rrr_rr3rdrrrrri) r?rrrrrrBrtvars rr3r3s@ V] " ". .  &*: : :  $' EE   ***""""   eS ! ! &u%%E eZ ( ( u2D99E'(!1&    j ( ([ (%+3T&\\\F# 1 1=..,0F4=)  j ( ($ 0K4O3P P  $ 0K4O3P P  s9AAceZdZdZ d dedejefdZdZe j dkrdZ e j d krd Z d Z d ZdS)rEzCreate a unique sentinel object. *name* should be the name of the variable to which the return value shall be assigned. *repr*, if supplied, will be used for the repr of the sentinel object. If not provided, "" will be used. NrrTc2||_||nd|d|_dS)N<>)r_repr)rrrTs rrzSentinel.__init__{s'  !-TT;t;;; rc|jSr)rKrs rrzSentinel.__repr__rrrcJtt|jd)Nz object is not callablerrrrus rrzSentinel.__call__s"tDzz2MMMNN Nrrc*tj||fSrrrs rrzSentinel.__or__s<e , ,rc*tj||fSrrrs rrzSentinel.__ror__s<t , ,rcLtdt|jd)NzCannot pickle z objectrNrs r __getstate__zSentinel.__getstate__s%Gd)<GGGHHHrr)rrrrrrrprrrdrrrrrRrrrrErErs&*???oc"???? '!! O O O 7"" - - - - - -IIIIIrrE)rrrr~ct|ttjtjfr#|jdkr|jS|jd|jS|durdSt|S)a"Convert a Python value to a format suitable for use with the STRING format. This is intended as a helper for tools that support the STRING format but do not have access to the code that originally produced the annotations. It uses repr() for most objects. r<r.rS)rrr FunctionTypeBuiltinFunctionTyperrrT)rs rrPrPsn edF$79ST U U >:--))&==);== = C<<5E{{r)#rXrYrZr[r\r]r^r`rcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|rRcdi|]-}tt||tt|.Sr)rrr)r@rs rrrs3TTTTgfd>S>STT764 TTTr)rrb)rN)NNF)NNr)r)ror<rcollections.abcrQenumrprior:rTrdrwrrr2rr__all__PEP_560r GenericMeta_PEP_696_IMPLEMENTEDr_r_FORWARD_REF_HAS_CLASSrr1rrRrrrrrrrrr_Finalrrr r5rr1r=r@rrrrr rrBr4r. defaultdictr(rrrrrrrrrr rrrIrOrrrrar)r+rarOrprrPr~rEXCLUDED_ATTRIBUTESr\rarlrDrrrvrzr|rzrrbrHrGr'r%r$r#r&r"r(r)r*_NEEDS_SINGLETONMETArrVrrWr_PEP_728_IMPLEMENTEDr!rr? signaturer>rrrrrBr<r>rEr-r<rLrbr]r9r8rJr~rrrr r rr rrrrr rrrrMrNrLrr rrQrTrUrSr(rrr&r*rrrFrPr,r/rwrxr[rCr`r0rcrrrrrrrrrr _prohibitedrrrrrrrABCregister memoryview bytearrayrr:rArKrrrr>r;r`rr2 _CapsuleType_socket_CAPI ImportErrorrrr6r7IntEnumr r3rArErP _typing_namesrrr+rrrrps5     wC C C L  '+==063D3NN  )++w    JJJ ?FN3V^DV^Dv~f--- 6>*D 9 9 9w & & & & &4 & & & 9 9 9 9 9 9 9 9 9 ? (/(/(/(/(/6=(/(/(/(/\11111V01111  w LEE @ 76?##(MM0   z!!nGG H H H H Hv34 H H H H:::::-T::::<l 1 2 2 2G( 76?##?#H(M,OO10 +1488&&&P 7 7 7### {     $ $    . ? {$ )))UUUUUUUUUUUUU===&*&*&*&*&*v:$&*&*&*&*PT I$$!1 9/EI*)&YLN*)) /$') N /.. "/$') ,-JK" )F677;;;       wHH<<<<@@@BBB&b&b&b&b&b&V_--b&b&b&H[0(((((6>]((((.w0111j  w$K(M,O(M(M$K(MMh(htn 72x \WWR22 \ YF YFF$  \ \ \ \ \(# \ \ \  $$$KGGFN,K,K(K 76; II     -     I 76>""&LL " " " " "] " " " "$#%%L t0 I*N&LL 1 1&2D E E PPM*f.f.f.f.f.f.f.f.Pnk2rBBJ<<<|!!!!! D!!!!2< < < |-~> 0 0 0 76=!!$KK     76:D1*NN0(>(>(>(>TT I21212121nw"JHH0, 76;8 II 8 8 8%%% )))CCCCCtCCC 'Y#Y#Y#Y#Y#Y,#Y#Y#Y#YN 76?##;7(M,OO77777 777.77777*7770Z        WV[!!V+[+[+[+[+[.+[+[+[+[+[bbbbbbD-bbbLwv}%%` 76? + + - 5      , r3r3r3r3r34r3r3r3r3l &> '!!     v'Fd    ,0 7 7 7 w$KK 6 6 6 76;13 II,3,3,3` 768+3 ]FF&3&3&3T 76:3HH.d 33]30 76?##8(MM88\8& 7668 ;DD88\8" 7678 LEE88\84 76:'3H$KK333&333" 76:3HH333&' Xw ]F))))'''''34'''' -----v+4----6+++---OJ####### WV^$$LJ;F;F;F;F;F!1;F;F;F;F;F|KJKJKJKJKJ}KJKJKJ\ 76=!!$KK!( 76233($*$H!!$'! 76>""S&LLS%SuSSSS8w 4 # %$ SSSSS S  S !, LVZ0&/#vz/2RR S   S*S !a SSSSl 76:&HH FOCO$D E E EB!b!!!!!Lz!!$JJ   BHHHHHHHHVg       (wv~&&YQ-44Q4Q4Q4Q4Qp Q Q QD+*F[D[[[[&$WWV^T%J%JKD 76'((l9....`!3F6!6!6!p 9%8"w"JJ%+$6!!*+X+X+X!Y!YEEEEE$EEEN,, b"EEK%,????B"9J 7;?H%% _ #FF        * OOJ OOI OOE 76'((2@wnGG:1:1:1:1:1:1:1:1|w(MM 7""        '!!,59 6 6 6 , , ( 6 6 6 6 6V%9 6 6 6 6_0_0_0_0_0_0_0_0D 76=!!+2$K!6  D    *22V-=c-B2222* 765 = *CC========@wv}d33 '..  4;;L      K NN=!!!w555555555)-TE%|D 76)**h!6#D4LLLLLb"VVVVVr#I#I#I#I#I#I#I#IL)))'II(&&& N TT]TTT .     s<tt#"t#