bgj'dZddlmZddlZddlZddlZddlZddlmZm Z ddl m Z ddl Z ddl mZmZddlmZddlmZejd krdd l mZndd lmZe d Zed Ze jd ZGddZdZe jdZe jdZejr dddZ dddZ!dS dddZ dddZ!dS)z(A few useful function/method decorators.) annotationsN)Callable Generator)TypeVar)_cacheutil)InferenceContext)InferenceError) ) ParamSpec_R_Pct|dd}|(ix|_}tj| ||S#t $r||i|x||<}|cYSwxYw)z>Simple decorator to cache result of method calls without args.__cacheN)getattrrr CACHE_MANAGERadd_dict_cacheKeyError)funcinstanceargskwargscacheresults c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/decorators.pycachedrs Hi . .E }#%%5++E222T{ #tT4V444d f sAA! A!c:eZdZdZdZdZedZddZdS)cachedpropertyaProvides a cached property equivalent to the stacking of @cached and @property, but more efficient. After first usage, the becomes part of the object's __dict__. Doing: del obj. empties the cache. Idea taken from the pyramid_ framework and the mercurial_ project. .. _pyramid: http://pypi.python.org/pypi/pyramid .. _mercurial: http://pypi.python.org/pypi/Mercurial )wrappedctjdkrtjdtd |jn%#t $r}t|d|d}~wwxYw||_dS)N)r z}cachedproperty has been deprecated and will be removed in astroid 3.0 for Python 3.8+. Use functools.cached_property instead. stacklevelz must have a __name__ attribute) sys version_infowarningswarnDeprecationWarning__name__AttributeError TypeErrorr )selfr excs r__init__zcachedproperty.__init__@s  v % % M9"       R     R R RwGGGHHc Q R s6 AAAcFt|jdd}d|rd|zndzS)N__doc__z+%sz %s)rr )r.docs rr2zcachedproperty.__doc__Ns2dlIt44< 'FSLLR  Ncn||S||}t||jj||SN)r setattrr+)r.instobjtypevals r__get__zcachedproperty.__get__Us9 <Kll4  dl+S111 r5r7)r+ __module__ __qualname__r2 __slots__r0propertyr<r5rrr/sc  I     X r5rcHtj|d|fdd}|S)zReturn the given infer function wrapped to handle the path. Used to stop inference if the node has already been looked at for a given `InferenceContext` to prevent infinite recursion NcontextInferenceContext | Nonereturnrc;K|t}||rdSt}|||fi|D]9}|jjdkr|j}n|}||vr|V||:dS)z"Wrapper function handling context.NInstance)r pushset __class__r+_proxiedadd)noderC_funcryieldedresaress rr zpath_wrapper..wrappedds ?&((G <<    F%%5w11&11 " "C}%33|7""  D!!! " "r5)rCrDrEr functoolswraps)rr s r path_wrapperrU]s>_T15T"""""* Nr5c#K||i|} t|Vn#t$rtjVYdSwxYw|Ed{VdSr7)next StopIterationr Uninferable)rrrr generators ryes_if_nothing_inferredr[}sd%f%%I9oo  s ::c#6K||i|} t|Vns#t$r4}|jrtdi|jd|td|d}~wt$r*}tdt jd|d}~wwxYw|Ed{VdS)Nrz3StopIteration raised without any error information.z!RecursionError raised with limit .rA)rWrXrr RecursionErrorr&getrecursionlimit)rrrrrZerrors rraise_if_nothing_inferredrasd%f%%I 9oo  : = 115:a=11u < A     J0E0G0G J J J    s  B/A B$%B  B3.0astroid_versionstr argumentsrE.Callable[[Callable[_P, _R]], Callable[_P, _R]]c dfd }|S)aDecorator which emits a DeprecationWarning if any arguments specified are None or not passed at all. Arguments should be a key-value mapping, with the key being the argument to check and the value being a type annotation as string for the value of the argument. To improve performance, only used when DeprecationWarnings other than the default one are enabled. rCallable[_P, _R]rEcNtjdfd }|S) Decorator function.r_P.argsr _P.kwargsrErc`ttjj}D]\}} ||}n5#t$r(td|d|djj ddwxYw||vr||8||vrx|dks.t||kst||krL||Dtj d|d|djj dj d d |d |d td |i|S)z/Emit DeprecationWarnings if conditions are met.Can't find argument '' for 'r'Nz#' will be a required argument for 'r]z ' in astroid z ('z' should be of type: 'z')r#r$listinspect signature parameterskeysitemsindex ValueErrorrJr>lenr(r)r+r*) rrrwargtype_annotationryrercrs rwrapperz@deprecate_default_argument_values..deco..wrappersG-d33>CCEEFF,5OO,=,=(C$ $ 3%$$$(aCaaQ@Q@^aaa#$$6#;+> f,,!RKK"4yyE11 #D E 1 1d5k6I! PPP $Q 1 >PPAEPP+:PP"%PP=LPPP/'( tT,V,,, A**2BrrkrrlrErrRrr~rercs` rdecoz/deprecate_default_argument_values..decosK_T " "# -# -# -# -# -# -# -# "# -JNr5rrhrErhrArcrers`` r!deprecate_default_argument_valuesrs/ ) ) ) ) ) ) ) V r5c dfd }|S)aDecorator which emits a DeprecationWarning if any arguments specified are passed. Arguments should be a key-value mapping, with the key being the argument to check and the value being a string that explains what to do instead of passing the argument. To improve performance, only used when DeprecationWarnings other than the default one are enabled. rrhrEcNtjdfd }|S) NrrkrrlrErcttjj}D]\}} ||}n5#t$r(td|d|djj ddwxYw||vst||krAtj d|d|djj dj dd|d td |i|S) NrnrorrpzThe argument 'r]z/' is deprecated and will be removed in astroid z ()r#r$rr) rrrwr|noteryrercrs rr~z2deprecate_arguments..deco..wrapperscG-d33>CCEEFF!*!2!2IC$ $ 3%$$$(aCaaQ@Q@^aaa#$$f}}D E(9(9 YSYY $Q 1 >YYAEYY>MYYQUYYY/'( tT,V,,,rrrRrs` rrz!deprecate_arguments..decosH _T " " - - - - - - -# " -&Nr5rrArs`` rdeprecate_argumentsrs.       . r5c dd}|S)bPassthrough decorator to improve performance if DeprecationWarnings are disabled. rrhrEc|SrjrArs rrz/deprecate_default_argument_values..decoKr5rrArs rrr      r5c dd}|S)rrrhrEc|SrrArs rrz!deprecate_arguments..decorr5rrArs rrrrr5)rb)rcrdrerdrErf)"r2 __future__rrSrtr&r(collections.abcrrtypingrwraptastroidrrastroid.contextr astroid.exceptionsr r'r typing_extensionsrr decoratorrrrUr[racheck_warnings_filterrrrAr5rrs8 /."""""" //////// ,,,,,,------w       ++++++ WT]]Yt__   ++++++++\@   .4 %;;;;;| %$$$$$$$R %      %       r5