j7ibdZddlmZddlmZddlmZddlmZddlmZddlZddl Z ddl m Z dd l m Z dd l mZdd l mZdd l mZdd l mZddl mZddl mZddl mZddl mZddl mZddlZddlmZedZededefZee efZeZee edee efe!geee"effZ#edeeedeedfffZ$GddeZ%GddeZ&eGddZ'eGd d!Z(d.d"Z)e*e d#Z+d/d$Z,eGd%d&Z-e-Z.e"e/ee efeee gdffZ0Gd'd(Z1e1Z2Gd)d*e1Z3eGd+dZ4eGd,d-Z5y)0zA Internal hook annotation, representation and calling machinery. ) annotations) Generator)Mapping)Sequence)SetN) ModuleType)Any)Callable)Final)final)Optional)overload) TYPE_CHECKING) TypedDict)TypeVar)Union)Result_T_F.)boundHookImplc:eZdZUdZded<ded<ded<ded<y ) HookspecOptsz!Options for a hook specification.bool firstresulthistoricWarning | None warn_on_implMapping[str, Warning] | Nonewarn_on_impl_argsN__name__ __module__ __qualname____doc____annotations__V/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pluggy/_hooks.pyrr(s +N  43r)rcNeZdZUdZded<ded<ded<ded<ded<ded <y ) HookimplOptsz"Options for a hook implementation.rwrapper hookwrapper optionalhooktryfirsttrylast str | NonespecnameNr"r(r)r*r,r,8s0,MNMr)r,ceZdZdZdZddZe d d dZe d d dZ d ddZy)HookspecMarkeraDecorator for marking functions as hook specifications. Instantiate it with a project_name to get a decorator. Calling :meth:`PluginManager.add_hookspecs` later will discover all marked functions if the :class:`PluginManager` uses the same project name.  project_namec||_yNr6selfr7s r*__init__zHookspecMarker.__init__X #/r)Ncyr9r(r;functionrrrr!s r*__call__zHookspecMarker.__call__[sr)cyr9r(r?s r*rAzHookspecMarker.__call__es!r)c8dfd }|||S|S)awIf passed a function, directly sets attributes on the function which will make it discoverable to :meth:`PluginManager.add_hookspecs`. If passed no function, returns a decorator which can be applied to a function later using the attributes supplied. :param firstresult: If ``True``, the 1:N hook call (N being the number of registered hook implementation functions) will stop at I<=N when the I'th function returns a non-``None`` result. See :ref:`firstresult`. :param historic: If ``True``, every call to the hook will be memorized and replayed on plugins registered after the call was made. See :ref:`historic`. :param warn_on_impl: If given, every implementation of this hook will trigger the given warning. See :ref:`warn_on_impl`. :param warn_on_impl_args: If given, every implementation of this hook which requests one of the arguments in the dict will trigger the corresponding warning. See :ref:`warn_on_impl`. .. versionadded:: 1.5 chr r tdd}t|jdz||S)Nz'cannot have a historic firstresult hook)rrrr!_spec) ValueErrorsetattrr7)funcoptsrrr;rr!s r*setattr_hookspec_optsz6HookspecMarker.__call__..setattr_hookspec_optssEK !JKK*$ ,%6 "D D$++g5t <Kr)rHrreturnrr()r;r@rrrr!rJs` ```` r*rAzHookspecMarker.__call__os'F    (2 2( (r)r7strrLNone)FFNN) r@rrrrrrrr!r rLr).....) r@rOrrrrrrr!r rLCallable[[_F], _F])NFFNN) r@ _F | Nonerrrrrrr!r rL_F | Callable[[_F], _F]r#r$r%r& __slots__r<rrAr(r)r*r5r5Ms"I0"'+:>   %  8  '*:= !!! ! % ! 8 ! !!#!'+:> 2)2)2) 2) % 2) 8 2) !2)r)r5ceZdZdZdZddZe d d dZe d d dZ d ddZy)HookimplMarkeraDecorator for marking functions as hook implementations. Instantiate it with a ``project_name`` to get a decorator. Calling :meth:`PluginManager.register` later will discover all marked functions if the :class:`PluginManager` uses the same project name. r6c||_yr9r6r:s r*r<zHookimplMarker.__init__r=r)cyr9r(r;r@r.r/r0r1r3r-s r*rAzHookimplMarker.__call__sr)cyr9r(rYs r*rAzHookimplMarker.__call__s!r)Nc@dfd }||S||S)a If passed a function, directly sets attributes on the function which will make it discoverable to :meth:`PluginManager.register`. If passed no function, returns a decorator which can be applied to a function later using the attributes supplied. :param optionalhook: If ``True``, a missing matching hook specification will not result in an error (by default it is an error if no matching spec is found). See :ref:`optionalhook`. :param tryfirst: If ``True``, this hook implementation will run as early as possible in the chain of N hook implementations for a specification. See :ref:`callorder`. :param trylast: If ``True``, this hook implementation will run as late as possible in the chain of N hook implementations for a specification. See :ref:`callorder`. :param wrapper: If ``True`` ("new-style hook wrapper"), the hook implementation needs to execute exactly one ``yield``. The code before the ``yield`` is run early before any non-hook-wrapper function is run. The code after the ``yield`` is run after all non-hook-wrapper functions have run. The ``yield`` receives the result value of the inner calls, or raises the exception of inner calls (including earlier hook wrapper calls). The return value of the function becomes the return value of the hook, and a raised exception becomes the exception of the hook. See :ref:`hookwrapper`. :param hookwrapper: If ``True`` ("old-style hook wrapper"), the hook implementation needs to execute exactly one ``yield``. The code before the ``yield`` is run early before any non-hook-wrapper function is run. The code after the ``yield`` is run after all non-hook-wrapper function have run The ``yield`` receives a :class:`Result` object representing the exception or result outcome of the inner calls (including earlier hook wrapper calls). This option is mutually exclusive with ``wrapper``. See :ref:`old_style_hookwrapper`. :param specname: If provided, the given name will be used instead of the function name when matching this hook implementation to a hook specification during registration. See :ref:`specname`. .. versionadded:: 1.2.0 The ``wrapper`` parameter. cNd}t|jdz||S)N)r-r.r/r0r1r3_impl)rGr7) rHrIr.r/r;r3r0r1r-s r*setattr_hookimpl_optsz6HookimplMarker.__call__..setattr_hookimpl_optss:"* ,$"$ "D D$++g5t <Kr)rKr() r;r@r.r/r0r1r3r-r^s ` `````` r*rAzHookimplMarker.__call__s'z    ( ((2 2r)rM)......)r@rr.rr/rr0rr1rr3r2r-rrLr).......)r@rOr.rr/rr0rr1rr3r2r-rrLrP)NFFFFNF)r@rQr.rr/rr0rr1rr3r2r-rrLrRrSr(r)r*rVrVsu"I0  "              " ! ! ! !  !  ! ! !  ! !#!"#L3L3L3 L3  L3  L3L3L3 !L3r)rVc|jdd|jdd|jdd|jdd|jdd|jddy)Nr0Fr1r-r.r/r3) setdefault)rIs r*normalize_hookimpl_optsrasVOOJ&OOIu%OOIu%OOM5)OONE*OOJ%r)pypy_version_infocltj|r |j}n#tj|s t |d|} tjtj|r |jn|}tjjtjjf}|jjDcic]\}}|j |vr||}}}t#|}t#d|j%Dxsd}|r t'| }|d|t#||d} }nd} t(sd} nd} |r2t |dd } tj|s d | vr |d | vr|d d}|| fS#t$rYywxYw#t $rYywxYw#t$rYywxYwcc}}w) zReturn tuple of positional and keywrord argument names for a function, method, class or callable. In case of a class, its ``__init__`` method is considered. For methods the ``self`` parameter is not included. )r(r(rAc3dK|](}|j|jur|j*ywr9)defaultempty).0params r* zvarnames..Js, }}EKK/ MM s.0Nr(r;)r;objr%.rr)inspectisclassr<AttributeError isroutinegetattr Exception signatureismethod__func__ TypeError ParameterPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORD parametersitemskindtuplevalueslen_PYPY) rHsig_valid_param_kindsnamerh _valid_paramsargsdefaultsindexkwargsimplicit_namesqualnames r*varnamesr%st ==D  t $ 4T2D$--d3DMM  ))// >>//1 D% ::+ + e M  D  &--/      XFU|U4<%8f *3( nb9   D !cXo$q'^:S8D <i      s: F F6F!F0 FF FF! F-,F-c*eZdZdZdZddZerddZyy) HookRelayzaHook holder object for performing 1:N hook calls where N is the number of registered plugins.)__dict__cy:meta private:Nr(rjs r*r<zHookRelay.__init__mr)cyr9r()r;rs r* __getattr__zHookRelay.__getattr__rrr)N)rLrO)rrNrL HookCaller)r#r$r%r&rTr<rrr(r)r*rrfs I;r)rceZdZdZdZ d ddZddZ ddZddZddZ dd Z dd Z dd Z dd Z dd Z d ddZ ddZddZy)rzCA caller of all registered implementations of a hook specification.)rspec _hookexec _hookimpls _call_historyNc|||_||_g|_d|_d|_||J|j ||yyr)rrrrrset_specification)r;r hook_executespecmodule_or_class spec_optss r*r<zHookCaller.__init__sR  ,2426%)  *( ((  " "#6 B +r)c|jduSr9)rrjs r*has_speczHookCaller.has_specsyy$$r)c|j9td|jjd|jjt ||j||_|j drg|_yy)NzHook z( is already registered within namespace r)rrFr namespaceHookSpecgetr)r;rrs r*rzHookCaller.set_specificationsu 99  )*$$(II$7$7#8: 0$))YG == $!#D  %r)c|jduS)z2Whether this caller is :ref:`historic `.N)rrjs r* is_historiczHookCaller.is_historics!!--r)ct|jD]#\}}|j|k(s|j|=ytd|d)Nzplugin z not found) enumeraterpluginrF)r;rimethods r*_remove_pluginzHookCaller._remove_pluginsO"4??3 IAv}}&OOA& 76*J788r)c6|jjS)z6Get all registered hook implementations for this hook.)rcopyrjs r* get_hookimplszHookCaller.get_hookimplss##%%r)cxt|jD]!\}}|js |js|}nt |j}|js |jr|t |j}}nd|}}|j r|jj ||y|jr|jj ||y|dz }||k\r=|j|jr$|dz}||k\r|j|jr$|jj |dz|y)z,Add an implementation to the callback chain.rrN)rrr.r-rr1insertr0)r;hookimplrr splitpointstartends r* _add_hookimplzHookCaller._add_hookimpls "4??3 .IAv!!V^^  . T__-J   8#3#3#S%93EJ3E    OO " "5( 3    OO " "3 1aAu*!3!rrjs r*__repr__zHookCaller.__repr__sdii]!,,r)c|jrk|jjD]Q}|vsdjfd|jjD}tjd|ddyyy)Nz, c3XK|]!}|jvr t|#ywr9)keysrepr)rgargnamers r*riz;HookCaller._verify_all_args_are_provided..s-*##&++-7 W *s'*z Argument(s) zE which are declared in the hookspec cannot be found in this hook call) stacklevel)rargnamesjoinwarningswarn)r;rr notincalls ` r*_verify_all_args_are_providedz(HookCaller._verify_all_args_are_provideds| 9999-- &( $ *'+yy'9'9*!IMM&yk2<<#$   r)c &|jrJd|j||jr&|jjj ddnd}|j |j |jj||S)zCall the hook. Only accepts keyword arguments, which should match the hook specification. Returns the result(s) of calling all registered plugins, see :ref:`calling`. ACannot directly call a historic hook - use call_historic instead.rF) rrrrIrrrrr)r;rrs r*rAzHookCaller.__call__sy##% O % **62BF))diinn((>QV ~~dii)=)=)?UUr)c:|jJ|xsi}|j||jj||f|j|j|j j |d}|yt|tr|D] }|| yy)a<Call the hook with given ``kwargs`` for all registered plugins and for all plugins which will be registered afterwards, see :ref:`historic`. :param result_callback: If provided, will be called for each non-``None`` result obtained from a hook implementation. NF) rrappendrrrr isinstancelist)r;result_callbackrresxs r* call_historiczHookCaller.call_historics!!---2 **62 !!6?";<nnTYY(<(<(>N  "  c4  #" # !r)c|jrJd|j|ddddddd}|jj}|D]}t dd||}t |dz }|dk\rg||j s||js||jr:|dz}|dk\r0||j r||jr*||jr:|j|dz||jr&|jjjddnd}|j|j|||S) zCall the hook with some additional temporarily participating methods using the specified ``kwargs`` as call parameters, see :ref:`call_extra`.rFN)r-r.r/r1r0r3zrrr)rrrrrrr.r-r0rrrIrrr) r;methodsrrI hookimplsrrrrs r* call_extrazHookCaller.call_extrasE ##% O % **62 !  OO((*  .Fh=HI"Aq&1))Yq\-A-AQ<((Q q&1))Yq\-A-AQ<((   QUH - .CG))diinn((>QV ~~diiFKHHr)c|jre|jJ|jD]G\}}|j|j|g|d}|s(|+t |t sJ||dIyy)zAApply call history to a new hookimpl if it is marked as historic.NFr)rrrrrr)r;rrrrs r*_maybe_apply_historyzHookCaller._maybe_apply_history?s}    %%1 11+/+=+= ,'nnTYY&%H?6%c4000#CF+  , r))NN) rrNr _HookExecrz_Namespace | NonerzHookspecOpts | NonerLrO)rLr)r _NamespacerrrLrO)r_PluginrLrOrLzlist[HookImpl])rrrLrOrLrN)rMapping[str, object]rLrO)robjectrLr )rzCallable[[Any], None] | NonerzMapping[str, object] | NonerLrO)rzSequence[Callable[..., object]]rrrLr )rrrLrO)r#r$r%r&rTr<rrrrrrrrrArrrr(r)r*rr|sMI26)- CC C/ C ' C  C6% $' $  $  $.9&40-&V&9=.2#5#,#  #6 I6 I@T I  ID ,r)rcZeZdZdZdZd dZed dZed dZed dZ d dZ y)_SubsetHookCallerztA proxy to another HookCaller which manages calls to all registered plugins except the ones from remove_plugins.)_orig_remove_pluginscd||_||_|j|_|j|_yr9)rrrr)r;origremove_pluginss r*r<z_SubsetHookCaller.__init__bs' -II r)c|jjDcgc]}|j|jvr|c}Scc}wr9)rrrr)r;impls r*rz_SubsetHookCaller._hookimplshs@ -- {{$"6"66    s!=c.|jjSr9)rrrjs r*rz_SubsetHookCaller.specpszzr)c.|jjSr9)rrrjs r*rz_SubsetHookCaller._call_historytszz'''r)c"d|jdS)Nz<_SubsetHookCaller rrrjs r*rz_SubsetHookCaller.__repr__xs$TYYM33r)N)rrrz Set[_Plugin]rLrOr)rLzHookSpec | None)rLz_CallHistory | Noner) r#r$r%r&rTr<propertyrrrrr(r)r*rrOsT4I (   ((4r)rc8eZdZdZdZ ddZddZy)rz/A hook implementation in a :class:`HookCaller`.) r@r kwargnamesrrI plugin_namer-r.r/r0r1c||_t|j\}}||_||_||_||_||_|d|_|d|_|d|_ |d|_ |d|_ y)rr-r.r/r0r1N) r@rrrrrIrr-r.r/r0r1)r;rrr@hook_impl_optsrrs r*r<zHookImpl.__init__s ( ' 6*' !+# ) "-,Y7 #1"?$2.#A .j9 -Y7 r)c<d|jd|jdS)Nzr)N)rrrrNrIrrLrO)r#r$r%rTr<r(r)r*rrs I?r)r)rIr,rLrO)rHrrLz'tuple[tuple[str, ...], tuple[str, ...]])6r& __future__rcollections.abcrrrrrnsystypesrtypingr r r r r rrrrrr_resultrrrrtyperrrNrrr_HookImplFunctionrr,r5rVrahasattrrrr _HookRelayr~ _CallHistoryr _HookCallerrrrr(r)r*rs#%#$   T] T#v+./ :t# $  (: V 4d; &$v, !  S%IdF2J6L,M(M"NNO 49 4 9*S)S)S)lq3q3q3h& ()>B < < < E'#v+.3%+9N0OOPQ L,L,` *4 *4Z6V6V6Vr???r)