Skip to content

Getting Started

Installation

pip install pluginator

Quick Start

1. Define a plugin

Use the @plugin() decorator to create a plugin class:

from pluginator.define import plugin, option
from pluginator import Action

@plugin("my-plugin", config="my_plugin.yaml", actions=[
    Action("greet", "my_plugin.actions.greet"),
])
class MyPlugin:
    message = option(str, default_from="default_message", env_var="MY_PLUGIN_MESSAGE")
    count = option(int, default=1)

    def default_message(self):
        return "Hello"

2. Create an action module

Each action references a module with a main function:

# my_plugin/actions/greet.py
def main(config, context):
    print(f"{config['message']} " * config['count'])

3. Install into pytest

In your conftest.py, call install_pytest_plugins:

from pluginator import install_pytest_plugins
from my_plugin import MyPlugin

install_pytest_plugins(MyPlugin())

4. Configure (optional)

Create a YAML config file (my_plugin.yaml):

message: "Hello from config"
count: 3

Plugin options are resolved in priority order: YAML config → environment variable → CLI argument → default property → type default.