internal/tools/: pluggy-1.5.0 metadata and description

Homepage Simple index

plugin and hook calling mechanisms for python

author Holger Krekel
author_email holger@merlinux.eu
classifiers
  • Development Status :: 6 - Mature
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: POSIX
  • Operating System :: Microsoft :: Windows
  • Operating System :: MacOS :: MacOS X
  • Topic :: Software Development :: Testing
  • Topic :: Software Development :: Libraries
  • Topic :: Utilities
  • Programming Language :: Python :: Implementation :: CPython
  • Programming Language :: Python :: Implementation :: PyPy
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3 :: Only
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
description_content_type text/x-rst
license MIT
platform
  • unix
  • linux
  • osx
  • win32
provides_extras testing
requires_dist
  • pre-commit ; extra == 'dev'
  • tox ; extra == 'dev'
  • pytest ; extra == 'testing'
  • pytest-benchmark ; extra == 'testing'
requires_python >=3.8
File Tox results History
pluggy-1.5.0-py3-none-any.whl
Size
20 KB
Type
Python Wheel
Python
3
  • Replaced 13 time(s)
  • Uploaded to internal/tools by internal 2024-07-05 12:47:37
pluggy-1.5.0.tar.gz
Size
66 KB
Type
Source

pypi conda-forge versions github-actions Join the chat at https://gitter.im/pytest-dev/pluggy black Code coverage Status

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

Please read the docs to learn more!

A definitive example

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]

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.