abx
Module Contents
Classes
Type of a plugin method decorated with @hookspec(firstresult=True), which returns a single result (from the first plugin that implements the hook) |
|
Type of a plugin method decorated with @hookspec(firstresult=False), which returns a list of results (one for each plugin that implements the hook) |
|
Improved version of pluggy.HookspecMarker that supports type inference of hookspecs with firstresult=True|False correctly https://github.com/pytest-dev/pluggy/issues/191 |
|
Full Metadata Dictionary containing all info about a plugin, returned by abx.get_plugin() |
|
Patch to fix pluggy’s PluginManager to work with pydantic models. See: https://github.com/pytest-dev/pluggy/pull/536 |
Functions
Check if a string is a valid attribute name (used to validate hook method names on a plugin) |
|
Check if a string e.g. “some_pkg.some_plugin_name” is a valid module name (used to validate plugin IDs) |
|
Get the order a plugin should be loaded in by reading its ./.plugin_order file or .order attr |
|
Get the full PluginInfo metadata for a plugin, given its plugin ID, module, or class |
|
Get the PluginInfo metadata for all the loaded plugins |
|
Get the names of all hookspec/hookimpl methods available across all loaded plugins |
|
Get a set of all hookspec methods defined in all plugins (useful for type checking if a pm.hook.call() is valid) |
|
Find all the plugins in a given directory. Just looks for an init.py file. |
|
replaces pm.load_setuptools_entrypoints(“abx”), finds plugins that registered entrypoints via pip |
|
Load all the plugins from a dictionary of module names and directory paths. |
|
Get all the functions marked with @hookimpl on a plugin module or class. |
|
Flatten a list of lists returned by a pm.hook.call() into a single list of [result1, result2, …] |
|
Flatten a list of dicts returned by a pm.hook.call() into a single dict of {plugin_id1: result1, plugin_id2: result2, …} |
Data
API
- class abx.HookSpecDecoratorThatReturnsFirstResult[source]
Bases:
typing.Protocol
Type of a plugin method decorated with @hookspec(firstresult=True), which returns a single result (from the first plugin that implements the hook)
- class abx.HookSpecDecoratorThatReturnsListResults[source]
Bases:
typing.Protocol
Type of a plugin method decorated with @hookspec(firstresult=False), which returns a list of results (one for each plugin that implements the hook)
- class abx.TypedHookspecMarker(project_name: str)[source]
Improved version of pluggy.HookspecMarker that supports type inference of hookspecs with firstresult=True|False correctly https://github.com/pytest-dev/pluggy/issues/191
Initialization
- __call__(function: Callable[abx.ParamsT, abx.ReturnT] | None = None, firstresult: bool = False, historic: bool = False, warn_on_impl: Warning | None = None, warn_on_impl_args: Mapping[str, Warning] | None = None) Callable[abx.ParamsT, List[abx.ReturnT]] | abx.HookSpecDecoratorThatReturnsListResults | abx.HookSpecDecoratorThatReturnsFirstResult [source]
- abx.is_valid_attr_name(x: str) str [source]
Check if a string is a valid attribute name (used to validate hook method names on a plugin)
- abx.is_valid_module_name(x: str) str [source]
Check if a string e.g. “some_pkg.some_plugin_name” is a valid module name (used to validate plugin IDs)
- class abx.PluginInfo[source]
Bases:
typing.TypedDict
Full Metadata Dictionary containing all info about a plugin, returned by abx.get_plugin()
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class abx.ABXPluginManager[source]
Bases:
pluggy.PluginManager
,typing.Generic
[abx.PluginSpec
]Patch to fix pluggy’s PluginManager to work with pydantic models. See: https://github.com/pytest-dev/pluggy/pull/536
- create_typed_hookcaller(name: str, module_or_class: Type[abx.PluginSpec], spec_opts: pluggy.HookspecOpts) pluggy.HookCaller [source]
create a new HookCaller subclass with a modified signature so that the return type is correct and args are converted to kwargs
- abx.get_plugin_order(plugin: abx.PluginId | pathlib.Path | types.ModuleType | Type) Tuple[int, pathlib.Path] [source]
Get the order a plugin should be loaded in by reading its ./.plugin_order file or .order attr
- abx.get_plugin(plugin: abx.PluginId | types.ModuleType | Type) abx.PluginInfo [source]
Get the full PluginInfo metadata for a plugin, given its plugin ID, module, or class
- abx.get_all_plugins() Dict[abx.PluginId, abx.PluginInfo] [source]
Get the PluginInfo metadata for all the loaded plugins
- abx.get_all_hook_names() Set[str] [source]
Get the names of all hookspec/hookimpl methods available across all loaded plugins
- abx.get_all_hook_specs() Dict[str, Dict[str, Any]] [source]
Get a set of all hookspec methods defined in all plugins (useful for type checking if a pm.hook.call() is valid)
- abx.find_plugins_in_dir(plugins_dir: pathlib.Path) Dict[abx.PluginId, pathlib.Path] [source]
Find all the plugins in a given directory. Just looks for an init.py file.
- abx.get_pip_installed_plugins(group: abx.PluginId = 'abx') Dict[abx.PluginId, pathlib.Path] [source]
replaces pm.load_setuptools_entrypoints(“abx”), finds plugins that registered entrypoints via pip
- abx.load_plugins(plugins: Iterable[abx.PluginId | types.ModuleType | Type] | Dict[abx.PluginId, pathlib.Path])[source]
Load all the plugins from a dictionary of module names and directory paths.
- abx.get_plugin_hooks(plugin: abx.PluginId | types.ModuleType | Type | None) Dict[abx.AttrName, Callable] [source]
Get all the functions marked with @hookimpl on a plugin module or class.