napari_plugin_engine/hooks.py
def _call_plugin(self, plugin_name: str, *args, **kwargs):
        """Call the hook implementation for a specific plugin

        .. note::

           This method is not intended to be called directly. Instead, just
           call the instance directly, specifing the ``_plugin`` argument.
           See the :meth:`__call__` method.

        Parameters
        ----------
        plugin_name : str
            Name of the plugin

        Returns
        -------
        Any
            Result of implementation call provided by plugin

        Raises
        ------
        TypeError
            If the implementation is a hook wrapper (cannot be called directly)
        TypeError
            If positional arguments are provided
        HookCallError
            If one of the required arguments in the hook specification is not
            present in ``kwargs``.
        PluginCallError
            If an exception is raised when calling the plugin
        """
        self._check_call_kwargs(kwargs)
        implementation = self.get_plugin_implementation(plugin_name)
        if implementation.hookwrapper:
            raise TypeError("Hook wrappers can not be called directly")

        # pluggy only allows calling hooks with keyword arguments
        if args:
            raise TypeError("hook calling supports only keyword arguments")
        _args: List[Any] = []
        # this converts kwargs into positional arguments in the correct order
        # for the hookspec
        try:
            _args = [kwargs[argname] for argname in implementation.argnames]
        except KeyError:
            for argname in implementation.argnames:
                if argname not in kwargs:
                    raise HookCallError(
                        f"hook call must provide argument {argname}"
                    )

        try:
            return implementation(*_args)
        except Exception as exc:
            raise PluginCallError(implementation) from exc
Call the hook implementation for a specific plugin

        .. note::

           This method is not intended to be called directly. Instead, just
           call the instance directly, specifing the ``_plugin`` argument.
           See the :meth:`__call__` method.

        Parameters
        ----------
        plugin_name : str
            Name of the plugin

        Returns
        -------
        Any
            Result of implementation call provided by plugin

        Raises
        ------
        TypeError
            If the implementation is a hook wrapper (cannot be called directly)
        TypeError
            If positional arguments are provided
        HookCallError
            If one of the required arguments in the hook specification is not
            present in ``kwargs``.
        PluginCallError
            If an exception is raised when calling the plugin
        
Call the hook implementation for a specific plugin
note:.

This method is not intended to be called directly. Instead, just
call the instance directly, specifing the ``_plugin`` argument.
See the :meth:`__call__` method.

Parameters

plugin_name : str
Name of the plugin

Returns

Any
Result of implementation call provided by plugin

Raises

TypeError
If the implementation is a hook wrapper (cannot be called directly)
TypeError
If positional arguments are provided
HookCallError
If one of the required arguments in the hook specification is not
present in ``kwargs``.
PluginCallError
If an exception is raised when calling the plugin
Call the hook implementation for a specific plugin note : . This method is not intended to be called directly . Instead just call the instance directly specifing the ` ` _plugin ` ` argument . See the : meth : ` __call__ ` method . Parameters plugin_name : str Name of the plugin Returns Any Result of implementation call provided by plugin Raises TypeError If the implementation is a hook wrapper ( cannot be called directly ) TypeError If positional arguments are provided HookCallError If one of the required arguments in the hook specification is not present in ` ` kwargs ` ` . PluginCallError If an exception is raised when calling the plugin
def _call_plugin(self, plugin_name: str, *args, **kwargs):
        self._check_call_kwargs(kwargs)
        implementation = self.get_plugin_implementation(plugin_name)
        if implementation.hookwrapper:
            raise TypeError("Hook wrappers can not be called directly")
        if args:
            raise TypeError("hook calling supports only keyword arguments")
        _args: List[Any] = []
        try:
            _args = [kwargs[argname] for argname in implementation.argnames]
        except KeyError:
            for argname in implementation.argnames:
                if argname not in kwargs:
                    raise HookCallError(
                        f"hook call must provide argument {argname}"
                    )
        try:
            return implementation(*_args)
        except Exception as exc:
            raise PluginCallError(implementation) from exc
def _call_plugin ( self , plugin_name : str , * args , ** kwargs ) : self . _check_call_kwargs ( kwargs ) implementation = self . get_plugin_implementation ( plugin_name ) if implementation . hookwrapper : raise TypeError ( "Hook wrappers can not be called directly" ) if args : raise TypeError ( "hook calling supports only keyword arguments" ) _args : List [ Any ] = [ ] try : _args = [ kwargs [ argname ] for argname in implementation . argnames ] except KeyError : for argname in implementation . argnames : if argname not in kwargs : raise HookCallError ( f"hook call must provide argument {argname}" ) try : return implementation ( * _args ) except Exception as exc : raise PluginCallError ( implementation ) from exc
Call the hook implementation for a specific plugin
.. note::
Call the hook implementation for a specific plugin .. note ::
"""Call the hook implementation for a specific plugin

        .. note::

           This method is not intended to be called directly. Instead, just
           call the instance directly, specifing the ``_plugin`` argument.
           See the :meth:`__call__` method.

        Parameters
        ----------
        plugin_name : str
            Name of the plugin

        Returns
        -------
        Any
            Result of implementation call provided by plugin

        Raises
        ------
        TypeError
            If the implementation is a hook wrapper (cannot be called directly)
        TypeError
            If positional arguments are provided
        HookCallError
            If one of the required arguments in the hook specification is not
            present in ``kwargs``.
        PluginCallError
            If an exception is raised when calling the plugin
        """ # pluggy only allows calling hooks with keyword arguments # this converts kwargs into positional arguments in the correct order # for the hookspec
self
plugin_name
str