_i8ddlZddlZddlZddlZddlZddlZddlZddlZgdZ dZ e Z e ZefdZej dk\rdZnej dk\rdZnd Zdd Zej&Zej(d Zej(d Zej(d Zej(ddZej(ddZej dk\rddlmZnGdde ZGddeZej8Zeedrej dddk\r ej<Zn!Gddej>dZ e dd Zej dk\r ejBZ!nd!Z!d"Z"eed#r ejFZ#n!Gd$d%ej>dZ$e$d#d& Z#ejJZ%eed'r%ejLZ&ejNZ'ejPZ(n6ejRejTejRe+Z,d(Z&d)Z'd*Z(ejZZ-ej\Z.ej^Z/ej`Z0ejbZ1ejdZ2ejfZ3ejhZ4ejjZ5eed+r ejlZ6nejnejleefZ6ejpZ8ejrZ9ejtZ:ejvZ;ejxZd-Z?d.Z@d/ZAeed0r ejZBn$d1ZCGd2d3ejZEGd4d0eEZBeed5r ejZFnd6ZFeFZGeed7r ejZHneFGd8d7eBZHeed9r%ejZIejZJejZKn\d:ZLd;ZMdZOd?eO_NGd@dAe ZJeJdBe+fiZIePeI_QdCeI_ReedArejeJfZSneJfZSdDZKeedEr ejZTndFZTeed9r ejZUnddlZddlZdGZVddIZUeedJrejZWejZXn!GdKdLejdZXGdMdJZWej dddk\rejZZejZ[n ddNlm\Z\ ddOlm^Z_dPZZdQZ[eedRr ejZ`nSej dddk\r GdSdTej>dZaeadUZ`n!GdVdTej>dZaeadRdW Z`GdXdYZbGdZd[ej(ebdZeed\rejZcejZdn Gd]d^ZeGd_d\eeZcGd`daeeZdeedbrGdcdbejebdZfn GdddbegebZfeedes GdfdgegZhejdhZjeederejZkejZhndZleldedl Zkeedmr ejZmnSej dddk\r Gdndoej>dZnendpZmn!Gdqdoej>dZnendmdr ZmGdsdtejdZeedur ejZpnedvZpeedwr ejZqnedxZqeedyr ejZrnedzZreed9rejZsejZtneej dddk\r(Gd{d|ej>dZueud}Zseud~Ztn+Gddej>dZvevd9d Zsevdd Zteedr ejZwnej dddk\r:Gddej>dZxGddejdZyexdZwdZzn;GddejdZyGddej>dZ{e{dd ZwdZzeedrGddejebdZ|n GddebZ|eedr ejZ}ndedefdZ}eedr ejZ~nderderfdZ~eedr ejZnddHdHdddedededejejejZej4ejdej4ffdfdej4dejegeff dZeedrejZn6ej(dejdej4fZdedefdZeedsee_ee_ej dk\rej ZydZddZejZehdZGdde ZddZej je_Re jeddiZej dk\rde_NdZee_y#e]$rejZ\YwxYw#e]$rejZ_YwxYw)N)8AnyClassVar ConcatenateFinal LiteralString ParamSpec ParamSpecArgsParamSpecKwargsSelfTypeTypeVar TypeVarTupleUnpack Awaitable AsyncIterator AsyncIterable CoroutineAsyncGeneratorAsyncContextManagerChainMapContextManagerCounterDeque DefaultDict NamedTuple OrderedDict TypedDict SupportsIndex Annotated assert_never assert_typeclear_overloadsdataclass_transform get_overloadsfinalget_args get_originget_type_hintsIntVar is_typeddictLiteralNewTypeoverloadoverrideProtocol reveal_typeruntimeruntime_checkableText TypeAlias TypeGuard TYPE_CHECKINGNeverNoReturnRequired NotRequiredTc |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 /builddir/build/BUILDROOT/alt-python312-setuptools-69.0.2-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pkg_resources/_vendor/typing_extensions.py z!_check_generic..gsPZ 1l ;ZrNzToo manyfewz parameters for z ; actual z , expected ) TypeError_markerhasattrr<len _is_unpacksum)cls parameterselenalenrB num_tv_tupless rC_check_genericrSYs 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 rC_should_collect_from_parametersr^os- $$f&9&96;K;KL  rT cVt|tjtjfSr>)r?rWrXrYrZr\s rCr^r^ts !f22F4G4GHIIr_cTt|tjxr |j Sr>)r?rWrX_specialr\s rCr^r^ws !V112E1::~Er_c$|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) ) rWr r?rLappendr^extendr<tuple)types typevar_typestvarsr]s rC_collect_type_varsrl{s  E  q- ( UN1 LLO *1 - LLQ%5%5H%5%!%5H I <Is + B 5B TKTVTT_co) covariantT_contra) contravariant)rT )rc(eZdZfdZfdZxZS)_AnyMetacH|tur tdt| |S)Nz6typing_extensions.Any cannot be used with isinstance())rrHsuper__instancecheck__)selfobj __class__s rCryz_AnyMeta.__instancecheck__s&s{ XYY7,S1 1r_c2|turyt| S)Nztyping_extensions.Any)rrx__repr__)rzr|s rCr~z_AnyMeta.__repr__ss{.7#% %r_)__name__ __module__ __qualname__ryr~ __classcell__r|s@rCrvrvs 2  & &r_rvc"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)rrHrx__new__)rNargskwargsr|s rCrz Any.__new__s/cz <==7?3888 8r_)rrr__doc__rrrs@rCrrs  9 9r_r) metaclassr)rTceZdZdZdZy) _FinalFormc d|jzSNztyping_extensions._namerzs rCr~z_FinalForm.__repr__'$**4 4r_cvtj||jd}tj||fSN accepts only a single type.rW _type_checkrrXrzrOitems rC __getitem__z_FinalForm.__getitem__9%%j)- 4P&QSD''tg6 6r_Nrrrr~rr_rCrr  5 7r_r)_rootaWA 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__AttributeErrorrH)fs rCr%r%s5, AK   *    s  c,tj|Sr>)rWr )names rCr)r)s >>$ r_r+ceZdZdZdZy) _LiteralFormc d|jzSrrrs rCr~z_LiteralForm.__repr__ rr_c.tj||Sr>)rWrXrzrOs rCrz_LiteralForm.__getitem__s''j9 9r_Nrrr_rCrr s  5 :r_raoA 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 <tS#t $rYtSwxYw)aDecorator for overloaded functions/methods. In a stub file, place two or more stub definitions for the same function in a row, each decorated with @overload. For example: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... In a non-stub file (i.e. a regular .py file), do the same but follow it with an implementation. The implementation should *not* be decorated with @overload. For example: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... def utf8(value): # implementation goes here The overloads for a function can be retrieved at runtime using the get_overloads() function. __func__)getattr_overload_registryrr__code__co_firstlinenor_overload_dummy)funcrs rCr-r--sg< D*d +  q|| ,Q^^ < ))     s7A AAct|d|}|jtvrgSt|j}|j|vrgSt ||jj S)z6Return all defined overloads for *func* as a sequence.r)rrrrlistvalues)rrmod_dicts rCr$r$Us` D*d + <<1 1I%all3 >> )IHQ^^,33566r_c,tjy)z$Clear all overloads in the registry.N)rclearrr_rCr"r"`s  "r_r) CallablerIterableIteratorrrHashableSized Container Collection ReversiblerrcNt}|jddD]}|jdvrt|di}t |j j t |j zD]*}|jdr|dvs|j|,|S)N)r/Generic__annotations___abc_)__abstractmethods__r __weakref__ _is_protocol_is_runtime_protocol__dict____args__ __slots____next_in_mro__r< __origin____orig_bases__ __extra__ __tree_hash__r__subclasshook____init__rr_MutableMapping__marker_gorg) set__mro__rrrrkeys startswithadd)rNattrsbase annotationsattrs rC_get_protocol_attrsrs EE CR  ==3 3 d$5r: ++-.k6F6F6H1IIDOOG,>F2F $J ! Lr_c>tfdtDS)Nc3JK|]}tt|dywr>)callabler)rArrNs rCrDz,_is_callable_members_only..s"W>VdxT401>V #)allrrNs`rC_is_callable_members_onlyrs W>QRU>VW WWr_c Xg}d|jvrtj|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>str)rAr]gvarsets rCrDz+_maybe_adjust_parameters..s"M5aAWr)rAgs rCrDz+_maybe_adjust_parameters..s"95a3q65zSome type variables (z) are not listed in [])rrWrlrr?rXrrr/rrHr<rjoinrh) rNrkgvarsrthe_basetvarsets_varss_argsrs @rC_maybe_adjust_parametersrs- E3<<'))#*<*<= &&D4!5!56OO'AA??33$#@AA++' =E%jG%jGg%"M5"MM"95"99"7x@22:1VHA!GHHEuCr_r/cDt|jr tdy)Nz Protocols cannot be instantiated)typerrHrzrrs rC_no_initrs : " ">? ? #r_ceZdZfdZxZS) _ProtocolMetactddr trtjryjrt fdt Dryt!S)NrFTc3K|]9}t|xr'tt|d xst|du;ywr>)rJrr)rArrNinstances rCrDz2_ProtocolMeta.__instancecheck__..sV=$<4x.=$WS$%=>><$/t;=$ 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 act as simple-minded runtime protocol that checks 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: ... rTcH|tur tdt| |S)NzIType Protocol cannot be instantiated; it can only be used as a base class)r/rHrxr)rNrkwdsr|s rCrzProtocol.__new__s.h!FGG7?3' 'r_cXt|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>rWrrArBmsgs rCrDz-Protocol.__class_getitem__..sFv!6--a5vrc3PK|]}t|tj ywr>)r?rWr r@s rCrDz-Protocol.__class_getitem__..sI&Q:a8&$&rzBParameters to Protocol[...] must all be type variables. Parameter z is z.Parameters to Protocol[...] must all be unique)r?rhrWTuplerHrr/rr rKrrSr<rX)rNparamsir s @rC__class_getitem__zProtocol.__class_getitem__s"fe, c5()9)9(::OPRR>CFvFFFhI&IIA$VAY?Q%VAY?#&&'!eWD =>>s6{#s6{2#HJJsFC0B0B,CD''V4 4r_cdjvrtjjv}ntjjv}|r t dt jjdds!tdjD_ fd}djvr|_ jsyjD]p}|ttjfvr|jdk(r|jtvr>t|t r |jr[t dt#|t$_y) Nrz!Cannot inherit from plain Genericrc3,K|] }|tuywr>)r/)rAbs rCrDz-Protocol.__init_subclass__..3s&LmqH}mscjjddstStdds5t j dj ddvrtStdts5t j dj ddvrtStdt|ts td tD]}|jD]w}||jvr|j| tccS;t|d i}t|tjsT||vsYt|tsj|j swtcSy ) NrrFrr)abc functoolszBInstance and class checks can only be used with @runtime protocolsz._proto_hook6s>||''=))s$:EB}}Q'11*=AUU--#%:;;05}}Q'11*=AUU--#%BCC!%.#$HII/4D % 4==0#}}T2:'5 5!&-d4Er&J &{FNNC $ 3 *5- @ % 2 2!!. .-5r_rzcollections.abcz5Protocols can only inherit from other protocols, got )rrWrr __bases__rHrranyrrobjectrr_PROTO_WHITELISTr?rreprrr)rNrrerrorr"rs` rC__init_subclass__zProtocol.__init_subclass__(s3<</#*<*<<#--7 CDD $S )<<##ND9#&&Lcmm&L#L  >"5'2$##  88+<< )99"47Drrs rC __index__zSupportsIndex.__index__s r_N)rrrrrabstractmethodintr/rr_rCrrs&   s   r_r9c tjdjddvr td y#tt f$rYywxYw)Nrr)rrrWz4TypedDict does not support instance and class checksF)rrrrHr ValueError)rNr!s rC _check_failsr4s_ }}Q))*5>HH VWW H +   s/3AAcF|s td|d|dd}}t|i|S)N)TypedDict.__new__(): not enough argumentsrr)rHdict)rr_s rC _dict_newr9s4GH Hq'484T$V$$r_z,($cls, _typename, _fields=None, /, **kwargs)totalc|s td|d|dd}}|r |d|dd}}n=d|vr.|jd}ddl}|jdtdn td|r |\}nBd |vrF ,- - f . "}}Q/99==j*UB| hBe<<3 .!<)rxr)rNrbasesrHr;r|s rCrz_TypedDictMeta.__init__s G T5" -r_c |dk(rtnt|d<t| ||tf|}t d|Dr&t jtf|_t|i}|jdi}d}|jD cic]\} } | t j| |}} } t} t} |D]} |j| jjdi| j| jjdd| j| jjdd|j||jD]\}}t!|}|t"urt%|}|r|d }t!|}|t&ur| j)|P|t*ur| j)|j|r| j)|~| j)|||_t/| |_t/| |_t5|d s||_|Scc} } w) Nrrc3PK|]}t|tj ywr>)rrWrrArs rCrDz)_TypedDictMeta.__new__..sF:dFNN3rrz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type__required_keys__r__optional_keys__r __total__)rIr9rxrr7r$rWrr#rritemsrrupdaterr'rr&r9rr:r frozensetrPrQrJrR)rNrrLrHr;tp_dictrown_annotationsr ntp required_keys optional_keysrannotation_keyannotation_typeannotation_originannotation_argsr|s rCrz_TypedDictMeta.__new__s/3k.ANyByM goc4$"=GFFF%+^^T$:!(1K ff%6;OSC True is_typeddict(Union[list, str]) # => False )r?rh_TYPEDDICT_TYPESrYs rCr*r*?s"e$4566r_r!c|S)aAssert (to the type checker) that the value is of the given type. When the type checker encounters a call to assert_type(), it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # ok assert_type(name, int) # type checker error At runtime this returns the first argument unchanged and otherwise does nothing. r)__val__typs rCr!r!Qs  r_c\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.rrc32K|]}t|ywr> _strip_extrasrAas rCrDz _strip_extras..o!GJq-"2JrrZc32K|]}t|ywr>rirks rCrDz _strip_extras..trmrr[c32K|]}t|ywr>rirks rCrDz _strip_extras..yrmr)r?_AnnotatedAliasrjrrJr9r:rrWrXrh copy_withrirZr[rreduceoperatoror_)r] stripped_argss rCrjrjhs9 a ) . . 1l # ;8O(O A/ / a-- .!!GAJJ!GGM *;;}- - 5. )jE)r?rp __metadata__rrxr)rzoriginmetadatar|s rCrz_AnnotatedAlias.__init__s?&/2!..9** G VV , (D r_cXt|dk(sJ|d}t||jS)Nrr)rKrpr~)rzrnew_types rCrqz_AnnotatedAlias.copy_withs0v;!# ##ayH"8T->->? ?r_cdtj|jddjd|jDdS)Nztyping_extensions.Annotated[rc32K|]}t|ywr>)r'rks rCrDz+_AnnotatedAlias.__repr__..s D2CQa2Crr)rW _type_reprrrr~rs rCr~z_AnnotatedAlias.__repr__sE263D3DT__3U2VVXyy D$2C2C DDEQH Ir_cbtjt|jf|jzffSr>)rsgetitemrrr~rs rC __reduce__z_AnnotatedAlias.__reduce__s1##DOO-0A0AA& r_ct|tstS|j|jk7ry|j|jk(S)NF)r?rprrr~rzr!s rC__eq__z_AnnotatedAlias.__eq__s>e_5%%%"2"22$$(:(:: :r_cDt|j|jfSr>)hashrr~rs rC__hash__z_AnnotatedAlias.__hash__s$*;*;<= =r_) rrrrrrqr~rrrrrs@rCrprps(  ) @  I   ; >r_rpcDeZdZdZdZdZejdZdZ y)raAdd 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()] rctd)Nz&Type Annotated cannot be instantiated.rHrNrrs rCrzAnnotated.__new__sDE Er_ct|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?rhrKrHrrr'rWrrp)rNrallowed_special_formsrr rs rCrzAnnotated.__class_getitem__sfe,F a!/00&.u$5 !&)$(==<++F1Is;VABZ(H"684 4r_c4td|jd)NCannot subclass z .Annotated)rHrrs rCr)zAnnotated.__init_subclass__s "3>>"2*= r_N) rrrrrrrWr*rr)rr_rCrrs4 @  F    5  5 r_)_BaseGenericAlias)rZct|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?rprrWrX_typing_GenericAliasrr r rrrcs rCr'r''sY b/ *  b6//1EGX(/; <==  >> !r_cVt|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) rdFrrNr)r?rprr~rWrXrrrr' collectionsrrEllipsisr)rYress rCr&r&?s b/ *MM#boo5 5 b6//1EF Gr:u-++C"~!9!99c!fH>TCH~s2w/Jr_r4ceZdZdZy)_TypeAliasFormc d|jzSrrrs rCr~z_TypeAliasForm.__repr__\rr_Nrrrr~rr_rCrr[ 5r_rct|d)a&Special marker indicating that an assignment should be recognized as a proper type alias definition by type checkers. For example:: Predicate: TypeAlias = Callable[..., bool] It's invalid when used anywhere except as in the example above.  is not subscriptablerrs rCr4r4_s4& 5677r_ceZdZdZy)rc d|jzSrrrs rCr~z_TypeAliasForm.__repr__orr_Nrrr_rCrrnrr_aSpecial 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.ceZdZdZdZdZy) _DefaultMixinzMixin for TypeVarLike defaults.rct|ttfrtd|D|_y|rt j |d|_yd|_y)Nc3HK|]}tj|dyw)Default must be a typeNr )rAds rCrDz)_DefaultMixin.__init__..s&&8/6!'-&8&8rrs rC__copy__z_Immutable.__copy__Kr_c|Sr>r)rzmemos rC __deepcopy__z_Immutable.__deepcopy__rr_N)rrrrrrrrr_rCrrsA   r_rc"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>rrzrs rCrzParamSpecArgs.__init__ $DOr_c4|jjdS)Nz.argsrrrs rCr~zParamSpecArgs.__repr__soo../u5 5r_c`t|tstS|j|jk(Sr>)r?r rrrs rCrzParamSpecArgs.__eq__s'e]3%%??e&6&66 6r_Nrrrrrr~rrr_rCr r s  % 6 7r_c"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>rrs rCrzParamSpecKwargs.__init__rr_c4|jjdS)Nz.kwargsrrs rCr~zParamSpecKwargs.__repr__soo../w7 7r_c`t|tstS|j|jk(Sr>)r?r rrrs rCrzParamSpecKwargs.__eq__s'e_5%%??e&6&66 6r_Nrrr_rCr r s  % 8 7r_r rc2eZdZdZdZdddddfd ZxZS)rz!Parameter specification variable.rWNFrrqrsrct|||||tj|| tjdj j dd}|dk7r||_ yy#ttf$rd}Y!wxYwr rxrrrrrrrr3rrzrrrqrsrrr|s rCrzParamSpec.__init__s G T)+8  :  " "4 1 --*4488ZP--").#J/  s/A))A=<A=rrs@rCrrs/ *.%u! * *r_ceZdZdZej ZedZedZ dddddfd Z dZ d Z d Z d 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 rs rCrzParamSpec.args0s  & &r_ct|Sr>)r rs rCrzParamSpec.kwargs4s "4( (r_NFrct||g||_t||_t||_|rt j|d|_nd|_tj|| tjdjjdd}|dk7r||_yy#ttf$rd}Y!wxYw)NzBound must be a type.rrr@r)rxrrbool __covariant____contravariant__rWr __bound__rrrrrrr3rrs rCrzParamSpec.__init__8s G dV $ DM!%iD %)-%8D "!'!3!3E;R!S!%  " "4 1 --*4488ZP--").#J/  s5/B22CCc`|jrd}n|jrd}nd}||jzS)N+-~)rrr)rzprefixs rCr~zParamSpec.__repr__Ls2!!''DMM) )r_c,tj|Sr>r%rrs rCrzParamSpec.__hash__U??4( (r_c ||uSr>rrs rCrzParamSpec.__eq__X 5= r_c|jSr>rrs rCrzParamSpec.__reduce__[ == r_cyr>rrs rC__call__zParamSpec.__call___ r_)rrrrrWr r|propertyrrrr~rrrrrrs@rCrrsd, ^NN  '  '  )  )+/%u! *( * ) ! ! r_rc\eZdZejZdZfdZdZdZ dZ e dZ xZ S)_ConcatenateGenericAliasFc@t||||_||_yr>)rxrrr)rzrrr|s rCrz!_ConcatenateGenericAlias.__init__ns G T "$DO DMr_ctj|jddjfd|jDdS)Nrrc3.K|] }|ywr>r)rAargrs rCrDz4_ConcatenateGenericAlias.__repr__..vs!K]c*S/]sr)rWrrrr)rzrs @rCr~z!_ConcatenateGenericAlias.__repr__ssF**J!$//23 !KT]]!KKLAO Pr_cDt|j|jfSr>)rrrrs rCrz!_ConcatenateGenericAlias.__hash__xs$--89 9r_cyr>rrs rCrz!_ConcatenateGenericAlias.__call__|rr_c:td|jDS)Nc3bK|]'}t|tjtfs$|)ywr>)r?rWr r)rArYs rCrDz:_ConcatenateGenericAlias.__parameters__..s&*rjfnni=X.Y]s%//)rhrrs rCr<z'_ConcatenateGenericAlias.__parameters__s !]] r_)rrrrWrXr|rdrr~rrrr<rrs@rCrrfs@((  !  P  :     r_rc|dk(r tdt|ts|f}t|dts tddtfd|D}t ||S)Nrz&Cannot take a Concatenate of no types.rzAThe last parameter to Concatenate should be a ParamSpec variable.z/Concatenate[arg, ...]: each arg must be a type.c3JK|]}tj|ywr>r r s rCrDz'_concatenate_getitem..sF:av))!S1:r)rHr?rhrr)rzrOr s @rC_concatenate_getitemrsjR@AA j% ( ] jni 0./ / ;CF:FFJ #D* 55r_ct||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. rrs rCrrs$D*55r_ceZdZdZdZy)_ConcatenateFormc d|jzSrrrs rCr~z_ConcatenateForm.__repr__rr_ct||Sr>rrs rCrz_ConcatenateForm.__getitem__s'j9 9r_Nrrr_rCrrs  5 :r_rrr5ceZdZdZy)_TypeGuardFormc d|jzSrrrs rCr~z_TypeGuardForm.__repr__rr_Nrrr_rCrrrr_rcbtj||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)rWrrXrs rCr5r5s4X!!*6R.ST##D4'22r_ceZdZdZdZy)rc d|jzSrrrs rCr~z_TypeGuardForm.__repr__rr_cvtj||jd}tj||fS)Nz accepts only a single typerrs rCrz_TypeGuardForm.__getitem__s9%%j)- 4O&PRD''tg6 6r_Nrrr_rCrrrr_rcpeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ejd Zy ) _SpecialForm)rr_getitemcV||_|j|_|j|_yr>)r rrr)rzrs rCrz_SpecialForm.__init__3s! %%  r_c8|dvr |jSt|)N>rr)rr)rzrs rC __getattr__z_SpecialForm.__getattr__8s / /:: T""r_ctd|)Nrr)rzrLs rC__mro_entries__z_SpecialForm.__mro_entries__>s*4(344r_c d|jSrrrs rCr~z_SpecialForm.__repr__As#DJJ<00r_c|jSr>rrs rCrz_SpecialForm.__reduce__Ds zzr_ctd|)NzCannot instantiate rrzrrs rCrz_SpecialForm.__call__Gs-dX677r_c,tj||fSr>rWUnionrs rC__or__z_SpecialForm.__or__Js||D%K((r_c,tj||fSr>rrs rC__ror__z_SpecialForm.__ror__Ms||E4K((r_ct|d)Nz! cannot be used with isinstance()r)rzr{s rCryz_SpecialForm.__instancecheck__P4& ABCCr_ct|d)Nz! cannot be used with issubclass()r)rzrNs rCr`z_SpecialForm.__subclasscheck__Srr_c&|j||Sr>)r rs rCrz_SpecialForm.__getitem__Vs}}T:..r_N)rrrrrr rr~rrrrryr`rWr*rrr_rCr r 0sU0I' # 518))DD //r_r rct|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. rrrzrs rCrr^s"4& 5677r_r 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 rrrs rCr r us4& 5677r_r7ct|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 rrrs rCr7r7s04& 5677r_ceZdZdZy)_ExtensionsSpecialFormc d|jzSrrrs rCr~z_ExtensionsSpecialForm.__repr__rr_Nrrr_rCr#r#rr_r#cvtj||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 rCr9r9s7"!!* Array[Batch, Unpack[Shape]]: ... rrWrrr2rs rCrrs1!!* r?r2r{s rCrLrL#|,,r_c$eZdZejZyr1r3rr_rCr2r2r4r_ceZdZdZdZy) _UnpackFormc d|jzSrrrs rCr~z_UnpackForm.__repr__rr_cbtj||jd}t||fSrr7rs rCrz_UnpackForm.__getitem__!s3%%j)- 4P&QSDtg. .r_Nrrr_rCr>r>s  5 /r_r>r6c"t|tSr>r9r:s rCrLrL3r;r_rc(eZdZdZddfd ZxZS)rzType variable tuple.Nrct||tj|| tjdj j dd}|dk7r||_ yy#ttf$rd}Y!wxYwNrrr@rr)rzrrrr|s rCrzTypeVarTuple.__init__=sx G T "  " "4 1 --*4488ZP--").#J/  s/A%%A98A9rrs@rCrr:s",0 * *r_cXeZdZdZej ZdZdddZdZ dZ dZ d Z d Z y) 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|jywr>) __unpacked__rs rC__iter__zTypeVarTuple.__iter__ys## #sNrCc||_tj|| tjdj j dd}|dk7r||_ t||_ y#ttf$rd}Y.wxYwrE) rrrrrrrrr3rrrH)rzrrrs rCrzTypeVarTuple.__init__|sx DM  " "4 1 --*4488ZP--") &t D  #J/  s/A))A=<A=c|jSr>rrs rCr~zTypeVarTuple.__repr__rr_c,tj|Sr>rrs rCrzTypeVarTuple.__hash__rr_c ||uSr>rrs rCrzTypeVarTuple.__eq__rr_c|jSr>rrs rCrzTypeVarTuple.__reduce__rr_c"d|vr tdy)Nrz&Cannot subclass special typing classesrrs rCr)zTypeVarTuple.__init_subclass__sd" HII#r_)rrrrrWr r|rIrr~rrrr)rr_rCrrJs<) XNN  $-1 - ! ) ! ! Jr_r0__objr-chtdt|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)printrrrstderr)rPs rCr0r0s*  e!5!5 89 K r_r __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)AssertionErrorrUs rCr r s(>??r_r#r) eq_default order_defaultkw_only_defaultfield_specifiersrYrZr[r\.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. - ``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)rYrZr[r\r)__dataclass_transform__) cls_or_fnrYr\r[rrZs rC decoratorz&dataclass_transform..decorators$(!.#2$4 1I - r_r)rYrZr[r\rras````` rCr#r#sL  r_r._F)rc|S)aIndicate 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. See PEP 698 for details. rrXs rCr.r.&s , r_c tjdjjddS#tt f$rYywxYw)Nrrr@)rrrrrr3rr_rC_callerreQs@ ==#--11*jI I +  s.1AAc 6|Dcgc]\}}| }}}|Dcic] \}}|tj|d|d"}}}tj||||}|x|_|j _t jdkr||_|Scc}}wcc}}w)Nzfield z annotation must be a typedefaultsmoduler`) rWrr namedtuplerrr version_info _field_types) rririrhrXr]rGrnm_tpls rC _make_nmtuplernWs %&1!&#(*#(41a&,,Q&;U0VWW#( *''f19&JBMM!?   f $"-F  '*s B%B>rrrceZdZdZy)_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|vr4tjjj} t| | _ |D]@} | tvrt!d | z| t"vs"| | j$vs1t'| | || Btj|vr| j)| Scc}w)Nz3can only inherit from a NamedTuple type and Genericc3<K|]}|turtn|ywr>) _NamedTuplerhrOs rCrDz*_NamedTupleMeta.__new__..nsSUT4;#6%D@UrErzNon-default namedtuple field z cannot follow default fieldrs rrrgz&Cannot overwrite NamedTuple attribute )rsrWrrHrhrrfrKrrnrSr#rr classmethod_prohibited_namedtuple_fieldsr_special_namedtuple_fieldsr?setattrr)) rNrFrLrHrri default_names field_namerXrm class_getitemkeys rCrz_NamedTupleMeta.__new__hs%' ''{*t6>>/I#MOOSUSSEFF,b1EM# #!((4"#&CJ<PB.1-.@1.Ds"&MQ'+yy'?&@%BCC $#+%++-)67A"Q%7,'F %F ~~& & @ @ I I +6}+E(77()QTW)WXX ::s&..?XFCC1  ~~&((*M8s F N)rrrrrr_rCrprpgs" r_rpc n||j}n |r tdt||tS)NzIEither list of fields or keywords can be provided to NamedTuple, not both)ri)rSrHrnre) __typename__fieldsrs rCrrs<  ||~H GH HZ')DDr_r)rTz$(typename, fields=None, /, **kwargs)c$t|vsJtfSr>)rrs)rLs rC_namedtuple_mro_entriesrsU"""~r_r>)NNF)r)rrcollections.abcrrsrrirYrW__all__PEP_560r GenericMetar%rIrSrkr^rlr8r rmrnrorprrrrvrrJrr rr%r)r+rrr-r$r" defaultdictpartialr7rr rrrrrrrrr_aliasrrrr,r3r6r&rrrr/rABCMetarr2r1rrrEr*r4r9__text_signature__rIrrrrbr!r(rjrrprXr'r&r ImportErrorrZrr4rrr r rrrrr*rrrr5r_Finalrr r7r9r:r#r*rr.r2rLr>rr0r r#rrrrr.rbrrern _prohibitedrxrUryrprrsrrrr_rCrs    B J  (*1<*w  JF* ??FNN3V^^DV^^Dv~~f- 6>>*D 9w &4 & 9 9 ?? 67 0 0! 4 > LLE7V((7 w L MEw LLE @  69nnG:v**$:9 1 2G(( 6?#H((M,,O100 +1148&P 7# {{       $$ $$  &&00   6=!$$K &-- 7 7"bBK .. ??&& .. {{$$ = &X%&R 6:H@7 7$$]$F 6&'00   6?#((M 6:  I**N&&L % $RI $(*=X*HN%====~{TGR8I#I <v'("11>B*, 7 6=!$$K   6:**N0(>X 6;  I,,O%>&..d%>N88zBQ7"""JH1,4?00 6;  IbqV#5,,D5 8 85,,D5{ $) *I $ $ &fnnm4&. 6?#((M,,O7 7.7*70 6;*F$$m4*.bD-bLv}%4B 6 6 6=!$$K%>>bqV# 6 6:6..d:#   K 6;  IbqV#5,,D5,3,3^7,,D7) + I^(/6==(/V 6?#((M88& 66 ;;D88" 67 LLE884 6:H$$KbqV#5!4!4D533&33"7++47  H"    K  68 ]]FbqV#5V005#v++4# + +-#v++4#/f))/   F- 6>" *v**M * NJ}NJb 6=!$$K1( 6>"&&L@E@e@. 6() 44 # % OOO O !,, LLVZZ0&//#vzz/2RR S   O**O !a Od 6:H FOOCO$D EBr@v~& 2F*F w""J %+$6$6!!*+X!Y#$#JE **22J,, b"EK  6!(N %"9JE$ 1"001 4%334s$?ii(i%$i%(i=<i=