A minimalist production ready plugin system https://pluggy.readthedocs.io/en/latest/
  • Python 99.7%
  • Shell 0.3%
Find a file
pre-commit-ci[bot] 38e558f33f
[pre-commit.ci] pre-commit autoupdate (#854)
updates:
- [github.com/asottile/blacken-docs: 1.20.0 → 1.21.0](https://github.com/asottile/blacken-docs/compare/1.20.0...1.21.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-11-30 23:41:33 +01:00
.claude Add CLAUDE.md with development guidance and AGENTS.md reference 2025-11-28 14:06:04 +01:00
.github build(deps): bump astral-sh/setup-uv (#828) 2026-11-16 18:39:44 +01:00
changelog Add changelog entry for #844 2026-11-21 08:19:53 +02:00
docs docs: remove outdated hookimpl default args paragraph 2026-10-14 17:46:38 +03:00
downstream refactor: extend the argument list instead of appending in a loop 2026-08-12 07:44:54 +02:00
scripts expand ruff linting 2025-03-27 11:22:11 +01:00
src/pluggy Detect a staticmethod hookspec on an instance namespace too 2026-11-22 08:06:21 +02:00
testing Exclude the never-called staticmethod spec stubs from coverage 2026-11-23 08:04:45 +02:00
.coveragerc chore: fix coverage report paths (#669) 2026-04-29 18:05:33 +02:00
.git_archival.txt Add stable .git_archival.txt for setuptools-scm 2026-10-05 08:37:35 +00:00
.gitattributes Add stable .git_archival.txt for setuptools-scm 2026-10-05 08:37:35 +00:00
.gitignore Add uv dependency management and dev tooling 2025-10-27 10:15:36 +01:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate (#854) 2026-11-30 23:41:33 +01:00
.readthedocs.yml [pre-commit.ci] pre-commit autoupdate, fix 'sphinx.configuration' (#561) 2025-01-14 13:13:06 +01:00
AGENTS.md Add CLAUDE.md with development guidance and AGENTS.md reference 2025-11-28 14:06:04 +01:00
CHANGELOG.rst Preparing release 1.7.0 2026-10-14 17:53:56 +03:00
CLAUDE.md lint: drop flake8, ruff covers it 2026-08-12 07:44:54 +02:00
codecov.yml ci: add codecov config 2020-01-16 01:12:15 +01:00
LICENSE Remove extra newlines at the end of files 2018-08-02 22:13:32 -03:00
MANIFEST.in Fix manifest: include testing directory 2016-09-25 19:20:55 -03:00
pyproject.toml Drop tox from the dev dependency group 2026-10-11 11:01:28 +02:00
README.rst README: replace Gitter badge with pytest-dev Discord badge 2026-11-15 07:41:31 +01:00
RELEASING.rst Drop tox from the dev dependency group 2026-10-11 11:01:28 +02:00
SECURITY.md Lift pluggy (#493) 2024-04-08 13:59:11 -03:00
TIDELIFT.rst Lift pluggy (#493) 2024-04-08 13:59:11 -03:00
tox.ini lint: drop flake8, ruff covers it 2026-08-12 07:44:54 +02:00
uv.lock build(deps): bump virtualenv from 21.7.13 to 21.14.13 (#812) 2026-10-25 12:05:36 +01:00

====================================================
pluggy - A minimalist production ready plugin system
====================================================

|pypi| |conda-forge| |versions| |github-actions| |discord| |black| |codecov|

This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.

Please `read the docs`_ to learn more!

A definitive example
====================
.. code-block:: python

    import pluggy

    hookspec = pluggy.HookspecMarker("myproject")
    hookimpl = pluggy.HookimplMarker("myproject")


    class MySpec:
        """A hook specification namespace."""

        @hookspec
        def myhook(self, arg1, arg2):
            """My special little hook that you can customize."""


    class Plugin_1:
        """A hook implementation namespace."""

        @hookimpl
        def myhook(self, arg1, arg2):
            print("inside Plugin_1.myhook()")
            return arg1 + arg2


    class Plugin_2:
        """A 2nd hook implementation namespace."""

        @hookimpl
        def myhook(self, arg1, arg2):
            print("inside Plugin_2.myhook()")
            return arg1 - arg2


    # create a manager and add the spec
    pm = pluggy.PluginManager("myproject")
    pm.add_hookspecs(MySpec)

    # register plugins
    pm.register(Plugin_1())
    pm.register(Plugin_2())

    # call our ``myhook`` hook
    results = pm.hook.myhook(arg1=1, arg2=2)
    print(results)


Running this directly gets us::

    $ python docs/examples/toy-example.py
    inside Plugin_2.myhook()
    inside Plugin_1.myhook()
    [-1, 3]


.. badges

.. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
    :target: https://pypi.org/pypi/pluggy

.. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
    :target: https://pypi.org/pypi/pluggy

.. |github-actions| image:: https://github.com/pytest-dev/pluggy/workflows/test/badge.svg
    :target: https://github.com/pytest-dev/pluggy/actions

.. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pluggy.svg
    :target: https://anaconda.org/conda-forge/pytest

.. |discord| image:: https://img.shields.io/badge/Discord-pytest--dev-blue
    :alt: Discord
    :target: https://discord.com/invite/pytest-dev

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. |codecov| image:: https://codecov.io/gh/pytest-dev/pluggy/branch/main/graph/badge.svg
    :target: https://codecov.io/gh/pytest-dev/pluggy
    :alt: Code coverage Status

.. links
.. _pytest:
    https://pytest.org
.. _tox:
    https://tox.wiki/
.. _devpi:
    https://doc.devpi.net
.. _read the docs:
   https://pluggy.readthedocs.io/en/latest/


Support pluggy
--------------

`Open Collective`_ is an online funding platform for open and transparent communities.
It provides tools to raise money and share your finances in full transparency.

It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.

``pluggy`` is part of the ``pytest-dev`` project, see more details in the `pytest collective`_.

.. _Open Collective: https://opencollective.com
.. _pytest collective: https://opencollective.com/pytest