pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.23k stars 121 forks source link

Add support deprecating hook parameters #495

Closed bluetech closed 4 months ago

bluetech commented 4 months ago

pytest has some hooks with deprecated parameters see here. We were able to apply some hack to raise a deprecation for callers passing these parameters, but for deprecating hookimpls which requests these parameters, we need support from pluggy.

This adds support for doing this:

@hookspec(
    warn_on_impl_args={
        "lousy_arg": DeprecationWarning(
            "The lousy_arg parameter of refreshed_hook is deprecated and will be removed soon; "
            "use awesome_arg instead"
        ),
    },
)
def refreshed_hook(lousy_arg, awesome_arg):
    pass

I have verified that this works for pytest.

Fix #178.