bgddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z gdZ dZ e ZGddZeZefdZejdkrdZnejd krd Znd Zdd Ze jZe jd Ze jdZe jdZe jddZe jddZejdkrddl mZnGdde ZGddeZe jZGdde jdZ e!e drejddd kre j"Z"nGd!d"e dZ#e#dd#$Z"ejdkre j$Z$nd%Z$d&Z%ejd'kre j&Z&n7d(Z'd)Z(Gd*d+e j)dZ*Gd,d-e dZ+e+d.$Z&e j,Z,e!e d/re j-Z-e j.Z.e j/Z/n-ej0ej1ej0e2Z3d0Z-d1Z.d2Z/e j4Z4e j5Z5e j6Z6e j7Z7e j8Z8e j9Z9e j:Z:e j;Z;e j<Z<e!e d3re j=Z=ne j>ej=eefZ=e j?Z?e j@Z@e jAZAe jBZBe jCZCgd4d5d6gd7gd8ZDhd9ZEejd:kreEhd;zZEejd kreEFd<ejd=kreEFd>eGeEZEd?ZHd@ZIddAZJejd=kre jKZKnwddCZLdDZMejd:kre jKZNe eNZOn eZNejPZOGdEdFeOZQeRdGZSejd:krGdHdIe jTeQZKnGdJdIeQZKejd:kre jUZUndKZUeUZVejd=kr2e jWZWe jXZXe jYZYe jZZZe j[Z[e j\Z\e j]Z]neUGdLdMeKZWeUGdNdOeKZXeUGdPdQeKZYeUGdRdSeKZZeUGdTdUeKZ[eUGdVdWeKeZ\eUGdXdYeKeZ]dZZ^ejd[kre j_Z_e j`Z`e jaZand\ejbe jcjdvZeejd:krdIZfnd]ZfGd^d_e Z`e ge`d`daiZhe^dbefddcddZ_e!e d_r e j`e`fZine`fZideZae!e dfre jjZjndgZje!e dhre jkZkndiZlddkZke!e dlre jmZme jnZnn"Gdmdne j)dZnGdodlZmejdddkre joZoe jpZpn: ddpl mqZqn#er$r e j)ZqYnwxYw ddql msZtn#er$r e j)ZtYnwxYwdrZodsZpe!e dtre juZun,ejddd kr e duZun e dtdv$ZudwZvdxZwGdydzZxGd{d|e ZyGd}d~eyZe!e dre jzZze j{Z{n)GddZ|Gdde|ZzGdde|Z{e!e drGddeyZ}nGdde~exZ}e!e dsGdde~Ze jdZe!e dre jZe jZnselfs H/opt/cloudlinux/venv/lib64/python3.11/site-packages/typing_extensions.py__repr__z_Sentinel.__repr__s|N__name__ __module__ __qualname__rsrortrrrmrms#rtrmc |st|d|tur=t|dr|jst|dt |j}t |}||krnt|dr;d|jD}t d|D}|dkr |||z krdStd||krdnd d |d |d |dS) zCheck correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. z is not a generic class__parameters__c0g|]}t||Sro) _is_unpack.0ps rr z"_check_generic..s#MMMz!}}M!MMMrtc3@K|]}t|tVdSN) isinstancerr}s rr z!_check_generic..s,PP 1l ; ;PPPPPPrtrNzToo manyfewz parameters for z ; actual z , expected ) TypeError_markerhasattrrzlensum)cls parameterselenalen num_tv_tupless rr_check_genericrsE 93777888 ws,-- =S5G =s;;;<< <3%&& z??D t|| 3( ) ) MMS%7MMMJPPZPPPPPM!!}0D(D(D;vv%;;QT;;#';;48;;<< < |rt cdt|tjtjtjfSr)rtyping _GenericAlias_types GenericAlias UnionTypets rr_should_collect_from_parametersrs) $f&96;KL   rtr cNt|tjtjfSr)rrrrrrs rrrrs!f2F4GHIIIrtcFt|tjo|j Sr)rrr_specialrs rrrrs!V122E1:~Ertc&| tj}g|D]o}t||r(|vr$t|s|t |r&fd|jDptS)zCollect all type variable contained in types in order of first appearance (lexicographic order). For example:: _collect_type_vars((T, List[S, T])) == (T, S) Ncg|]}|v| Sroro)r~rtvarss rrrz&_collect_type_vars..sHHH%!rt) rr rr|appendrextendrztuple)types typevar_typesrrs @rr_collect_type_varsrs  E JJ q- ( (  UNN1   LLOOO *1 - - J LLHHHHQ%5HHH I I I <<rtTKTVTT_co) covariantT_contra) contravariant)r )rc(eZdZfdZfdZxZS)_AnyMetacv|turtdt|S)Nz6typing_extensions.Any cannot be used with isinstance())rrsuper__instancecheck__)rqobj __class__s rrrz_AnyMeta.__instancecheck__s3s{{ XYYY77,,S11 1rtcZ|turdStS)Nztyping_extensions.Any)rrrs)rqrs rrrsz_AnyMeta.__repr__s(s{{..77##%% %rt)rvrwrxrrs __classcell__rs@rrrrsQ 2 2 2 2 2  & & & & & & & & &rtrc"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__rargskwargsrs rrrz Any.__new__sAczz <==="577?3888888 8rt)rvrwrx__doc__rrrs@rrrrsB   9 9 9 9 9 9 9 9 9rtr) metaclassceZdZdZdS)_ExtensionsSpecialFormcd|jzSNztyping_extensions._namerps rrrsz_ExtensionsSpecialForm.__repr__s#dj00rtNrurortrrrrs#11111rtr)_rootr)rceZdZdZdS) _FinalFormchtj||jd}tj||fSN accepts only a single type.r _type_checkrrrqritems rr __getitem__z_FinalForm.__getitem__;%j)-&Q&Q&QSSD'tg66 6rtNrvrwrxrrortrrrr# 7 7 7 7 7rtraWA special typing construct to indicate that a name cannot be re-assigned or overridden in a subclass. For example: MAX_SIZE: Final = 9000 MAX_SIZE += 1 # Error reported by type checker class Connection: TIMEOUT: Final[int] = 10 class FastConnector(Connection): TIMEOUT = 1 # Error reported by type checker There is no runtime checking of these properties.)doccF 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__AttributeErrorr)fs rrr-r-s>, AKK *    D     c*tj|Sr)rr )names rrr3r3<s >$  rt)rrcg}|D]G}t|tr||j2||Ht |S)zJAn internal helper for Literal creation: flatten Literals among parameters)r_LiteralGenericAliasr__args__rr)rparamsrs rr_flatten_literal_paramsrDsa ! !A!122 ! aj)))) a    V}}rtc#:K|D]}|t|fVdSr)type)rrs rr_value_and_type_iterrNs8  AT!WW*      rtceZdZdZdZdS)rct|tstStt |j}tt |j}||kSr)rrNotImplementedsetrr)rqotherthese_args_dedupedother_args_dedupeds rr__eq__z_LiteralGenericAlias.__eq__SsYe%9:: &%%!$%9$-%H%H!I!I !$%9%.%I%I!J!J %);; ;rtc^ttt|jSr)hash frozensetrrrps rr__hash__z_LiteralGenericAlias.__hash__Zs# "6t}"E"EFFGG GrtN)rvrwrxrrrortrrrrRs7 < < < H H H H Hrtrc eZdZdefdZdZdS) _LiteralFormrc0d|_|x|_|_dS)Nr6)r_docr)rqrs rr__init__z_LiteralForm.__init__^s"DJ'* *DI rtct|ts|f}t|}tt |} t |}t |t |krVg}|D]6}||vr0||d||7|r J|t|}n#t$rYnwxYwt||S)Nr) rrrlistrrrrremoverr)rqrval_type_pairs deduped_pairsnew_parameterspairs rrrz_LiteralForm.__getitem__bsj%00 +(] 0< + + + + + : : : : :rtra 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,ct|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_registryrwrx__code__co_firstlinenor_overload_dummy)funcrs rrr8r8sn< 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)rrwr rxrvalues)r rmod_dicts rrr,r,sg D*d + + <1 1 1I%al3 > ) )IHQ^,3355666rtc8tdS)z$Clear all overloads in the registry.N)r clearrortrrr)r)s  """""rtr) rJrrUrVrrRrdrLrKrarAbstractContextManagerAbstractAsyncContextManagerr)zcollections.abc contextlibtyping_extensions>rr__dict__r __slots__rw __weakref__ _is_protocol__orig_bases____orig_class__rz__annotations____subclasshook____protocol_attrs____abstractmethods___is_runtime_protocol_MutableMapping__marker__callable_proto_members_only__)r>_gorgr __extra__ __origin__ __tree_hash____next_in_mro____class_getitem__)r __type_params__ct}|jddD]_}|jdvr t|di}g|j|RD]5}|ds|t vr||6`|S)N>rQr:r_abc_)r__mro__rvrr startswith_EXCLUDED_ATTRSadd)rattrsbase annotationsattrs rr_get_protocol_attrsr8s EEE CRC    =3 3 3 d$5r:: 2dm2k22  DOOG,, _1L1L $  Lrtc >g}d|jvrt|j}d}|jD]Z}t|tjr>|jtjtfvr$|jj }|td|j }[||}nt|}t||ksYd fd|D}d d|D}td|d|d |d |}t||_ dS) zHelper function used in Protocol.__init_subclass__ and _TypedDictMeta.__new__. The contents of this function are very similar to logic found in typing.Generic.__init_subclass__ on the CPython main branch. rNzECannot inherit from Generic[...] and/or Protocol[...] multiple types., c3>K|]}|vt|VdSrr)r~rgvarsets rrrz+_maybe_adjust_parameters..:s3"M"MaAW.;s("9"9a3q66"9"9"9"9"9"9rtzSome type variables (z) are not listed in [])rrrrrrr'rQr:rvrrzrjoinr) rrgvarsr5the_basetvarsets_varss_argsr=s @rr_maybe_adjust_parametersrHsx E3<''"3#566 & , ,D4!566 ,O'AAA?3$#@AAA+ =EE%jjG%jjGg%%"M"M"M"M5"M"M"MMM"9"95"9"9"999!G!G!G2:!G!G=C!G!G!GHHHEuCrtc tj|jddS#tt f$rYdSwxYw)Nrv__main__)sys _getframe f_globalsgetr ValueErrordepths rr_callerrRBsQ}U##-11*jIII J 'tts,/AArc$t|dvS)zAllow instance and class checks for special stdlib modules. The abc and functools modules indiscriminately call isinstance() and issubclass() on the whole MRO of a user class, which may contain protocols. >Nabc functools)rRrPs rr_allow_reckless_class_checksrVNs u~~!;;;rtcLt|jrtddS)Nz Protocols cannot be instantiated)rrrrqrrs rr_no_initrYUs/ :: " @>?? ? @ @rtc8eZdZdZdZdZdZdZdefdZ dS) _ProtocolMetac |dkrt|dkrnttht|zrn|D]k}|tt jtthvsH|jt |j gvs!t|std|ltjj||||fi|S)Nr:rz5Protocols can only inherit from other protocols, got )rr:_typing_ProtocolrobjectrrQrv_PROTO_ALLOWLISTrNrwr4rrTABCMetar)mclsrbases namespacerr5s rrrz_ProtocolMeta.__new__jsz!!c%jj1nn,-E : !  DCS TTT=,<,@,@RT,U,UUU&t,,V(,#',,;&tT5)NNvNN Nrtctjjg|Ri|tddr;t _t fdjD_dSdS)NrFc3TK|]"}tt|dV#dSr)callabler)r~r7rs rrrz)_ProtocolMeta.__init__..sH::;?HWS$5566::::::rt)rTr`rrr8rallr#rrrs` rrrz_ProtocolMeta.__init__zs K  6t 6 6 6v 6 6 6sNE22 )    &S & & & & & &rtr[cT|jddstS|jD]}}|jD]j}||jvr|j| tccSnOt |di}t |tjj r||vrt|rn ktcS~dS)NrFrT) rrNrrr0rr collectionsrTrYr4)rrr7r5r6s rrrlrls|66 "! !* & &D  & &4=((}T*2------E&d,=rBB {KO,CDD ++#E**,E%%%%trtcBeZdZejjZdZdZdZfdZ xZ S)r:roTFc4tj|i||jdds#t d|jD|_d|jvr t|_|jr!|j tj urt|_ dSdSdS)NrFc3(K|] }|tuVdSrr:r~bs rrrz-Protocol.__init_subclass__..&*P*PQ1=*P*P*P*P*P*Prtr) r__init_subclass__rrNany __bases__rrlrrr:rYrs rrrzProtocol.__init_subclass__s))4:6:::|''>>Q'**P*P#-*P*P*P'P'PC$&S\99+6C(#, 8I(I(I#+CLLL,,(I(Irt) rvrwrxrr:rrrr!rrrs@rrr:r:sRo-GIL#(  , , , , , , , , ,rtr:cTeZdZdZdZdZdZfdZej dZ dZ xZ S)r:aBase class for protocol classes. Protocol classes are defined as:: class Proto(Protocol): def meth(self) -> int: ... Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:: class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check See PEP 544 for details. Protocol classes decorated with @typing_extensions.runtime_checkable act as simple-minded runtime-checkable protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:: class GenProto(Protocol[T]): def meth(self) -> T: ... roTFcv|turtdt|S)NzIType Protocol cannot be instantiated; it can only be used as a base class)r:rrr)rrkwdsrs rrrzProtocol.__new__ s=(??#%JKKKwws+++rtct|ts|f}|s&|tjurt d|jddtfd|D}|t urtd|Dsed}t||tjr%|dz }t||tj%t d|dzd ||tt|t|krt d n#t||t|j tj ||S) NzParameter list to z[...] cannot be emptyz*Parameters to generic types must be types.c3BK|]}tj|VdSrrrr~rmsgs rrrz-Protocol.__class_getitem__...s0JJav1!S99JJJJJJrtc3JK|]}t|tjVdSr)rrr r}s rrrz-Protocol.__class_getitem__..1s.MMz!V^<<MMMMMMrtrrzBParameters to Protocol[...] must all be type variables. Parameter z is z.Parameters to Protocol[...] must all be unique)rrrrfrrxr:rgr rrrrzr)rrirs @rrr*zProtocol.__class_getitem__&s!&%00'$YFV#V\"9"9#TS-=TTTVVVBJJJJ6JJJJJ(??MMfMMMMMB(FNCC#FA)FNCC#'A*+a%AA5;AYAABBB3v;;''3v;;66'LNNN7 #3C4F0G0GHHH+C888rtcd|jvrtj|jv}ntj|jv}|rt dt ||jdds#td|jD|_ d|jvr t|_ |j r!|j tj urt|_ dSdSdS)Nrz!Cannot inherit from plain Genericrc3(K|] }|tuVdSrr}r~s rrrz-Protocol.__init_subclass__..Krrtr)rrrQrrrrHrNrrrlrrr:rY)rrrerrors rrrzProtocol.__init_subclass__@s#s|33"Nc.@@EE"Ncm;EI#$GHHH(---|''==Q'**P*P#-*P*P*P'P'PC$&S\99+6C(#, 8I(I(I#+CLLL,,(I(Irt) rvrwrxrrrr!rr _tp_cacher*rrrs@rrr:r:s  :IL#(  , , , , ,   9 9  92 , , , , , , ,rtct|tst|tjrt |ddst d|d|_|S)a4Mark a protocol class as a runtime protocol, so that it 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 the one-offs in collections.abc such as Hashable. rFz@@runtime_checkable can be only applied to protocol classes, got T)rr[ issubclassrrQrrr!rvs rrr=r=Ysq] + + -/9#v~/N/N -^U33 -,$',,-- -#'  rtc<eZdZdZdZejdefdZdS)r$z(An ABC with one abstract method __int__.rortcdSrrorps rr__int__zSupportsInt.__int__~ DrtN) rvrwrxrrrTabstractmethodrwrrortrrr$r$ysH66  S        rtr$c<eZdZdZdZejdefdZdS)r"z*An ABC with one abstract method __float__.rortcdSrrorps rr __float__zSupportsFloat.__float__rrtN) rvrwrxrrrTrfloatrrortrrr"r"H88  u        rtr"c<eZdZdZdZejdefdZdS)r!z,An ABC with one abstract method __complex__.rortcdSrrorps rr __complex__zSupportsComplex.__complex__rrtN) rvrwrxrrrTrcomplexrrortrrr!r!sH::          rtr!c<eZdZdZdZejdefdZdS)r z*An ABC with one abstract method __bytes__.rortcdSrrorps rr __bytes__zSupportsBytes.__bytes__rrtN) rvrwrxrrrTrbytesrrortrrr r rrtr c8eZdZdZejdefdZdS)r#rortcdSrrorps rr __index__zSupportsIndex.__index__rrtN)rvrwrxrrTrrwrrortrrr#r#sB  s        rtr#c<eZdZdZdZejdefdZdS)rz_ An ABC with one abstract method __abs__ that is covariant in its return type. rortcdSrrorps rr__abs__zSupportsAbs.__abs__rrtN) rvrwrxrrrTrrrrortrrrrsN    T        rtrcBeZdZdZdZejddedefdZ dS) r%za An ABC with one abstract method __round__ that is covariant in its return type. rorndigitsrtcdSrro)rqrs rr __round__zSupportsRound.__round__rrtN)r) rvrwrxrrrTrrwrrrortrrr%r%sZ     S         rtr%cfd}|S)NctjjdkrbtjdkrRt |t d}t |jd|}tj||S|_ |S)Npypyr)__call____mro_entries__ro) rKimplementationr version_info staticmethodrrvrUupdate_wrapperr)r cls_dictr mro_entriess rrinnerz#_ensure_subclassable..inners~   "f , ,1AF1J1J(..#/ #<#<HT]B11A+AACC66 6#.D Krtro)rrs` rr_ensure_subclassablers#      Lrt)r module _Protocolc$eZdZddZeZdZeZdS)_TypedDictMetaTc|D]5}t|tur|tjurt d6t d|Drtjf}nd}tttg|tR||_ j tkr|_ tds|_ i}| di}dtr"fd|D}n fd|D}t!} t!} |D]}||j di| |j d d| |j d d|||D]\} } t'| } | t(ur(t+| }|r|d } t'| } | t,ur| | d| t0ur| | |r| | | | |_t5| _t5| _td s|_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 classc3JK|]}t|tjVdSr)rrrQr~s rrrz)_TypedDictMeta.__new__..s.@@Q:a00@@@@@@rtrorrz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecPi|]"\}}|tj|j#S)r)rrrw)r~ntprtp_dicts rr z*_TypedDictMeta.__new__..sD###2v)"c':LMMM###rtcBi|]\}}|tj|Sror)r~rrrs rrrz*_TypedDictMeta.__new__..s<###2v)"c22###rt__required_keys____optional_keys__r __total__)rrrrQrrr _fake_namedictrvrxrrrN _TAKES_MODULEitemsrupdaterr/r&r.rEr3rFrrrrr)rrrbnstotalr5 generic_baser6own_annotations required_keys optional_keysannotation_keyannotation_typeannotation_originannotation_argsrrs @@rrrz_TypedDictMeta.__new__sQ F F::^33FN8R8R#%EFFF@@%@@@@@ " &0 ! ll>:?T?Tt?T?TVXYYG#G #z11'+$7$455 /).&K ff%6;;OSC #####!0!6!6!8!8### ####!0!6!6!8!8### EEMEEM Q Q""4=#4#45F#K#KLLL$$T]%6%67JB%O%OPPP$$T]%6%67JB%O%OPPPP    / / /3B3H3H3J3J 6 6/$.$?$?!$ 11&.&?&?O&H*9!*<,6,G,G)$00!%%n5555&+55!%%n55556!%%n5555!%%n5555&1G #(1-(@(@G %(1-(@(@G %7K00 *$)!Nrtc td)Nz4TypedDict does not support instance and class checksrrms rrrkz _TypedDictMeta.__subclasscheck__/sRSS SrtN)T)rvrwrxrrrrkrrortrrrrsJH H H H T T T T.rtrrroctfSr) _TypedDictrbs rrr7s rtrc |tus|A|turd}nd}d|d|d}|d|zdz}tj|td |}n|rt d |rtjd td d t |i}t }|||d<t|d||} tf| _ | S)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. 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. .r stacklevelz@TypedDict takes either a dict or keyword arguments, but not bothzThe 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.rrwror) rwarningswarnDeprecationWarningrrrRrrr) __typename__fieldsrrdeprecated_thingexampledeprecation_msgrrtds rrrr7s0` w  ("27""#W  #M I*II:IIIG#OOO  O M/+=! L L L LHH  -,-- -   M;#      h 0  %B|  JBe < < <&L rtcvttdr|tjurdSt|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 rF)rrrr_TYPEDDICT_TYPESrs rrr5r5s9 6; ' ' B&2B,B,B5".///rtr(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. ro)__val__typs rrr(r(s  rtrEcdt|trt|jSt |dr/|jt t fvrt|jdSt|tj r@td|jD}||jkr|S| |St tdr_t|tj rEtd|jD}||jkr|Stj |j|St tdrdt|tjrJtd|jD}||jkr|Stjt"j|S|S)z=Strips Annotated, Required and NotRequired from a given type.r'rc34K|]}t|VdSr _strip_extrasr~as rrrz _strip_extras..*!G!Gq-"2"2!G!G!G!G!G!Grtrc34K|]}t|VdSrrrs rrrz _strip_extras..rrtrc34K|]}t|VdSrrrs rrrz _strip_extras..rrt)r_AnnotatedAliasrr'rrErFrrrr copy_withrrrrUreduceoperatoror_)r stripped_argss rrrrs a ) ) / .. . 1l # # 0 ;8O(O(O 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-@@ @rtFcttdrtj|||d}ntj|||}|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. r&T)globalnslocalnsinclude_extras)r r c4i|]\}}|t|Sror)r~krs rrrz"get_type_hints..s&===1=##===rt)rrr2r)rr r r hints rrr2r2s|@ 6; ' ' R(hDD(xQQQD  K== ====rtr&c@eZdZdZfdZdZdZdZdZdZ xZ S)raKRuntime representation of an annotated type. At its core 'Annotated[t, dec1, dec2, ...]' is an alias for the type 't' with extra annotations. The alias behaves like a normal typing alias, instantiating is the same as instantiating the underlying type, binding it to types is also the same. ct|tr|j|z}|j}t ||||_dSr)rr __metadata__r'rr)rqoriginmetadatars rrrz_AnnotatedAlias.__init__ sR&/22 +!.9* GG  VV , , , (D   rtcft|dksJ|d}t||jS)Nrr)rrr)rqrnew_types rrrz_AnnotatedAlias.copy_withs5v;;!####ayH"8T->?? ?rtcdtj|jddd|jDdS)Nztyping_extensions.Annotated[r:c34K|]}t|VdSr)reprrs rrrz+_AnnotatedAlias.__repr__..s( D DQa D D D D D DrtrA)r _type_reprr'rBrrps rrrsz_AnnotatedAlias.__repr__s\H63DT_3U3UHHyy D D$2C D D DDDHHH IrtcHtjt|jf|jzffSr)rgetitemr&r'rrps rr __reduce__z_AnnotatedAlias.__reduce__s)#DO-0AA& rtc~t|tstS|j|jkrdS|j|jkS)NF)rrrr'rrqrs rrrz_AnnotatedAlias.__eq__!s@e_55 &%%%"222u$(:: :rtc8t|j|jfSr)rr'rrps rrrz_AnnotatedAlias.__hash__(s$*;<== =rt) rvrwrxrrrrsrrrrrs@rrrrs   ) ) ) ) ) @ @ @  I I I     ; ; ; > > > > > > >rtrcBeZdZdZdZdZejdZdZ dS)r&aAdd context specific metadata to a type. Example: Annotated[int, runtime_check.Unsigned] indicates to the hypothetical runtime_check module that this type is an unsigned int. Every other consumer of this type can ignore this metadata and treat this type as int. The first argument to Annotated must be a valid type (and will be in the __origin__ field), the remaining arguments are kept as a tuple in the __extra__ field. Details: - It's an error to call `Annotated` with less than two arguments. - Nested Annotated are flattened:: Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3] - Instantiating an annotated type is equivalent to instantiating the underlying type:: Annotated[C, Ann1](5) == C(5) - Annotated can be used as a generic type alias:: Optimized = Annotated[T, runtime.Optimize()] Optimized[int] == Annotated[int, runtime.Optimize()] OptimizedList = Annotated[List[T], runtime.Optimize()] OptimizedList[int] == Annotated[List[int], runtime.Optimize()] roc td)Nz&Type Annotated cannot be instantiated.rrhs rrrzAnnotated.__new__NDEE ErtcTt|trt|dkrtdtt f}t |d|vr |d}nd}tj|d|}t|dd}t||S)NrzUAnnotated[...] should be used with at least two arguments (a type and an annotation).rz$Annotated[t, ...]: t must be a type.r) rrrrrrr/rrr)rrallowed_special_formsrrrs rrr*zAnnotated.__class_getitem__Qsfe,, 0F a!/000&.u$5 !&)$$(===<+F1Is;;VABBZ((H"6844 4rtc2td|jd)NCannot subclass z .Annotated)rrwrhs rrrzAnnotated.__init_subclass__`s$=3>=== rtN) rvrwrxrrrrrr*rrortrrr&r&+sf  @  F F F   5 5   5     rt)_BaseGenericAlias)rct|trtSt|tjt t ttfr|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) rrr&rr_typing_GenericAliasr(r r r'rQrs rrr/r/xsg b/ * *   b6/1EGX(/; < < !=   > !trtcft|tr|jf|jzSt|tjt frjt|ddrdS|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) rFrorNr.)rrr'rrrr*rrr/ryrTrJEllipsisr)rress rrr.r.s b/ * * 6M#bo5 5 b6/1EF G G r:u-- r+C"~~!999c!fH>T>TCH~~s2w/Jrrtr?c&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 subscriptablerrqrs rrr?r?s4666777rta%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.ct|ttfr td|D|_dS|tkrt j|d|_dSd|_dS)Nc3@K|]}tj|dVdS)Default must be a typeNr)r~ds rrrz_set_default..sD(:(:,-)/(:1>V(W(W(:(:(:(:(:(:rtr3)rrr __default__rrr) type_paramdefaults rr _set_defaultr8s'E4=))&!&(:(:18(:(:(:";";  G  !'!3G=U!V!V !% rtcDtd}|dkr ||_dSdS)NrrPr)rRrw) typevarlikedef_mods rr _set_moduler<s4AG%%%!( &%rtceZdZdZdZeZdS) _DefaultMixinzMixin for TypeVarLike defaults.roN)rvrwrxrrr8rrortrrr>r>s))IHHHrtr>ceZdZdedefdZdS)_TypeVarLikeMeta_TypeVarLikeMeta__instancertc,t||jSr)r_backported_typevarlike)rrAs rrrz"_TypeVarLikeMeta.__instancecheck__s*c&ABBBrtN)rvrwrxrboolrrortrrr@r@s>C3C4CCCCCCrtr@c<eZdZdZejZdddedddZddZ dS) r zType variable.NF)boundrrr7infer_variancecttdrtj|g|R||||d}n3tj|g|R|||d}|r|s|rtd||_t ||t ||S)Nr@rFrrrGrFrrz1Variance cannot be specified with infer_variance.)rrr rO__infer_variance__r8r<) rrrFrrr7rG constraintstypevars rrrzTypeVar.__new__s 6? + + 8nTDKDDu/8 4BDDDGGnTWKWWu/8 WWWG V9 V  V !TUUU)7G &Wg&&&Grtrtc2tdtd)Ntype 'z(.TypeVar' is not an acceptable base typerrvrvs rrrzTypeVar.__init_subclass__sSSSSTTTrtrtN) rvrwrxrrr rCrrrrortrrr r sb$n/3u$UUUUUUrtr r c"eZdZdZdZdZdZdS) _Immutablez3Mixin to indicate that object should not be copied.roc|Srrorps rr__copy__z_Immutable.__copy__Krtc|Srro)rqmemos rr __deepcopy__z_Immutable.__deepcopy__rVrtN)rvrwrxrrrUrYrortrrrSrS s=AA         rtrSc$eZdZdZdZdZdZdS)r aQThe args for a ParamSpec object. Given a ParamSpec object P, P.args is an instance of ParamSpecArgs. ParamSpecArgs objects have a reference back to their ParamSpec: P.args.__origin__ is P This type is meant for runtime introspection and has no special meaning to static type checkers. c||_dSrr'rqrs rrrzParamSpecArgs.__init__  $DOOOrtc |jjdS)Nz.argsr'rvrps rrrszParamSpecArgs.__repr__#so.555 5rtcZt|tstS|j|jkSr)rr rr'rs rrrzParamSpecArgs.__eq__&s*e]33 &%%?e&66 6rtNrvrwrxrrrsrrortrrr r sK  % % % 6 6 6 7 7 7 7 7rtc$eZdZdZdZdZdZdS)r a[The kwargs for a ParamSpec object. Given a ParamSpec object P, P.kwargs is an instance of ParamSpecKwargs. ParamSpecKwargs objects have a reference back to their ParamSpec: P.kwargs.__origin__ is P This type is meant for runtime introspection and has no special meaning to static type checkers. c||_dSrr\r]s rrrzParamSpecKwargs.__init__7r^rtc |jjdS)Nz.kwargsr`rps rrrszParamSpecKwargs.__repr__:so.777 7rtcZt|tstS|j|jkSr)rr rr'rs rrrzParamSpecKwargs.__eq__=s*e_55 &%%?e&66 6rtNrbrortrrr r +sK  % % % 8 8 8 7 7 7 7 7rtr rc<eZdZdZejZddddeddZddZ dS) rzParameter specification.NFrFrrrGr7cttdrtj|||||}ntj||||}||_t ||t ||S)Nr@rIrJ)rrrrKr8r<)rrrFrrrGr7 paramspecs rrrzParamSpec.__new__Ksv// >",T7@;H , G , , ,  " " " rtrtc2tdtd)NrOz*.ParamSpec' is not an acceptable base typerPrvs rrrzParamSpec.__init_subclass__^sYXYYYZZ ZrtrQ) rvrwrxrrrrCrrrrortrrrrFsc&&"("2(,#5#('     & [ [ [ [ [ [rtceZdZdZejZedZedZ dddde dfd Z dZ d Z d Zd Zd ZxZS) ra'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 rps rrrzParamSpec.argss && &rtc t|Sr)r rps rrrzParamSpec.kwargss"4(( (rtNFrhct|g||_t||_t||_t||_|rtj|d|_ nd|_ t||t}|dkr ||_ dSdS)NzBound must be a type.r) rrrvrD __covariant____contravariant__rKrr __bound__r>rRrw) rqrrFrrrGr7r;rs rrrzParamSpec.__init__s GG  dV $ $ $ DM!%iD %)-%8%8D "&*>&:&:D # &!'!3E;R!S!S!%  " "4 1 1 1iiG---").-rtcV|jrd}n|jrd}n |jrd}nd}||jzS)N+-~)rKrprqrv)rqprefixs rrrszParamSpec.__repr__sJ& # ' DM) )rtc6t|Srr^rrps rrrzParamSpec.__hash__??4(( (rtc ||uSrrors rrrzParamSpec.__eq__ 5= rtc|jSrrvrps rrrzParamSpec.__reduce__ = rtcdSrrorXs rrrzParamSpec.__call__ Drt)rvrwrxrrr rpropertyrrrrrsrrrrrrs@rrrres, , ^N  ' '  '  ) )  )+/%u$)7 * * * * * * *$ * * * ) ) ) ! ! ! ! ! !       rtrcXeZdZejZdZfdZdZdZ dZ e dZ xZ S)_ConcatenateGenericAliasFcft|||_||_dSr)rrr'r)rqrrrs rrrz!_ConcatenateGenericAlias.__init__s- GG  T " " "$DO DMMMrtctj|jddfd|jDdS)Nr@r:c3.K|]}|VdSrro)r~argrs rrrz4_ConcatenateGenericAlias.__repr__..s+!K!Kc**S//!K!K!K!K!K!KrtrA)rrr'rBr)rqrs @rrrsz!_ConcatenateGenericAlias.__repr__sd*J!z$/22OO !K!K!K!KT]!K!K!KKKOOO Prtc8t|j|jfSr)rr'rrps rrrz!_ConcatenateGenericAlias.__hash__s$-899 9rtcdSrrorXs rrrz!_ConcatenateGenericAlias.__call__rrtc>td|jDS)Nc3\K|]'}t|tjtf#|V(dSr)rrr r)r~rs rrrz:_ConcatenateGenericAlias.__parameters__..sLjfni=X.Y.Yrt)rrrps rrrzz'_ConcatenateGenericAlias.__parameters__s2!] rt)rvrwrxrrrrrrsrrrrzrrs@rrrrs(  ! ! ! ! !  P P P  : : :            rtrc |dkrtdt|ts|f}t|dtstddtfd|D}t ||S)Nroz&Cannot take a Concatenate of no types.r.zAThe last parameter to Concatenate should be a ParamSpec variable.z/Concatenate[arg, ...]: each arg must be a type.c3BK|]}tj|VdSrrrs rrrz'_concatenate_getitem..s0FFav)!S11FFFFFFrt)rrrrr)rqrrs @rr_concatenate_getitemrsR@AAA j% ( (# ] jni 0 0/.// / ;CFFFF:FFFFFJ #D* 5 55rtc"t||S)&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. rr0s rrrrs$D*555rtceZdZdZdS)_ConcatenateFormc"t||Srrr0s rrrz_ConcatenateForm.__getitem__s'j99 9rtNrrortrrrrs# : : : : :rtrrrAc^tj||d}tj||fS) 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). r)rrrrs rrrArA's5X!*.S.S.STT#D4'222rtceZdZdZdS)_TypeGuardFormchtj||jd}tj||fS)Nz accepts only a single typerrs rrrz_TypeGuardForm.__getitem__Xs;%j)-&P&P&PRRD'tg66 6rtNrrortrrrrWrrtrrcneZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ejd Zd S) _SpecialForm)rr_getitemcD||_|j|_|j|_dSr)rrvrr)rqrs rrrz_SpecialForm.__init__s  %  rtc6|dvr|jSt|)N>rvrx)rr)rqrs rr __getattr__z_SpecialForm.__getattr__s$ / / /: T"""rtc&td|)Nr'r)rqrbs rrrz_SpecialForm.__mro_entries__s3433444rtcd|jSrrrps rrrsz_SpecialForm.__repr__s0DJ000rtc|jSrrrps rrrz_SpecialForm.__reduce__s zrtc&td|)NzCannot instantiate rrqrrs rrrz_SpecialForm.__call__s6d66777rtc*tj||fSrrrgrs rr__or__z_SpecialForm.__or__s|D%K((rtc*tj||fSrrrs rr__ror__z_SpecialForm.__ror__s|E4K((rtc&t|d)Nz! cannot be used with isinstance()rrqrs rrrz_SpecialForm.__instancecheck__4BBBCCCrtc&t|d)Nz! cannot be used with issubclass()r)rqrs rrrkz_SpecialForm.__subclasscheck__rrtc.|||Sr)rr0s rrrz_SpecialForm.__getitem__s}}T:...rtN)rvrwrxrrrrrsrrrrrrkrrrrortrrrrs0I''' ### 555111888))))))DDDDDD /////rtrrc&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. r/rrqrs rrrrs"4666777rtr c&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 r/rrs rrr r s4666777rtrCc&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 r/rrs rrrCrCs04666777rtchtj||jd}tj||fS)A 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. rrrs rrrErEs6"!*.Y.Y.YZZ#D4'222rtchtj||jd}tj||fS)`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, ) rrrs rrrFrFs6!*.Y.Y.YZZ#D4'222rtceZdZdZdS) _RequiredFormchtj||jd}tj||fSrrrs rrrz_RequiredForm.__getitem__,rrtNrrortrrrr+rrtrrrFraType 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)r/rrs rrr|r|s#&((rtceZdZfdZxZS)_UnpackSpecialFormcbt|t|_dSr)rr _UNPACK_DOCr)rqrrs rrrz_UnpackSpecialForm.__init__s& GG  W % % %&DLLLrt)rvrwrxrrrs@rrrrs8 ' ' ' ' ' ' ' ' 'rtrceZdZejZdS _UnpackAliasNrvrwrxrr rrortrrrrN rtrc^tj||jd}t||fSrrrrrrs rrrrs1!*.Y.Y.YZZD4'***rtc,t|tSrrrrs rrr|r|#|,,,rtceZdZejZdSrrrortrrrrrrtceZdZdZdS) _UnpackFormc^tj||jd}t||fSrrrs rrrz_UnpackForm.__getitem__s8%j)-&Q&Q&QSSDtg.. .rtNrrortrrrrs# / / / / /rtrrc,t|tSrrrs rrr|r|rrtrc2eZdZdZejZeddZdZ dS)rzType variable tuple.r7cltj|}t||t||Sr)rrr8r<)rrr7tvts rrrzTypeVarTuple.__new__s5%d++C g & & &    Jrtc td)N&Cannot subclass special typing classesrrs rrrzTypeVarTuple.__init_subclass__r#rtN) rvrwrxrrrrCrrrrortrrrrsS"""("5*1       F F F F FrtcPeZdZdZejZdZeddZ 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) __unpacked__rps rr__iter__zTypeVarTuple.__iter__s# # # # # #rtrc||_t||t}|dkr||_t ||_dS)Nr)rvr>rrRrwrr)rqrr7r;s rrrzTypeVarTuple.__init__sO DM  " "4 1 1 1iiG---") &t D   rtc|jSrrrps rrrszTypeVarTuple.__repr__rrtc6t|Srrzrps rrrzTypeVarTuple.__hash__r{rtc ||uSrrors rrrzTypeVarTuple.__eq__r}rtc|jSrrrps rrrzTypeVarTuple.__reduce__rrtc,d|vrtddS)Nrrrrs rrrzTypeVarTuple.__init_subclass__s$d"" HIII#"rtN)rvrwrxrrr rrrrrsrrrrrortrrrrs) ) XN  $ $ $-4 - - - - - ! ! ! ) ) ) ! ! ! ! ! ! J J J J Jrtr;__objrtcftdt|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)printrrvrKstderr)rs rrr;r; s0 9e!599 KKKK rtr'__argc 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. zExpected code to be unreachable)AssertionErrorrs rrr'r' s(>???rt) eq_default order_defaultkw_only_defaultfrozen_defaultfield_specifiersrrrrr.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)rrrrrr)__dataclass_transform__) cls_or_fnrrrrrrs rr decoratorz&dataclass_transform..decorator s,(!.#2"0$4 11I - rtro)rrrrrrrs`````` rrr*r*8 sCR          rtr9_F)rFcF d|_n#ttf$rYnwxYw|S)aLIndicate 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__rrrs rrr9r9 s@4 !%E   *    D    rr+_Trcategoryr__msgrrc8dtdtffd }|S)aIndicate that a class, function or overload is deprecated. 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: ... When this decorator is applied to an object, the type checker will generate a diagnostic on usage of the deprecated object. The warning specified by ``category`` will be emitted on use of deprecated objects. For functions, that happens on calls; for classes, on instantiation. If the ``category`` is ``None``, no warning is emitted. 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. The decorator sets the ``__deprecated__`` attribute on the decorated object to the deprecation message passed to the decorator. 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. rrtc _Sttrajjt jut jfd}t|_x_|_Str2t jfd}x_|_|Std)Nctjdztjur |g|Ri|Ss|s|rt |jd|S)Nrrz() takes no arguments)rrr^rrrv)rrrrrhas_init original_newrs rrrz.deprecated..decorator..__new__ sM%(zTU~VVVV#6>99+|CA$AAA&AAA%14161'3<(N(N(NOOO+|C000rtcHtjdz|i|S)Nrr)rr)rrrrrrs rrwrapperz.deprecated..decorator..wrapper s4M%(zTU~VVVV 5$1&111rtzY@deprecated decorator with non-None category must be applied to a class or callable, not ) __deprecated__rrrrr^rUwrapsrrfr)rrrrrrrrs` @@rrrzdeprecated..decorator s0',$ E4(( $}  >@..11111111/.1!-W 5 5 @EE$w'= % ''2222222('2AFE$w'=:05::rt)r)rrrrs``` rrr+r+ sEX" R" B" " " " " " " " Hrtcd|D}d|D}tj||||}|x|_|j_tjdkr||_|S)Ncg|]\}}|Sroror~rrs rrrz!_make_nmtuple..$ s&&&1!&&&rtc Hi|]\}}|tj|d|d S)zfield z annotation must be a typerrs rrrz!_make_nmtuple..% sG***1a&,Q0V0V0V0VWW***rtdefaultsrr)ry namedtuplerrrKr _field_types)rrrr fieldsr6nm_tpls rr _make_nmtupler# s&&&&&**#(*** 'f19&JJJBMM!?  f $ $"-F  rt>rvrwrceZdZdZdS)_NamedTupleMetac t|vsJ|D](}|tur|tjurtd)t d|D}di}g}|D]^}|vr|||r@td|dt|dkrdndd d |_t|| fd |Dd  }||_ tj|vr^ttdrttj|_n*tjjj} t| |_D]F} | t"vrt%d| z| t&vr | |jvrt+|| | Gtj|vr||S)Nz3can only inherit from a NamedTuple type and Genericc3:K|]}|turtn|VdSr) _NamedTupler)r~r5s rrrz*_NamedTupleMeta.__new__..: s0SST4;#6#6%%DSSSSSSrtrzNon-default namedtuple field z cannot follow default fieldrsrt r:c g|] }| Sroro)r~rrs rrrz+_NamedTupleMeta.__new__..G s777A"Q%777rtrwr_generic_class_getitemz&Cannot overwrite NamedTuple attribute )rrrQrrrNrrrBrrrr classmethodrr*r_prohibited_namedtuple_fieldsr_special_namedtuple_fields_fieldssetattrr) rtypenamerbrr5r default_names field_namer  class_getitemkeys ` rrrz_NamedTupleMeta.__new__4 sZ%'''' O O{**t6>/I/I#MOOOSSUSSSSSEFF,b11EM# 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, 2 2777()QTW)WXXX :::s&.?X?XFCC111~&&((***MrtN)rvrwrxrrortrrrr3 s#% % % % % rtrrc(t|vsJtfSr)rrrs rr_namedtuple_mro_entriesr#] sU""""~rtc |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.rrz = 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 argumentsrzIEither list of fields or keywords can be provided to NamedTuple, not bothz3.15)rrrrr) rrrrformatrrrrRrr)rrrrrrnts rrrra sp* w   "#X H  $X LjLL LLL0 # " #"   "F $N LjLL LLL0 # " #"  HGHH H w  ("2 M&&, |jcYS#t$r&tdt |jdwxYwwxYw)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,) z"Expected an instance of type, not N)rrrrrrv)__clss rrr0r0 s* ' '    &&&!   Qe9MQQ  s AA0A  AcVeZdZdZdZdZdZdZdZe j dkrdZ d Z d Sd S) r7aLNewType 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|Srrors rrrzNewType.__call__ sJrtc||_d|vr|dd}||_||_t }|dkr ||_dSdS)Nrr.r)rx rpartitionrv __supertype__rRrw)rqrrr;s rrrzNewType.__init__ s` $D d{{s++B/ DM!#D iiG---").-rtc6|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(r:z)`)rvr)r subcls_name supercls_names rrrz8NewType.__mro_entries__..Dummy.__init_subclass__ sU"%,K#W'WW4?WWERWWWrtN)rvrwrxr)r4srrDummyr1 s.rtr5r)rqrbr5r4s @rrrzNewType.__mro_entries__ sG!MM          8Ortc$|jd|jS)Nr)rwrxrps rrrszNewType.__repr__ so;;(9;; ;rtc|jSr)rxrps rrrzNewType.__reduce__" s $ $rtrc*tj||fSrrrs rrrzNewType.__or__) s|D%K00rtc*tj||fSrrrs rrrzNewType.__ror__, s|E4K00rtN) rvrwrxrrrrrsrrKrrrrortrrr7r7 s     * * *     < < < % % %  w & & 1 1 1 1 1 1 1 1 ' &rtr7r@cn|dup1t|ttjtjt fS)z:Corresponds to is_unionable() in unionobject.c in CPython.N)rrrrrr@rs rr _is_unionabler;3 s8d{ j       /    rtceZdZdZdddefdZdededd ffd Zdedefd Z dedefd Z defd Z dZ dZ dZdZejdkr dZdZxZSxZS)r@aCreate 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)'). ro) type_paramsrcdt|tstd||_||_g}|D]B}t|t r||-||Ct||_ t}|dkr||_ ||_ dS)Nz#TypeAliasType name must be a stringr) rrr __value__r,rrrrrzrRrwrv)rqrvaluer=rr6r;s rrrzTypeAliasType.__init__X sdC(( G EFFF"DN#.D J) 2 2 j,772%%j1111%%j1111"' "3"3D iiG---") DMMMrt_TypeAliasType__name_TypeAliasType__valuertNct|dr||t||dS)Nrv)r_raise_attribute_errorr __setattr__)rqrArBrs rrrEzTypeAliasType.__setattr__k sItZ(( 4++F333 GG   0 0 0 0 0rtc0||dSr)rD)rqrAs rr __delattr__zTypeAliasType.__delattr__p s  ' ' / / / / /rtc|dkrtd|dvrtd|dtd|d)Nrvzreadonly attribute>r?rwrzr,z attribute 'z3' of 'typing.TypeAliasType' objects is not writablez0'typing.TypeAliasType' object has no attribute '')r)rqrs rrrDz$TypeAliasType._raise_attribute_errors srz!!$%9:::YYY$&$&&& %NtNNNrtc|jSrrrps rrrszTypeAliasType.__repr__ rrtct|ts|f}fd|D}tjt|S)NcLg|] }tj|djd!S)z Subscripting z requires a type.)rrrv)r~rrqs rrrz-TypeAliasType.__getitem__.. sK"J$-JJJrt)rrrrr0s` rrrzTypeAliasType.__getitem__ scj%00 +(] ' J 'eJ.?.?@@ @rtc|jSrrrps rrrzTypeAliasType.__reduce__ rrtc td)NzEtype 'typing_extensions.TypeAliasType' is not an acceptable base typerrhs rrrzTypeAliasType.__init_subclass__ sW rtc td)NzType alias is not callablerrps rrrzTypeAliasType.__call__ s899 9rtrcVt|stStj||fSrr;rrrg)rqrights rrrzTypeAliasType.__or__ s+%U++*))|D%K00rtcVt|stStj||fSrrQ)rqlefts rrrzTypeAliasType.__ror__ s)$T***))|D$J//rt)rvrwrxrrrr^rErCrGrDrsrrrrrKrrrrrs@rrr@r@< s`  6=? ! ! ! ! ! ! !& 1c 1F 1t 1 1 1 1 1 1  0c 0e 0 0 0 0 s u     !c ! ! ! ! A A A ! ! !    : : :  w & & 1 1 1 0 0 0 0 0 0 0 ' & & &rtr4__tpct|to=t|ddo,|tuo#|ttdt uS)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 rFr:)rrrr:rr^rUs rrr4r4 sY tT " " Bne44 BH$ BGFJAAA  rtct|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 Protocolr)r4rrrrr8rWs rrr1r1 sf4   ;t999:: : 4- . . 6T455 5,T22333rtr)r)r)NNF)ro)rTrycollections.abcrUrorrKrrrr__all__PEP_560r GenericMetarmrrrrrrDr rrrrrrrrrrrrrr-r3r6rrrrrr r8r,r) defaultdictpartialrr r rrrrrrrrr_aliasrrrr>rBr_r2r3rr8rHrRr:rVrYr]_ProtocolMetaBaser`r[rrlrQr=r<r$r"r!r r#rr%rrrr5 signaturerrrrrrrr(r2rr&rr/r.r( ImportErrorrr*r?r8r<r>r@r r rSrrrrrrrrAr_Finalrr rCrErFrrrr|rrrrr;r'r*rDrfrgrJr9rr+rrrr_Warningrwrr _prohibitedrrrrr#_new_signaturer FunctionType__text_signature__rrABCregister memoryview bytearrayrr0r7r@r;r4r1rOrGrHrIrKrLrMrNrPrRrSrTrUrVrWrXrYrZr[r\r]r^r`rarbrcrdrerhrirjrkrortrrrms   u u u p   )++*1<<<<*w     JJJJFFF* ?FN3V^DV^Dv~f--- 6>*D 9 9 9w & & & & &4 & & & 9 9 9 9 9 9 9 9 9 ?11111V01111 767M 0! 4 > > LEE77777+47777 Jw L M M MEw LEE @   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### {     $ $  &0  76=!!C$KK &- 7"bBBK . ?& {$ ,-JK" fO v+,,,w)***)O,,   %&%&%&PwHH<<<<@@@ 6!!"? D!122"Kf&f&f&f&f&)f&f&f&P[0 6!! , , , , ,v~ , , , , ,,X ,X ,X ,X ,X ,X ,X ,X ,X ,vv0& w$K(M,O(M(M$K(MMh(htn   w I*N&LL 1 1&2D E E PPM 6!!  Q.Q.Q.Q.Q.Q.Q.Q.fnk2rBBJ5566'.QQQQQ76Qfwv'((-"1>B*,000" 76=!!$KK     76:D>*NN0(>(>(>(>X 76;f I,OO%>%>%>%>%>&.d%>%>%>%>N88888888zBQB7"""JHH1,,,,,,, 111"014??????? 444%3400 76; IIbqbV## 8 8 8 8'&    I&&&)))CCCCCtCCC UUUUU(UUUU8 76?##;7(M,OO77777 777.77777*7770 76;D[[[[[.[[[[[>bbbbbD-bbbLwv}%%4B 6 6 6 76=!!# $K%>bqbV## 6 6 6 6:::::1::::#"     K 76;e  IIbqbV##,3,3,3,3^77777/t7777 ) + + + I^(/(/(/(/(/6=(/(/(/(/V 76?##8(MM88\8& 7668 ;DD88\8" 7678 LEE88\84 76:N H$KKbqbV##333&3333"77777.d7777 }    H" -     K ' Tw ]F)))) bqbV##'''''34'''' #####v+4####+++----#####v+4####/////,D//// [{ 3 3 3F--- 76>""]J F F F F F!1 F F F F FKJKJKJKJKJ}KJKJKJ\ 76=!!$KK1( 76>""@&LL@E@e@@@@.w 4 # %$ SSSSS S  S !, LVZ0&/#vz/2RR S   S*S !a SSSSl 76:&HH FOCO$D E E EB!!r!!!!H 76<  U"JJ   B ;M PPPP/&+g"67P P "r " PPPPtwv~&&+ 2F*Fw"JJ    %+$6!!*+X+X+X!Y!Y&&&&&$&&&P,, b"EEK122(/???32?H 6!!? :j&"5 6 6 D,:J ) )5CJ  2 7;?H%% _ #FF        * OOJ OOI OOE 76'(( 2DwnGG9191919191919191x 76?##w0(MM   k0k0k0k0k0k0k0k0\ 76=!!+4$K!6 $ 4    *444F,