R`iddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z gdZ dZ e ZGddZeZefdZej$dk\rdZnej$d k\rd Znd Zdd Ze j*Ze j,d Ze j,dZe j,dZe j,ddZe j,ddZej$dk\rddl mZnGdde ZGddeZe j<ZGdde j>dZ e!e drej$ddd k\r e jDZ"nGd!d"e dZ#e#dd#$Z"ej$dk\r e jHZ$nd%Z$d&Z%ej$d'k\r e jLZ&n3d(Z'd)Z(Gd*d+e jRdZ*Gd,d-e dZ+e+d.$Z&e jXZ,e!e d/r%e jZZ-e j\Z.e j^Z/n6ej`ejbej`e2Z3d0Z-d1Z.d2Z/e jhZ4e jjZ5e jlZ6e jnZ7e jpZ8e jrZ9e jtZ:e jvZ;e jxZ<e!e d3r e jzZ=ne j|ejzeefZ=e j~Z?e jZ@e jZAe jZBe jZCgd4d5d6gd7gd8ZDhd9ZEej$d:kreEhd;zZEej$d k\reEjd<ej$d=k\reEjd>eGeEZEd?ZHd@ZIddAZJej$d=k\r e jZKnddBZLdCZMej$d:k\re jZNe eNZOneZNejZOGdDdEeOZQeRdFZSej$d:k\rGdGdHe jeQZKn GdIdHeQZKej$d:k\r e jZUndJZUeUZVej$d=k\rUe jZWe jZXe jZYe jZZe jZ[e jZ\e jZ]nveUGdKdLeKZWeUGdMdNeKZXeUGdOdPeKZYeUGdQdReKZZeUGdSdTeKZ[eUGdUdVeKeZ\eUGdWdXeKeZ]dYZ^ej$dZk\r%e jZ_e jZ`e jZand[eje jjvZeej$d:k\rdHZfnd\ZfGd]d^e Z`e je`d_d`iZhe^daefddbdcZ_e!e d^re je`fZine`fZiddZae!e der e jZjndfZje!e dgr e jZkndhZlddjZke!e dkre jZme jZnn!Gdldme jRdZnGdndkZmej$dddk\re jZoe jZpn ddol mqZq ddpl msZtdqZodrZpe!e dsr e jZun%ej$ddd k\r e dtZun e dsdu$ZudvZvdwZwGdxdyZxGdzd{e ZyGd|d}eyZe!e d~re jZze jZ{n GddZ|Gdd~e|ZzGdde|Z{e!e dr GddeyZ}n Gdde~exZ}e!e ds Gdde~Ze jdZe!e dre jZe jZn2ej$ddd k\r e dZnGdde dZedd$Ze!e dre jZn2ej$ddd k\r e dZnGdde dZedd$ZGdde j dZe!e dre jZnedZe!e dre jZnedZe!e dre jZnedZe!e dgre jZe jZnDej$ddd k\re dZe dZn!Gdde dZedgd$Zedd$ZdZej$d=k\re jZdZnsej$ddd k\r0Gdde dZGdde jRdZedZdZn1Gdde jRdZGdde dZede$ZdZe!e dr GddeyZn GddexZe!e dre j(ZndedefdZe!e dre j*ZndedefdZej$d=k\re j,Znddididid`ddedededede j0e j2e jhe j8e j4de j8ffdfde j8de j4egeffd„Ze!e dëre j6Zn6e j,de j4de j8fūZdedefdƄZe!e dǫre j:ZnNe j,dȫZeddʜdede jBe jhedede j4egeffd΄Ze!e dsee _ee _ej$dZk\re jHZnddτZe jLZeGhdУZGdфde Ze jedd`iZdԄZe^eefdՄZej$d:k\r0dZeeej\ree_neej`_e!ejd7rejjbZnLGdׄd7ejdZejgeejgeejgee!edثrejnZndلZej$dk\re jpZn Gdڄd۫Ze!e dܫre jrZn d݄ZGdބdܫZe!e d߫re jvZe jxZnde defdZde de jzefdZe j|Ze j~Ze jZe j4Ze jZe jZe jZe jZe jzZe jZe jZTe jZe jZe jZe jZe jZe jZe jZe jZe jZe jZe jZe jZe jZe jBZe jZe jZe jZe jZe jZe jZe j0Ze j2Ze jZe jZe jZe jZy#er$re jRZqYwxYw#er$re jRZtYwxYw)N)iAnyClassVar ConcatenateFinal LiteralString ParamSpec ParamSpecArgsParamSpecKwargsSelfTypeTypeVar TypeVarTupleUnpack Awaitable AsyncIterator AsyncIterable CoroutineAsyncGeneratorAsyncContextManagerBufferChainMapContextManagerCounterDeque DefaultDict NamedTuple OrderedDict TypedDict SupportsAbs SupportsBytesSupportsComplex SupportsFloat SupportsIndex SupportsInt SupportsRound Annotated assert_never assert_typeclear_overloadsdataclass_transform deprecated get_overloadsfinalget_args get_originget_original_basesget_protocol_membersget_type_hintsIntVar is_protocol is_typeddictLiteralNewTypeoverloadoverrideProtocol reveal_typeruntimeruntime_checkableText TypeAlias TypeAliasType TypeGuard TYPE_CHECKINGNeverNoReturnRequired NotRequired AbstractSetAnyStrBinaryIOCallable Collection ContainerDict ForwardRef FrozenSet GeneratorGenericHashableIO ItemsViewIterableIteratorKeysViewListMapping MappingViewMatchMutableMappingMutableSequence MutableSetOptionalPattern ReversibleSequenceSetSizedTextIOTupleUnion ValuesViewcast no_type_checkno_type_check_decoratorTceZdZdZy) _Sentinelcy)Nz selfs /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/typing_extensions.py__repr__z_Sentinel.__repr__sN__name__ __module__ __qualname__rsrortrrrmrmsrtrmc |st|d|tur;t|dr |jst|dt |j}t |}||k7rot|drE|jDcgc]}t |r|}}t d|D}|dkDr |||z k\rytd||kDrdndd |d |d |ycc}w) 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__c3<K|]}t|tywN) isinstancer.0ps rr z!_check_generic..sPZ 1l ;ZrNzToo manyfewz parameters for z ; actual z , expected ) TypeError_markerhasattrrzlen _is_unpacksum)cls parameterselenalenr num_tv_tupless rr_check_genericrs 3%6788 ws,-S5G5Gse#:;< <3%%& z?D t| 3( )%(%7%7M%7z!}!%7JMPZPPM!}0D(D$v%@@PQTPUV##'& D6;< < Ms >CC ctt|tjtjtj fSr|)r}typing _GenericAlias_types GenericAlias UnionTypets rr_should_collect_from_parametersrs- $$f&9&96;K;KL  rtr cVt|tjtjfSr|)r}rrrrrs rrrrs !f22F4G4GHIIrtcTt|tjxr |j Sr|)r}rr_specialrs rrrrs !V112E1::~Ertc$|tj}g}|D]h}t||r ||vrt|s|j |t |s;|j |jDcgc] }||vs| c}jt|Scc}w)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) ) rr r}rappendrextendrztuple)types typevar_typestvarsrs rr_collect_type_varsrs  E  q- ( UN1 LLO *1 - LLQ%5%5H%5%!%5H I <Is + B 5B TKTVTT_co) covariantT_contra) contravariant)r )rc(eZdZfdZfdZxZS)_AnyMetacH|tur tdt| |S)Nz6typing_extensions.Any cannot be used with isinstance())rrsuper__instancecheck__)rqobj __class__s rrrz_AnyMeta.__instancecheck__s&s{ XYY7,S1 1rtc2|turyt| S)Nztyping_extensions.Any)rrrs)rqrs rrrsz_AnyMeta.__repr__ss{.7#% %rt)rvrwrxrrs __classcell__rs@rrrrs 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. cP|tur tdt| |g|i|S)NzAny cannot be instantiated)rrr__new__rargskwargsrs rrrz Any.__new__s/cz <==7?3888 8rt)rvrwrx__doc__rrrs@rrrrs  9 9rtr) metaclassceZdZdZy)_ExtensionsSpecialFormc d|jzSNztyping_extensions._namerps rrrsz_ExtensionsSpecialForm.__repr__s#djj00rtNrurortrrrrs1rtr)_rootr)rceZdZdZy) _FinalFormcvtj||jd}tj||fSN accepts only a single type.r _type_checkrrrqritems rr __getitem__z_FinalForm.__getitem__9%%j)- 4P&QSD''tg6 6rtNrvrwrxrrortrrrr 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.)doccB d|_|S#ttf$rY|SwxYw)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-s5, AK   *      c,tj|Sr|)rr )names rrr3r3<s >>$ rt)rrcg}|D]?}t|tr|j|j/|j |At |S)zJAn internal helper for Literal creation: flatten Literals among parameters)r}_LiteralGenericAliasr__args__rr)rparamsrs rr_flatten_literal_paramsrDsDA!12 ajj) a  V}rtc#8K|D]}|t|fywr|)type)rrs rr_value_and_type_iterrNsAT!W* sceZdZdZdZy)rct|tstStt |j }tt |j }||k(Sr|)r}rNotImplementedsetrr)rqotherthese_args_dedupedother_args_dedupeds rr__eq__z_LiteralGenericAlias.__eq__SsIe%9:%%!$%9$--%H!I !$%9%..%I!J %);; ;rtcPttt|jSr|)hash frozensetrrrps rr__hash__z_LiteralGenericAlias.__hash__Zs "6t}}"EFG GrtN)rvrwrxrrrortrrrrRs  < HrtrceZdZdefdZdZy) _LiteralFormrc.d|_|x|_|_y)Nr6)r_docr)rqrs rr__init__z_LiteralForm.__init__^s"DJ'* *DI rtcrt|ts|f}t|}tt |} t |}t |t |krHg}|D],}||vs|j|d|j|.|rJ|t|} t||S#t$rYwxYw)Nr) r}rrlistrrrrremoverr)rqrval_type_pairs deduped_pairsnew_parameterspairs rrrz_LiteralForm.__getitem__bsj%0(] 0 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 rrr8r8sg< D*d +  q|| ,Q^^ < ))     s7A AAct|d|}|jtvrgSt|j}|j|vrgSt ||jj S)z6Return all defined overloads for *func* as a sequence.r)rrwrrxrvalues)r rmod_dicts rrr,r,s` D*d + <<1 1I%all3 >> )IHQ^^,33566rtc,tjy)z$Clear all overloads in the registry.N)rclearrortrrr)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]`}|jdvrt|di}g|j|D].}|j dr|t vs|j|0b|S)N>rQr:r_abc_)r__mro__rvrr startswith_EXCLUDED_ATTRSadd)rattrsbase annotationsattrs rr_get_protocol_attrsr6sz EE CR  ==3 3 d$5r: 2dmm2k2DOOG,_1L $3 ! Lrtc Bg}d|jvrt|j}d}|jD]o}t|tj s|j tjtfvsA|j j}| td|j}q||}ndt|}t||ksGdjfd|D}djd|D}td|dd |d |}t||_ y) 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|]}|vst|ywr|r)rrgvarsets rrrz+_maybe_adjust_parameters..:s"M5aAW.;s"95a3q65zSome type variables (z) are not listed in [])rrrr}rrr%rQr:rvrrzrjoinr) rrgvarsr3the_basetvarsets_varss_argsr;s @rr_maybe_adjust_parametersrGs' E3<<'"3#5#56 &&D4!5!56OO'AA??33$#@AA++' =E%jG%jGg%"M5"MM"95"99"7x@22:1VHA!GHHEuCrtc tj|jjddS#tt f$rYywxYw)Nrv__main__)sys _getframe f_globalsgetr ValueErrordepths rr_callerrQBs@}}U#--11*jII J 's.1AAct|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)rQrOs rr_allow_reckless_class_checksrUNs u~!;;;rtcDt|jr tdy)Nz Protocols cannot be instantiated)rrrrqrrs rr_no_initrXUs : " ">? ? #rtc6eZdZdZdZdZdZdZdefdZ y) _ProtocolMetac |dk(rt|dkrnttht|zrp|D]k}|tt j tthvr&|jtj|jgvrSt|r_td|tjj||||fi|S)Nr:rz5Protocols can only inherit from other protocols, got )rr:_typing_ProtocolrobjectrrQrv_PROTO_ALLOWLISTrMrwr4rrSABCMetar)mclsrbases namespacerr3s rrrz_ProtocolMeta.__new__jsz!c%j1n,-E :!DCS TT==,<,@,@RT,UU&t,'##'(, ";;&&tT5)NvN Nrtctjjg|i|tddr4t _t fdj D_yy)NrFc3JK|]}tt|dywr|)callabler)rr5rs rrrz)_ProtocolMeta.__init__..s$:CY4HWS$56CY #)rSr_rrr6rallr!rrrs` rrrz_ProtocolMeta.__init__zs_ KK  6t 6v 6sNE2)  &S &rtrZct|jjddstS|jD]}|jD]o}||jvr|j| tccS;t |di}t |tjjs^||vsct|sotcSy)NrFrT) rrMrrr.rr} collectionsrSrYr4)rrr5r3r4s rrrlrls||6! !**D 4==(}}T*2--&d,=rB {KOO,C,CD +#E*& &%#+$rtcVeZdZejj ZdZdZdZfdZ xZ S)r:roTFc:t||i||jjdds!t d|j D|_d|jvr t|_|j r)|jtjur t|_ yyy)NrFc3,K|] }|tuywr|r:rbs rrrz-Protocol.__init_subclass__..*P-Q1=-r) r__init_subclass__rrMany __bases__rrlrrr:rXrs rrrzProtocol.__init_subclass__s)4:6:||''>'**P#--*P'PC$&S\\9+6C(## 8I8I(I#+CL)J#rt) rvrwrxrr:rrrrrrrs@rrr:r:s,oo--GIL#(  , ,rtr:cXeZdZdZdZdZdZfdZejdZ 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: ... roTFcH|tur tdt| |S)NzIType Protocol cannot be instantiated; it can only be used as a base class)r:rrr)rrkwdsrs rrrzProtocol.__new__ s.(?#%JKKws++rtcXt|ts|f}|s+|tjurt d|j ddtfd|D}|t urtd|DsYd}t||tjr#|dz }t||tjr#t d|dzd ||tt|t|k7r+t d t||t|jtj||S) NzParameter list to z[...] cannot be emptyz*Parameters to generic types must be types.c3JK|]}tj|ywr|rrrrmsgs rrrz-Protocol.__class_getitem__...sJ6av11!S96rfc3PK|]}t|tj ywr|)r}rr r~s rrrz-Protocol.__class_getitem__..1sMfz!V^^>STVVBJ6JJ(?MfMM(FNNCFA)FNNC'**+a%VAYKABB3v;'3v;6'LNN#3C4F4F0GH++C88rtcd|jvrtj|jv}ntj|jv}|r t dt ||jjdds!td|jD|_ d|jvr t|_ |jr)|jtjur t|_ yyy)Nrz!Cannot inherit from plain Genericrc3,K|] }|tuywr|r}r~s rrrz-Protocol.__init_subclass__..Krrr)rrrQrrrrGrMrrrlrrr:rX)rrrerrors rrrzProtocol.__init_subclass__@s#s||3"NNc.@.@@E"NNcmm;E#$GHH(-||''='**P#--*P'PC$&S\\9+6C(## 8I8I(I#+CL)J#rt) rvrwrxrrrrrr _tp_cacher(rrrs@rrr:r:s> :IL#(  ,    9 92 ,rtct|tst|tjr t |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)r}rZ issubclassrrQrrrrvs rrr=r=YsP] +z#v~~/N^U3$$'7,- -#'  rtc>eZdZdZdZej defdZy)r$z(An ABC with one abstract method __int__.rortcyr|rorps rr__int__zSupportsInt.__int__~ rtN) rvrwrxrrrSabstractmethodrwrrortrrr$r$ys)6   S   rtr$c>eZdZdZdZej defdZy)r"z*An ABC with one abstract method __float__.rortcyr|rorps rr __float__zSupportsFloat.__float__rrtN) rvrwrxrrrSrfloatrrortrrr"r")8   u   rtr"c>eZdZdZdZej defdZy)r!z,An ABC with one abstract method __complex__.rortcyr|rorps rr __complex__zSupportsComplex.__complex__rrtN) rvrwrxrrrSrcomplexrrortrrr!r!s):      rtr!c>eZdZdZdZej defdZy)r z*An ABC with one abstract method __bytes__.rortcyr|rorps rr __bytes__zSupportsBytes.__bytes__rrtN) rvrwrxrrrSrbytesrrortrrr r rrtr c:eZdZdZej defdZy)r#rortcyr|rorps rr __index__zSupportsIndex.__index__rrtN)rvrwrxrrSrrwrrortrrr#r#s&   s   rtr#c>eZdZdZdZej defdZy)rz_ An ABC with one abstract method __abs__ that is covariant in its return type. rortcyr|rorps rr__abs__zSupportsAbs.__abs__rrtN) rvrwrxrrrSrrrrortrrrrs-    T   rtrcDeZdZdZdZej ddedefdZ y)r%za An ABC with one abstract method __round__ that is covariant in its return type. rondigitsrtcyr|ro)rqrs rr __round__zSupportsRound.__round__rrtN)r) rvrwrxrrrSrrwrrrortrrr%r%s4    S    rtr%cfd}|S)Nctjjdk(r\tjdkrIt |t d}t |j d|}tj||S|_ |S)Npypyr)__call____mro_entries__ro) rJimplementationr version_info staticmethodrrvrTupdate_wrapperr)r cls_dictr mro_entriess rrinnerz#_ensure_subclassable..innersq    " "f ,1A1AF1J(.#/ #<HT]]B1A++AC6 6#.D Krtro)rrs` rr_ensure_subclassablers  Lrt)r module _Protocolc"eZdZddZeZdZeZy)_TypedDictMetac |D]1}t|tus|tjus(t dt d|Drtjf}nd}tj ttg|t|}||_ |jtk(r||_ t|ds||_ i}|jdi} d} trD| jD cic](\} } | tj | | |j"*} } } n7| jD cic]\} } | tj | | } } } t%} t%}|D]}|j'|j(jdi| j'|j(jdd|j'|j(jd d|j'| | jD]\}}t+|}|t,urt/|}|r|d }t+|}|t0ur| j3|P|t4ur|j3|j|r| j3|~|j3|||_t9| |_t9||_t|d s||_|Scc} } wcc} } w) 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 classc3PK|]}t|tj ywr|)rrrQr~s rrrz)_TypedDictMeta.__new__..s@%Q:a0%rrorrz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typer__required_keys____optional_keys__r __total__) rrrrQrrr _fake_namedictrvrxrrrM _TAKES_MODULEitemsrrwrupdaterr/r&r.rEr1rFrrrrr)rrranstotalr3 generic_basetp_dictr4own_annotationsrntp required_keys optional_keysannotation_keyannotation_typeannotation_originannotation_argss rrrz_TypedDictMeta.__new__s:^3FNN8R#%EFF @%@@ &0 ! ll>:?T?Tt?TVXYG#G ##z1'+$7$45).&K ff%6;OSC"1!6!6!8#!82v))"c':L:LMM!8 #"1!6!6!8#!82v))"c22!8 # EMEM""4==#4#45F#KL$$T]]%6%67JB%OP$$T]]%6%67JB%OP    /3B3H3H3J/$.$?!$ 1&.&?O&*9!*<,6,G)$0!%%n5&+5!%%n5!%%n5!%%n54K"'2G #(1-(@G %(1-(@G %7K0$)!NQ# #s )-K-!K!ctd)Nz4TypedDict does not support instance and class checksrrms rrrkz _TypedDictMeta.__subclasscheck__/sRS SrtN)T)rvrwrxrrrrkrrortrrrrsH T T.rtrrroctfSr|) _TypedDictras rrr7s rtrc b|tus|@|turd}nd}d|d|d}|d|zdz}tj|td |}n |r t 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. 2Failing 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) rwarningswarnDeprecationWarningrrrQrrr) __typename__fieldsrrdeprecated_thingexampledeprecation_msgrrtds rrrr7s` w ("27"#W #M *]:.IG#$%OO  O MM/+=! LH ,- -  MM;#   h 0  %B|  JBe <&L rtchttdr|tjuryt|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 rrr5r5s, 6; 'B&2B2B,B".//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  rtrEc\t|trt|jSt |dr0|jt t fvrt|jdSt|tjr>td|jD}||jk(r|S|j|St tdrgt|tjrMtd|jD}||jk(r|Stj|j|St tdrkt|tjrQtd|jD}||jk(r|Stj t"j$|S|S)z=Strips Annotated, Required and NotRequired from a given type.r%rc32K|]}t|ywr| _strip_extrasras rrrz _strip_extras..!GJq-"2Jr>rc32K|]}t|ywr|rrs rrrz _strip_extras..rr>rc32K|]}t|ywr|rrs rrrz _strip_extras..rr>)r}_AnnotatedAliasrr%rrErFrrrr copy_withrrrrTreduceoperatoror_)r stripped_argss rrrrs; a ) . . 1l # ;8O(O A/ / a-- .!!GAJJ!GGM *;;}- - 6> *z!V=P=P/Q!!GAJJ!GGM *&&q||]C C 6; 'Jq&:J:J,K!!GAJJ!GGM *##HLL-@ @rtFcttdrtj|||d}ntj|||}|r|S|jDcic]\}}|t |c}}Scc}}w)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 )rrr2rr)rr r r hintkrs rrr2r2sr@ 6; '((hD((xQD K04 = 1=## ===sA4r&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|||||_yr|)r}r __metadata__r%rr)rqoriginmetadatars rrrz_AnnotatedAlias.__init__ s?&/2!..9** G VV , (D rtcXt|dk(sJ|d}t||jS)Nrr)rrr)rqrnew_types rrrz_AnnotatedAlias.copy_withs0v;!# ##ayH"8T->->? ?rtcdtj|jddjd|jDdS)Nztyping_extensions.Annotated[r8c32K|]}t|ywr|)reprrs rrrz+_AnnotatedAlias.__repr__..s D2CQa2Cr>r@)r _type_reprr%rArrps rrrsz_AnnotatedAlias.__repr__sE263D3DT__3U2VVXyy D$2C2C DDEQH Irtcbtjt|jf|jzffSr|)rgetitemr&r%rrps rr __reduce__z_AnnotatedAlias.__reduce__s1##DOO-0A0AA& rtct|tstS|j|jk7ry|j|jk(S)NF)r}rrr%rrqrs rrrz_AnnotatedAlias.__eq__!s>e_5%%%"2"22$$(:(:: :rtcDt|j|jfSr|)rr%rrps rrrz_AnnotatedAlias.__hash__(s$*;*;<= =rt) rvrwrxrrrrsrrrrrs@rrrrs(  ) @  I   ; >rtrcDeZdZdZdZdZejdZdZ y)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()] roctd)Nz&Type Annotated cannot be instantiated.rrhs rrrzAnnotated.__new__NDE Ertct|trt|dkr tdtt 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) r}rrrrrr/rrr)rrallowed_special_formsrrrs rrr(zAnnotated.__class_getitem__Qsfe,F a!/00&.u$5 !&)$(==<++F1Is;VABZ(H"684 4rtc4td|jd)NCannot subclass z .Annotated)rrwrhs rrrzAnnotated.__init_subclass__`s "3>>"2*= rtN) rvrwrxrrrrrr(rrortrrr&r&+s4 @  F    5  5 rt)_BaseGenericAlias)rct|trtSt|tjt t ttfr |jS|tjurtjSy)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) r}rr&rr_typing_GenericAliasr&r r r%rQrs rrr/r/xsY b/ *  b6//1EGX(/; <==  >> !rtcVt|tr|jf|jzSt|tj t fr_t|ddry|j}t|tjjur|dturt|dd|df}|Sy)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,)r}rr%rrrr(rrr/ryrSrJEllipsisr)rress rrr.r.s b/ *MM#boo5 5 b6//1EF Gr:u-++C"~!9!99c!fH>TCH~s2w/Jrtr?ct|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?s4& 5677rta%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|ttfrtd|D|_y|tk7rt j |d|_yd|_y)Nc3HK|]}tj|dyw)Default must be a typeNr)rds rrrz_set_default..s&(:18A)/(:(:1>V(W18s "r1)r}rr __default__rrr) type_paramdefaults rr _set_defaultr6sP'E4=)!&(:18(:";  G !'!3!3G=U!V !% rtc6td}|dk7r||_yy)NrrOr)rQrw) typevarlikedef_mods rr _set_moduler:s"AG%%!( &rtceZdZdZdZeZy) _DefaultMixinzMixin for TypeVarLike defaults.roN)rvrwrxrrr6rrortrrr<r<s)IHrtr<ceZdZdedefdZy)_TypeVarLikeMeta_TypeVarLikeMeta__instancertc.t||jSr|)r}_backported_typevarlike)rr?s rrrz"_TypeVarLikeMeta.__instancecheck__s*c&A&ABBrtN)rvrwrxrboolrrortrrr>r>sC3C4Crtr>cDeZdZdZej ZdddedddZddZ y)r zType variable.NF)boundrrr5infer_variancecttdrtj|g|||||d}n3tj|g||||d}|r|s|r td||_t ||t ||S)Nr@rDrrrErDrrz1Variance cannot be specified with infer_variance.)rrr rN__infer_variance__r6r:) rrrDrrr5rE constraintstypevars rrrzTypeVar.__new__s 6? +nnTDKDu/8 4BDGnnTWKWu/8 WG9  !TUU)7G &Wg&Grtc(tdtd)Ntype 'z(.TypeVar' is not an acceptable base typerrvrvs rrrzTypeVar.__init_subclass__s& *RSTTrtrtN) rvrwrxrrr rArrrrortrrr r s'$nn/3u$Urtr r c eZdZdZdZdZdZy) _Immutablez3Mixin to indicate that object should not be copied.roc|Sr|rorps rr__copy__z_Immutable.__copy__Krtc|Sr|ro)rqmemos rr __deepcopy__z_Immutable.__deepcopy__rTrtN)rvrwrxrrrSrWrortrrrQrQ sA   rtrQc"eZdZdZdZdZdZy)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||_yr|r%rqrs rrrzParamSpecArgs.__init__  $DOrtc4|jjdS)Nz.argsr%rvrps rrrszParamSpecArgs.__repr__#soo../u5 5rtc`t|tstS|j|jk(Sr|)r}r rr%rs rrrzParamSpecArgs.__eq__&s'e]3%%??e&6&66 6rtNrvrwrxrrrsrrortrrr r s  % 6 7rtc"eZdZdZdZdZdZy)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||_yr|rZr[s rrrzParamSpecKwargs.__init__7r\rtc4|jjdS)Nz.kwargsr^rps rrrszParamSpecKwargs.__repr__:soo../w7 7rtc`t|tstS|j|jk(Sr|)r}r rr%rs rrrzParamSpecKwargs.__eq__=s'e_5%%??e&6&66 6rtNr`rortrrr r +s  % 8 7rtr rcDeZdZdZej ZddddeddZddZ y)rzParameter specification.NFrDrrrEr5cttdrtj|||||}n tj||||}||_t ||t ||S)Nr@rGrH)rrrrIr6r:)rrrDrrrEr5 paramspecs rrrzParamSpec.__new__Kskv/",,T7@;H , G ,  " rtc(tdtd)NrMz*.ParamSpec' is not an acceptable base typerNrvs rrrzParamSpec.__init_subclass__^sfXJ.XYZ ZrtrO) rvrwrxrrrrArrrrortrrrrFs)&"("2"2(,#5#(' & [rtceZdZdZej ZedZedZ 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. ct|Sr|)r rps rrrzParamSpec.argss  & &rtct|Sr|)r rps rrrzParamSpec.kwargss "4( (rtNFrfc8t||g||_t||_t||_t||_|rtj|d|_ nd|_ tj||t}|dk7r||_ yy)NzBound must be a type.r) rrrvrB __covariant____contravariant__rIrr __bound__r<rQrw) rqrrDrrrEr5r9rs rrrzParamSpec.__init__s G dV $ DM!%iD %)-%8D "&*>&:D #!'!3!3E;R!S!%  " "4 1iG--").rtc~|jrd}n |jrd}n|jrd}nd}||jzS)N+-~)rIrnrorv)rqprefixs rrrszParamSpec.__repr__s@&&##''DMM) )rtc,tj|Sr|r]rrps rrrzParamSpec.__hash__??4( (rtc ||uSr|rors rrrzParamSpec.__eq__ 5= rtc|jSr|rvrps rrrzParamSpec.__reduce__ == rtcyr|rorWs rrrzParamSpec.__call__ rt)rvrwrxrrr rpropertyrrrrrsrrrrrrs@rrrresf, ^NN  '  '  )  )+/%u$)7 *$ * ) ! ! rtrc\eZdZejZdZfdZdZdZ dZ e dZ xZ S)_ConcatenateGenericAliasFc@t||||_||_yr|)rrr%r)rqrrrs rrrz!_ConcatenateGenericAlias.__init__s G T "$DO DMrtctj|jddjfd|jDdS)Nr?r8c3.K|] }|ywr|ro)rargrs rrrz4_ConcatenateGenericAlias.__repr__..s!K]c*S/]sr@)rrr%rAr)rqrs @rrrsz!_ConcatenateGenericAlias.__repr__sF**J!$//23 !KT]]!KKLAO PrtcDt|j|jfSr|)rr%rrps rrrz!_ConcatenateGenericAlias.__hash__s$--89 9rtcyr|rorWs rrrz!_ConcatenateGenericAlias.__call__rrtc:td|jDS)Nc3bK|]'}t|tjtfs$|)ywr|)r}rr r)rrs rrrz:_ConcatenateGenericAlias.__parameters__..s&*rjfnni=X.Y]s%//)rrrps rrrzz'_ConcatenateGenericAlias.__parameters__s !]] rt)rvrwrxrrrrrrsrrrrzrrs@rrrrs@((  !  P  :     rtrc|dk(r tdt|ts|f}t|dts tddtfd|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.c3JK|]}tj|ywr|rrs rrrz'_concatenate_getitem..sF:av))!S1:rf)rr}rrr)rqrrs @rr_concatenate_getitemrsjR@AA j% ( ] jni 0./ / ;CF:FFJ #D* 55rtct||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. rr.s rrrrs$D*55rtceZdZdZy)_ConcatenateFormct||Sr|rr.s rrrz_ConcatenateForm.__getitem__s'j9 9rtNrrortrrrrs :rtrrrAcbtj||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's4X!!*6R.ST##D4'22rtceZdZdZy)_TypeGuardFormcvtj||jd}tj||fS)Nz accepts only a single typerrs rrrz_TypeGuardForm.__getitem__Xs9%%j)- 4O&PRD''tg6 6rtNrrortrrrrWrrtrrcpeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ejd Zy ) _SpecialForm)rr_getitemcV||_|j|_|j|_yr|)rrvrr)rqrs rrrz_SpecialForm.__init__s! %%  rtc8|dvr |jSt|)N>rvrx)rr)rqrs rr __getattr__z_SpecialForm.__getattr__s / /:: T""rtctd|)Nr%r)rqras rrrz_SpecialForm.__mro_entries__s*4(344rtc d|jSrrrps rrrsz_SpecialForm.__repr__s#DJJ<00rtc|jSr|rrps rrrz_SpecialForm.__reduce__s zzrtctd|)NzCannot instantiate rrqrrs rrrz_SpecialForm.__call__s-dX677rtc,tj||fSr|rrgrs rr__or__z_SpecialForm.__or__s||D%K((rtc,tj||fSr|rrs rr__ror__z_SpecialForm.__ror__s||E4K((rtct|d)Nz! cannot be used with isinstance()rrqrs rrrz_SpecialForm.__instancecheck__4& ABCCrtct|d)Nz! cannot be used with issubclass()r)rqrs rrrkz_SpecialForm.__subclasscheck__rrtc&|j||Sr|)rr.s rrrz_SpecialForm.__getitem__s}}T:..rtN)rvrwrxrrrrrsrrrrrrkrrrrortrrrrsU0I' # 518))DD //rtrrct|d)aPRepresents an arbitrary literal string. Example:: from pip._vendor.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"4& 5677rtr ct|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 s4& 5677rtrCct|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 pip._vendor.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 rrrCrCs04& 5677rtcvtj||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 rrrErEs7"!!* 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|jywr|) __unpacked__rps rr__iter__zTypeVarTuple.__iter__s## #src||_tj||t}|dk7r||_t ||_y)Nr)rvr<rrQrwrr)rqrr5r9s rrrzTypeVarTuple.__init__s> DM  " "4 1iG--") &t D rtc|jSr|r}rps rrrszTypeVarTuple.__repr__r~rtc,tj|Sr|rxrps rrrzTypeVarTuple.__hash__ryrtc ||uSr|rors rrrzTypeVarTuple.__eq__r{rtc|jSr|r}rps rrrzTypeVarTuple.__reduce__r~rtc"d|vr tdy)Nrrrrs rrrzTypeVarTuple.__init_subclass__sd" HII#rtN)rvrwrxrrr rrrrrsrrrrrortrrrrs<) XNN  $-4 - ! ) ! ! Jrtr;__objrtchtdt|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)printrrvrJstderr)rs rrr;r; s*  e!5!5 89 K rtr'__argctd)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 pip._vendor.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 1I - rtro)rrrrrrrs`````` rrr*r*8 sR  rtr9_F)rDcB d|_|S#ttf$rY|SwxYw)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 s64 !%E    *    rr+_Trcategoryr__msgrrc4dtdtffd }|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 _Sttrijjt jut jfd}t|_x_|_Str0t jfd}x_|_|Std)Nctjdztjur |g|i|Ss|s|rt |j d|S)Nrrz() takes no arguments)rrr]rrrv)rrrrrhas_init original_newrs rrrz.deprecated..decorator..__new__ sbMM%(zTU~V#6>>9+CA$A&AA%46'3<<.8M(NOO+C00rtcJtjdz|i|S)Nrr)rr)rrrrrrs rrwrapperz.deprecated..decorator..wrapper s(MM%(zTU~V $1&11rtzY@deprecated decorator with non-None category must be applied to a class or callable, not ) __deprecated__r}rrrr]rTwrapsrrer)rrrrrrrrs` @@rrrzdeprecated..decorator s',$ E4($}}  >>@.1/1!-W 5 @EE$w'= %'2(2AFE$w'=005y:rt)r)rrrrs``` rrr+r+ s X" R" B" Hrtc 6|Dcgc]\}}| }}}|Dcic] \}}|tj|d|d"}}}tj||||}|x|_|j _t jdkr||_|Scc}}wcc}}w)Nzfield z annotation must be a typedefaultsrr) rrry namedtuplerrrJr _field_types) rrrrrrfieldsr4nm_tpls rr _make_nmtupler # s %&1!&#(*#(41a&,,Q&;U0VWW#( *''f19&JBMM!?   f $"-F  '*s B%B>rvrwrceZdZdZy)_NamedTupleMetac t|vsJ|D](}|tus |tjustdt d|D}|j di}g}|D]M}||vr|j ||std|dt|dkDrdndd d j|t||j|Dcgc]}|| c}|d  } || _ tj|vrcttd rttj| _n4tjjj } t| | _|D]@} | t"vrt%d| z| t&vs"| | j(vs1t+| | || Btj|vr| j-| Scc}w)Nz3can only inherit from a NamedTuple type and Genericc3<K|]}|turtn|ywr|) _NamedTupler)rr3s rrrz*_NamedTupleMeta.__new__..: sSUT4;#6%D@UrrzNon-default namedtuple field z cannot follow default fieldrsrr r8rwr_generic_class_getitemz&Cannot overwrite NamedTuple attribute )rrrQrrrMrrrAr rrr classmethodrr(r_prohibited_namedtuple_fieldsr_special_namedtuple_fields_fieldssetattrr) rtypenamerarr3r default_names field_namerr class_getitemkeys rrrz_NamedTupleMeta.__new__4 s%' ''{*t6>>/I#MOOSUSSEFF,b1EM# #!((4"#&CJ<PB.1-.@1.Ds"&MQ'+yy'?&@%BCC $#%++-)67A"Q%7,'F %F ~~&6#; 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|Sr|rors rrrzNewType.__call__ sJrtc||_d|vr|jdd}||_||_t }|dk7r||_yy)Nrr,r)rx rpartitionrv __supertype__rQrw)rqrrr9s rrrzNewType.__init__ sO $D d{s+B/ DM!#D iG--").rtc:|jGfdd}|fS)NceZdZfdZy)&NewType.__mro_entries__..Dummyc F|j}td|d|dd)NzGCannot subclass an instance of NewType. Perhaps you were looking for: `z = NewType(r8z)`)rvr)r subcls_name supercls_names rrrz8NewType.__mro_entries__..Dummy.__init_subclass__ s8"%,,K#'= K?"]OSUWrtN)rvrwrxr)r.srrDummyr+ srtr/r})rqrar/r.s @rrrzNewType.__mro_entries__ s!!MMM  8Ortc8|jd|jS)Nr)rwrxrps rrrszNewType.__repr__ soo&a(9(9':; ;rtc|jSr|)rxrps rrrzNewType.__reduce__" s$$ $rtrc,tj||fSr|rrs rrrzNewType.__or__) s||D%K00rtc,tj||fSr|rrs rrrzNewType.__ror__, s||E4K00rtN) rvrwrxrrrrrsrrJrrrrortrrr7r7 s?   *   < %   w & 1 1 'rtr7r@cv|duxs4t|ttjtjt fS)z:Corresponds to is_unionable() in unionobject.c in CPython.N)r}rrrrr@rs rr _is_unionabler53 s9d{ j         /   rtceZdZdZdddefdZdededd ffd Zdedefd Z dedefd Z defd Z dZ dZ dZdZej"dk\r 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_paramsrc(t|ts td||_||_g}|D]5}t|t r|j |%|j|7t||_ t}|dk7r||_ ||_ y)Nz#TypeAliasType name must be a stringr) r}rr __value__r*rrrrrzrQrwrv)rqrvaluer7rr4r9s rrrzTypeAliasType.__init__X sdC( EFF"DN#.D J) j,7%%j1%%j1 * #( "3D iG--") DMrt_TypeAliasType__name_TypeAliasType__valuertNc`t|dr|j|t| ||y)Nrv)r_raise_attribute_errorr __setattr__)rqr;r<rs rrr?zTypeAliasType.__setattr__k s*tZ(++F3 G  0rtc&|j|yr|)r>)rqr;s rr __delattr__zTypeAliasType.__delattr__p s  ' ' /rtcf|dk(r td|dvrtd|dtd|d)Nrvzreadonly attribute>r9rwrzr*z attribute 'z3' of 'typing.TypeAliasType' objects is not writablez0'typing.TypeAliasType' object has no attribute '')r)rqrs rrr>z$TypeAliasType._raise_attribute_errors sXz!$%9::YY$!$(&& %FtfANrtc|jSr|r}rps rrrszTypeAliasType.__repr__ r~rtc t|ts|f}|Dcgc]&}tj|d|jd(}}tj |t|Scc}w)Nz Subscripting z requires a type.)r}rrrrvrrs rrrzTypeAliasType.__getitem__ svj%0(] ' 'D""M$--8IJ'  ''eJ.?@ @ s+A$c|jSr|r}rps rrrzTypeAliasType.__reduce__ r~rtctd)NzEtype 'typing_extensions.TypeAliasType' is not an acceptable base typerrhs rrrzTypeAliasType.__init_subclass__ sW rtctd)NzType alias is not callablerrps rrrzTypeAliasType.__call__ s89 9rtrcNt|stStj||fSr|r5rrrg)rqrights rrrzTypeAliasType.__or__ s%%U+))||D%K00rtcNt|stStj||fSr|rJ)rqlefts rrrzTypeAliasType.__ror__ s#$T*))||D$J//rt)rvrwrxrrrr]r?rCrAr>rsrrrrrJrrrrrs@rrr@r@< s 6=? ! !& 1c 1F 1t 1  0c 0e 0 s u  !c ! A !  :   w & 1 0 'rtr4__tpct|txr4t|ddxr%|tuxr|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:)r}rrr:rr]rNs rrr4r4 sN tT " Bne4 BH$ BGFJAA  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)r4rrrrr6rPs rrr1r1 sL4 th&89: : 4- .T445 5,T233rtr|)r)r)NNF)ro)rSrycollections.abcrTrorrJrrrr__all__PEP_560r GenericMetarmrrrrrrDr rrrrrrrrrrrrrr-r3r6rrrrrr r8r,r) defaultdictpartialrrr rrrrrrrrr_aliasrrrr>rBr^r0r1rr6rGrQr:rUrXr\_ProtocolMetaBaser_rZrrlrQr=r<r$r"r!r r#rr%rrrr5 signaturerrrrrrrr(r2rr&rr/r.r& ImportErrorrr(r?r6r:r<r>r r rQrrrrrrrrAr_Finalrr rCrErFrrrrrrrrr;r'r*rBrfrgrJr9rr+rrrr_Warningrwrr  _prohibitedrrr rr_new_signaturer} FunctionType__text_signature__rrABCregister memoryview bytearrayrr0r7r@r5r4r1rOrGrHrIrKrLrMrNrPrRrSrTrUrVrWrXrYrZr[r\r]r^r`rarbrcrdrerhrirjrkrortrrrfs   u p   +*1<*w  JF* ??FNN3V^^DV^^Dv~~f- 6>>*D 9w &4 & 9 9 ??1V001 67 0 0! 4 > LLE7+47 w L MEw LLE @ z!nnG Hv334 H:-T:< 1 2G(( 6?#H((M,,O100 +1148&P 7# {{       $$ $$  &&00   6=!$$K &-- 7 7"bBK .. ??&& {{$$ ,-JK" fO v+,w)*O, %&PwH<@ 6!"?? !12"KKf&)f&P0 6! ,v~~ ,,X ,X ,vv00& w$$K((M,,O((M((M$$K((Mh(htn w  I**N&&L 1 1 1&2D2D E P PPM 6!  Q.Q.fnk2rBJ56'.QQ7Qfv'("11>B*,0" 6=!$$K   6:**N0(>X 6;  I,,O%>&..d%>N88zBQ7"""JH1,4?00 6;  IbqV# 8 8'  I&)CtC U(U8 6?#((M,,O7 7.7*70 6;[.[>bD-bLv}%4B 6 6 6=!$$K%>>bqV# 6 6:1:#   K 6;  IbqV#,3,3^7/t7 ) + I^(/6==(/V 6?#((M88& 66 ;;D88" 67 LLE884 6:H$$KbqV#33&33"7.d7   H"    K ' Tw ]]F) bqV#'34' #v++4#++-#v++4#/,D/ { 3F- 6>" F!1 FKJ}KJ\ 6=!$$K1( 6>"&&L@E@e@.w 44 # %$ SSS S  S !,, LLVZZ0&//#vzz/2RR S   S**S !a Sl 6:H FOOCO$D EB!!r!H 6< ""J  B ;M PP//&++g"67P P "r " Ptv~& 2F*Fw""J %+$6$6!!*+X!Y&$&P,, b"EK12(/?3?H 6!? j&"5"5 6,:J )5CJ   2 ;??H% __ # #F  * OOJ OOI OOE 6'(22DwnnG9191x 6?#((M k0k0\ 6=!$$K!66 $ 4 *444F,<,