Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support deprecating hook parameters #495

Merged
merged 1 commit into from Apr 19, 2024

Conversation

bluetech
Copy link
Member

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.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

docs/index.rst Show resolved Hide resolved
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good - im hoping we can expand it to ensure forward/backward compatibility with hook callers at some point

@bluetech bluetech merged commit b4a8c92 into pytest-dev:main Apr 19, 2024
15 of 17 checks passed
@bluetech bluetech deleted the warn-on-impl-args branch April 19, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate hook parameters
3 participants