Ë ‡e¶VãóΗddlmZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z d d lmZd d lmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZe rddlZ ee!e ee e!efgdfZ"eeee!e ee e!efgdfZ#d!d„Z$Gd„de%«Z&Gd„d«Z'Gd„d«Z(d"d „Z)y)#é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚFinal)ÚIterable)ÚMapping)ÚSequence)Ú TYPE_CHECKINGé)Ú_tracing)Ú _multicall)Ú_HookImplFunction)Ú _Namespace)Ú_Plugin)Ú_SubsetHookCaller)Ú HookCaller)ÚHookImpl)Ú HookimplOpts)Ú HookRelay)Ú HookspecOpts)Únormalize_hookimpl_opts)ÚResultcóÌ—ttj|«}tj|t |«|j j|j j¬«y)N)ÚlinenoÚfilename) rÚtypesÚ FunctionTypeÚwarningsÚ warn_explicitÚtypeÚ__code__Úco_firstlinenoÚ co_filename)ÚwarningÚfunctionÚfuncs ú4/usr/lib/python3.12/site-packages/pluggy/_manager.pyÚ_warn_for_functionr)&sF€Ü ”×"Ñ" HÓ -€DÜ ×ÑØÜ ˆW‹ Ø�}‰}×+Ñ+Ø—‘×*Ñ*ö ócó$‡—eZdZdZdˆfd„ ZˆxZS)ÚPluginValidationErrorzyPlugin failed validation. :param plugin: The plugin which failed validation. :param message: Error message. có2•—t‰|�|«||_y©N)ÚsuperÚ__init__Úplugin)Úselfr1ÚmessageÚ __class__s €r(r0zPluginValidationError.__init__7sø€Ü ‰Ñ˜Ô!àˆ� r*)r1rr3ÚstrÚreturnÚNone)Ú__name__Ú __module__Ú __qualname__Ú__doc__r0Ú __classcell__)r4s@r(r,r,0sø„ñ÷ ñr*r,có<—eZdZdZdd„Zedd„«Zd d d„Zd d„Zy) Ú DistFacadez$Emulate a pkg_resources Distributioncó—||_yr.)Ú_dist)r2Údists r(r0zDistFacade.__init__@s €Øˆ� r*có$—|jd}|S)NÚname)Úmetadata©r2rCs r(Ú project_namezDistFacade.project_nameCs€à—M‘M &Ñ)ˆØˆ r*Ncó0—t|j||«Sr.)Úgetattrr@)r2ÚattrÚdefaults r(Ú __getattr__zDistFacade.__getattr__Hs€Ü�t—z‘z 4¨Ó1Ð1r*cóH—tt|j«ddgz«S)Nr@rF)ÚsortedÚdirr@©r2s r(Ú__dir__zDistFacade.__dir__Ks€Ü”c˜$Ÿ*™*“o¨°.Ð(AÑAÓBÐBr*)rAzimportlib.metadata.Distributionr6r7)r6r5r.)rIr5)r6z list[str]) r8r9r:r;r0ÚpropertyrFrKrP©r*r(r>r>=s)„Ù.óðòóðô2ôCr*r>có"—eZdZdZdd„Z dd„Zddd„Zd d„Z d! d"d„Zd#d„Z d$d „Z d$d „Z d%d „Z d&d „Z d'd „Zd(d„Zd)d„Zd*d„Zd$d„Zd+d„Zd,d„Zd-d„Zdd.d„Zd/d„Zd0d„Zd1d„Z d2d„Zd3d„Z d4d„Zy)5Ú PluginManageraQCore class which manages registration of plugin objects and 1:N hook calling. You can register new hooks by calling :meth:`add_hookspecs(module_or_class) `. You can register plugin objects (which contain hook implementations) by calling :meth:`register(plugin) `. For debugging purposes you can call :meth:`PluginManager.enable_tracing` which will subsequently send debug information to the trace helper. :param project_name: The short project name. Prefer snake case. Make sure it's unique! có²—||_i|_g|_t«|_t j «jd«|_t|_ y)NÚ pluginmanage) rFÚ _name2pluginÚ_plugin_distinforÚhookr Ú TagTracerÚgetÚtracerÚ_inner_hookexec)r2rFs r(r0zPluginManager.__init__`sM€à#/ˆÔØ79ˆÔØIKˆÔô%›;ˆŒ ä3;×3EÑ3EÓ3G×3KÑ3KØ ó4 ˆŒ ô *ˆÕr*có*—|j||||«Sr.©r])r2Ú hook_nameÚmethodsÚkwargsÚ firstresults r(Ú _hookexeczPluginManager._hookexecns€ð×#Ñ# I¨w¸À ÓLÐLr*Ncó(—|xs|j|«}||jvr;|jj|d«€ytd|›d|›d|j›�«‚||jj «vrtd|›d|›d|j›�«‚||j|<t |«D]Ü}|j ||«}|€Œt|«t||«}t||||«}|jd«xs|}t|j|d«}|€.t||j«}t|j||«n3|j«r#|j||«|j!|«|j#|«ŒÞ|S)a“Register a plugin and return its name. :param name: The name under which to register the plugin. If not specified, a name is generated using :func:`get_canonical_name`. :returns: The plugin name. If the name is blocked from registering, returns ``None``. If the plugin is already registered, raises a :exc:`ValueError`. éÿÿÿÿNz Plugin name already registered: Ú=Ú z2Plugin already registered under a different name: Úspecname)Úget_canonical_namerWr[Ú ValueErrorÚvaluesrNÚparse_hookimpl_optsrrHrrYrrdÚsetattrÚhas_specÚ _verify_hookÚ_maybe_apply_historyÚ _add_hookimpl)r2r1rCÚ plugin_nameÚ hookimpl_optsÚmethodÚhookimplrYs r(ÚregisterzPluginManager.registerys�€ðÒ=˜d×5Ñ5°fÓ=ˆ à ˜$×+Ñ+Ñ +Ø× Ñ ×$Ñ$ [°"Ó5Ð=ØÝ⢨×(9Ò(9ð;óð ð �T×&Ñ&×-Ñ-Ó/Ñ /Ý⢨×(9Ò(9ð;óð ð*0ˆ×ј+Ñ&ô˜–KˆDØ ×4Ñ4°V¸TÓBˆMØÑ(Ü'¨ Ô6Ü4;¸FÀDÓ4I�Ü# F¨K¸ÀÓO�Ø$×(Ñ(¨Ó4Ò<¸�Ü*1°$·)±)¸TÀ4Ó*H�Ø�<Ü% d¨D¯N©NÓ;�DܘDŸI™I t¨TÕ2Ø—]‘]”_Ø×%Ñ% d¨HÔ5Ø×-Ñ-¨hÔ7Ø×"Ñ" 8Õ,ð ðÐr*cóÊ—t||«}tj|«sy t||jdzd«}|�t |t «sd}|S#t$ri}YŒ#wxYw)aÊTry to obtain a hook implementation from an item with the given name in the given plugin which is being searched for hook impls. :returns: The parsed hookimpl options, or None to skip the given item. This method can be overridden by ``PluginManager`` subclasses to customize how hook implementation are picked up. By default, returns the options for items decorated with :class:`HookimplMarker`. NÚ_impl)rHÚinspectÚ isroutinerFÚ ExceptionÚ isinstanceÚdict)r2r1rCruÚress r(rmz!PluginManager.parse_hookimpl_opts¬sr€ô! ¨Ó.ˆÜ× Ñ  Ô(Øð Ü'.ؘ×)Ñ)¨GÑ3°Tó(ˆCð ˆ?¤:¨c´4Ô#8àˆC؈ øô ò ØŠCð ús¤AÁ A"Á!A"có*—|€#|€Jd«‚|j|«}|€Jd«‚|€|j|«}|€y|j|«}|r|D]}|j|«Œ|jj |«r|€J‚|j|=|S)a Unregister a plugin and all of its hook implementations. The plugin can be specified either by the plugin object or the plugin name. If both are specified, they must agree. Returns the unregistered plugin, or ``None`` if not found. Nz+one of name or plugin needs to be specifiedzplugin is not registered)Úget_nameÚ get_pluginÚget_hookcallersÚ_remove_pluginrWr[)r2r1rCÚ hookcallersÚ hookcallers r(Ú unregisterzPluginManager.unregisterÅs¶€ð ˆ<ØÐ%Ð TÐ'TÓ TÐ%Ø—=‘= Ó(ˆDØÐ#Ð ?Ð%?Ó ?Ð#à ˆ>Ø—_‘_ TÓ*ˆF؈~Øà×*Ñ*¨6Ó2ˆ Ù Û)� Ø×)Ñ)¨&Õ1ð*ð × Ñ × Ñ  Ô &ØÐ#Ð #Ð#Ø×!Ñ! $Ð'àˆ r*cóF—|j|¬«d|j|<y)zHBlock registrations of the given name, unregister if already registered.©rCN)r‡rWrEs r(Ú set_blockedzPluginManager.set_blockedås €à �‰˜TˆÔ"Ø"&ˆ×ј$Òr*cóD—||jvxr|j|duS)z0Return whether the given plugin name is blocked.N)rWrEs r(Ú is_blockedzPluginManager.is_blockedês(€à�t×(Ñ(Ð(ÒL¨T×->Ñ->¸tÑ-DÈÐ-LÐLr*cóX—|jj|d«€|j|=yy)zQUnblocks a name. Returns whether the name was actually blocked. rfTF©rWr[rEs r(ÚunblockzPluginManager.unblockîs1€ð × Ñ × Ñ   rÓ *Ð 2Ø×!Ñ! $Ð'ØØr*có²—g}t|«D]ª}|j||«}|€Œt|j|d«}|€0t ||j ||«}t |j||«n9|j||«|j«D]}|j||«Œ|j|«Œ¬|std|j›d|›�«‚y)zÔAdd new hook specifications defined in the given ``module_or_class``. Functions are recognized as hook specifications if they have been decorated with a matching :class:`HookspecMarker`. Nzdid not find any z hooks in ) rNÚparse_hookspec_optsrHrYrrdrnÚset_specificationÚ get_hookimplsrpÚappendrkrF)r2Úmodule_or_classÚnamesrCÚ spec_optsÚhcÚ hookfunctions r(Ú add_hookspecszPluginManager.add_hookspecsøsÛ€ð ˆÜ˜Ö(ˆDØ×0Ñ0°À$ÓGˆIØÑ$Ü(/°· ± ¸4ÀÓ(F�Ø�:Ü# D¨$¯.©.¸/È9ÓU�BܘDŸI™I t¨RÕ0ð×(Ñ(¨¸)ÔDØ(*×(8Ñ(8Ö(:˜ Ø×)Ñ)¨"¨lÕ;ð);à— ‘ ˜TÕ"ð)ñÜØ# D×$5Ñ$5Ð#8¸ À?ÐBUÐVóð ðr*cóR—t||«}t||jdzd«}|S)aòTry to obtain a hook specification from an item with the given name in the given module or class which is being searched for hook specs. :returns: The parsed hookspec options for defining a hook, or None to skip the given item. This method can be overridden by ``PluginManager`` subclasses to customize how hook specifications are picked up. By default, returns the options for items decorated with :class:`HookspecMarker`. Ú_specN)rHrF)r2r•rCruÚoptss r(r‘z!PluginManager.parse_hookspec_optss/€ô˜¨$Ó/ˆÜ$+¨F°D×4EÑ4EÈÑ4OÐQUÓ$VˆØˆ r*cóH—t|jj««S)z.Return a set of all registered plugin objects.)ÚsetrWrlrOs r(Ú get_pluginszPluginManager.get_plugins$s€ä�4×$Ñ$×+Ñ+Ó-Ó.Ð.r*có\‡—tˆfd„|jj«D««S)z0Return whether the plugin is already registered.c3ó(•K—|] }‰|k(–—Œ y­wr.rR)Ú.0Úvalr1s €r(Ú z.PluginManager.is_registered..*søèø€ÐGÑ,F S�6˜S•=Ñ,Fùsƒ)ÚanyrWrl)r2r1s `r(Ú is_registeredzPluginManager.is_registered(s#ø€äÓG¨D×,=Ñ,=×,DÑ,DÔ,FÓGÓGÐGr*cóL—t|dd«}|xstt|««S)a3Return a canonical name for a plugin object. Note that a plugin may be registered under a different name specified by the caller of :meth:`register(plugin, name) `. To obtain the name of a registered plugin use :meth:`get_name(plugin) ` instead. r8N)rHr5Úid)r2r1rCs r(rjz PluginManager.get_canonical_name,s%€ô# 6¨:°tÓ<ˆØÒ&”sœ2˜f›:“Ð&r*có8—|jj|«S)z:Return the plugin registered under the given name, if any.rŽrEs r(r‚zPluginManager.get_plugin7s€à× Ñ ×$Ñ$ TÓ*Ð*r*có(—|j|«duS)z:Return whether a plugin with the given name is registered.N)r‚rEs r(Ú has_pluginzPluginManager.has_plugin;s€à�‰˜tÓ$¨DÐ0Ð0r*cóZ—|jj«D]\}}||k(sŒ |cSy)zPReturn the name the plugin is registered under, or ``None`` if is isn't.N)rWÚitems)r2r1rCr¤s r(r�zPluginManager.get_name?s2€ð×*Ñ*×0Ñ0Ö2‰IˆD�#ؘ‹}Ø’ ð3ðr*c ó—|j«rI|js |jr1t|jd|j ›d|j ›d�«‚|j€J‚|jjr*t|jj|j«t|j«t|jj«z }|rJt|jd|j ›d|j ›dt|j«›d|›d� «‚|js |jrftj|j«sGt|jd|j ›d|j ›dt|j«›d�«‚|jrT|jrGt|jd|j ›d|j ›dt|j«›d �«‚yy) NzPlugin z hook z5 historic incompatible with yield/wrapper/hookwrapperz for hook z hookimpl definition: z Argument(s) zB are declared in the hookimpl but can not be found in the hookspeczV Declared as wrapper=True or hookwrapper=True but function is not a generator functionzE The wrapper=True and hookwrapper=True options are mutually exclusive)Ú is_historicÚ hookwrapperÚwrapperr,r1rsrCÚspecÚ warn_on_implr)r&rŸÚargnamesÚ _formatdefrzÚisgeneratorfunction)r2rYrvÚ notinspecs r(rpzPluginManager._verify_hookGs–€Ø × Ñ Ô  8×#7Ò#7¸8×;KÒ;KÜ'Ø—’à×'Ó'¨¯«ð4óð ð �y‰yÐ$Ð$Ð$Ø �9‰9× !Ò !Ü ˜tŸy™y×5Ñ5°x×7HÑ7HÔ Iô˜×)Ñ)Ó*¬S°·±×1CÑ1CÓ-DÑDˆ Ù Ü'Ø—’ð ×(Ó(Ø—I“Iܘx×0Ñ0Õ1Úðó ð ð × Ò  × 4Ò 4Ü×-Ñ-¨h×.?Ñ.?Ô@Ü'Ø—’ð×'Ó'¨¯«´J¸x×?PÑ?PÕ4QðSóð ð × Ò  × 4Ò 4Ü'Ø—’ð×'Ó'¨¯«´J¸x×?PÑ?PÕ4QðSóð ð!5Ð r*c ó(—|jjD]y}|ddk7sŒ t|j|«}|j«rŒ3|j «D]4}|j rŒt |jd|›d|j›�«‚Œ{y)z›Verify that all hooks which have not been verified against a hook specification are optional, otherwise raise :exc:`PluginValidationError`.rÚ_z unknown hook z in plugin N)rYÚ__dict__rHror“Ú optionalhookr,r1)r2rCrYrvs r(Ú check_pendingzPluginManager.check_pendingvsz€ð—I‘I×&Ô&ˆDØ�A‰w˜#‹~Ü#*¨4¯9©9°dÓ#;�Ø—}‘}•Ø$(×$6Ñ$6Ö$8˜Ø'×4Ó4Ü"7Ø (§¢â#'¨¯ªð!:ó#ðñ%9ñ 'r*cóâ—ddl}d}t|jj««D]Â}|jD]±}|j |k7sG|�|j |k7s6|j|j «s|j|j «rŒZ|j«}|j||j ¬«|jj|t|«f«|dz }Œ³ŒÄ|S)a-Load modules from querying the specified setuptools ``group``. :param group: Entry point group to load plugins. :param name: If given, loads only plugins with the given ``name``. :return: The number of plugins loaded by this call. rNr‰r )Úimportlib.metadataÚlistrDÚ distributionsÚ entry_pointsÚgrouprCr‚rŒÚloadrwrXr”r>)r2rÃrCÚ importlibÚcountrAÚepr1s r(Úload_setuptools_entrypointsz)PluginManager.load_setuptools_entrypoints†sÆ€ó "àˆÜ˜×+Ñ+×9Ñ9Ó;Ö<ˆDØ×'Ô'�à—H‘H Ò%ØÐ(¨R¯W©W¸ª_à—‘ r§w¡wÔ/Ø—‘ r§w¡wÔ/àØŸ™›�Ø— ‘ ˜f¨2¯7©7� Ô3Ø×%Ñ%×,Ñ,¨f´jÀÓ6FÐ-GÔHؘ‘ ‘ñ(ð=ðˆ r*có,—t|j«S)zXReturn a list of (plugin, distinfo) pairs for all setuptools-registered plugins.)rÀrXrOs r(Úlist_plugin_distinfoz"PluginManager.list_plugin_distinfo¤s€ô�D×)Ñ)Ó*Ð*r*cóH—t|jj««S)zAReturn a list of (name, plugin) pairs for all registered plugins.)rÀrWr®rOs r(Úlist_name_pluginzPluginManager.list_name_plugin©s€ä�D×%Ñ%×+Ñ+Ó-Ó.Ð.r*cóê—|j|«€yg}|jjj«D]7}|j «D]"}|j |usŒ|j |«Œ$Œ9|S)z¸Get all hook callers for the specified plugin. :returns: The hook callers, or ``None`` if ``plugin`` is not registered in this plugin manager. N)r�rYr»rlr“r1r”)r2r1r…r†rvs r(rƒzPluginManager.get_hookcallers­sm€ð �=‰=˜Ó Ð (ØØˆ ØŸ)™)×,Ñ,×3Ñ3Ö5ˆJØ&×4Ñ4Ö6�Ø—?‘? fÒ,Ø×&Ñ& zÕ2ñ7ð6ðÐr*cóf‡‡‡‡—‰jŠ dˆˆˆfd„ }|‰_dˆˆfd„ }|S)a7Add before/after tracing functions for all hooks. Returns an undo function which, when called, removes the added tracers. ``before(hook_name, hook_impls, kwargs)`` will be called ahead of all hook calls and receive a hookcaller instance, a list of HookImpl instances and the keyword arguments for the hook call. ``after(outcome, hook_name, hook_impls, kwargs)`` receives the same arguments as ``before`` but also a :class:`~pluggy.Result` object which represents the result of the overall hook call. c󎕇‡‡‡—‰‰‰‰«tjˆˆˆˆˆfd„«}‰|‰‰‰«|j«S)Ncó•—‰‰‰‰‰«Sr.rR)Ú caller_kwargsrcÚ hook_implsr`Úoldcalls€€€€€r(ÚzPPluginManager.add_hookcall_monitoring..traced_hookexec..Ösø€™  ¨:°}ÀkÔRr*)rÚ from_callÚ get_result)r`rÒrÑrcÚoutcomeÚafterÚbeforerÓs```` €€€r(Útraced_hookexecz>PluginManager.add_hookcall_monitoring..traced_hookexecÎsCü€ñ �9˜j¨-Ô 8Ü×&Ñ&ßRóˆGñ �'˜9 j°-Ô @Ø×%Ñ%Ó'Ð 'r*có•—‰‰_yr.r_)rÓr2s€€r(Úundoz3PluginManager.add_hookcall_monitoring..undoÝs ø€Ø#*ˆDÕ r*) r`r5rÒúSequence[HookImpl]rÑúMapping[str, object]rcÚboolr6úobject | list[object]©r6r7r_)r2rÙrØrÚrÜrÓs``` @r(Úadd_hookcall_monitoringz%PluginManager.add_hookcall_monitoring½sYû€ð×&Ñ&ˆð (Øð (à*ð (ð0ð (ðð (ð #÷ (ð /ˆÔö +ðˆ r*c󮇗|jjjd«Š dˆfd„ } dˆfd„ }|j||«S)zwEnable tracing of hook calls. Returns an undo function which, when called, removes the added tracing. rYcóV•—‰jxjdz c_‰||«y)Nr )ÚrootÚindent)r`rarbÚ hooktraces €r(rÙz,PluginManager.enable_tracing..beforeés$ø€ð �N‰N× !Ò ! QÑ &Õ !Ù �i Õ (r*cóŽ•—|j€‰d|d|j««‰jxjdzc_y)NÚfinishz-->r )Ú exceptionrÖråræ)r×r`rarbrçs €r(rØz+PluginManager.enable_tracing..afterïs=ø€ð × Ñ Ð(Ù˜( I¨u°g×6HÑ6HÓ6JÔKØ �N‰N× !Ò ! QÑ &Ö !r*)r`r5rarÝrbrÞr6r7) r×zResult[object]r`r5rarÝrbrÞr6r7)r\rår[râ)r2rÙrØrçs @r(Úenable_tracingzPluginManager.enable_tracingâsŠø€ð —J‘J—O‘O×'Ñ'¨Ó/ˆ ð )Øð )Ø%7ð )ØAUð )à õ )ð  'Ø#ð 'àð 'ð(ð 'ð)ð  'ð õ  'ð×+Ñ+¨F°EÓ:Ð:r*có�—t|j|«}|D�chc]}t||«sŒ|’Œ}}|r t||«S|Scc}w)z«Return a proxy :class:`~pluggy.HookCaller` instance for the named method which manages calls to all registered plugins except the ones from remove_plugins.)rHrYÚhasattrr)r2rCÚremove_pluginsÚorigÚplugÚplugins_to_removes r(Úsubset_hook_callerz PluginManager.subset_hook_callerûsN€ô # 4§9¡9¨dÓ3ˆÙ.<ÓT©n dÄÈÈdÕ@SšT¨nÐÐTÙ Ü$ TÐ+<Ó=Ð =؈ ùòUs ›A­A)rFr5r6r7) r`r5rarÝrbrÞrcrßr6ràr.)r1rrCú str | Noner6ró)r1rrCr5r6zHookimplOpts | None)NN)r1z_Plugin | NonerCrór6ú Any | None)rCr5r6r7)rCr5r6rß)r•rr6r7)r•rrCr5r6zHookspecOpts | None)r6zset[Any])r1rr6rß)r1rr6r5)rCr5r6rô)r1rr6ró)rYrrvrr6r7rá)rÃr5rCrór6Úint)r6z list[tuple[_Plugin, DistFacade]])r6zlist[tuple[str, _Plugin]])r1rr6zlist[HookCaller] | None)rÙÚ _BeforeTracerØÚ _AfterTracer6úCallable[[], None])r6rø)rCr5rîzIterable[_Plugin]r6r)r8r9r:r;r0rdrwrmr‡rŠrŒr�ršr‘r r§rjr‚r¬r�rpr½rÈrÊrÌrƒrârëròrRr*r(rTrTOs'„ñó *ð Màð Mð$ð Mð%ð Mð ð Mð ó Mô1ófð4AEðØ$ðØ3=ðà óó@'ó Móóð4Ø)ðØ14ðà óó$/óHó 'ó+ó1óó-ó^ô ó<+ó /óð #Ø"ð#Ø+6ð#à ó#óJ;ð2 Øð Ø):ð à ô r*rTcóH—|j›tj|«›�Sr.)r8rzÚ signature)r's r(r¶r¶s!€Ø�m‰mˆ_œW×.Ñ.¨tÓ4Ð5Ð 6Ð6r*)r%ÚWarningr&úCallable[..., object]r6r7)r'rür6r5)*Ú __future__rrzrrÚtypingrrrrrr r r Úr Ú_callersrÚ_hooksrrrrrrrrrrÚ_resultrr¿rÅr5rör÷r)r|r,r>rTr¶rRr*r(ÚrsÖðÝ"ãÛ ÛÝÝÝÝÝÝÝÝ åÝ Ý%ÝÝÝ%ÝÝÝ ÝÝ Ý+Ýáãð˜˜h xÑ0°'¸#¸s¸(Ñ2CÐDÀdÐJÑK€ ؘ˜s™  S¨(°8Ñ*<¸gÀcÈ3ÀhÑ>OÐPÐRVÐVÑW€ óô ˜Iô ÷CñC÷$vñvôr 7r*