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

Deprecate implprefix #144

Merged
merged 3 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pluggy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ class PluginManager(object):
"""

def __init__(self, project_name, implprefix=None):
""" if implprefix is given implementation functions
"""If ``implprefix`` is given implementation functions
will be recognized if their name matches the implprefix. """
self.project_name = project_name
self._name2plugin = {}
self._plugin2hookcallers = {}
self._plugin_distinfo = []
self.trace = _tracing.TagTracer().get("pluginmanage")
self.hook = _HookRelay(self.trace.root.get("hook"))
if implprefix is not None:
warnings.warn(
"Support for the `implprefix` arg is now deprecated and will "
"be removed in an upcoming release. Please use HookimplMarker.",
DeprecationWarning
)
self._implprefix = implprefix
self._inner_hookexec = lambda hook, methods, kwargs: \
hook.multicall(
Expand Down Expand Up @@ -106,7 +112,14 @@ def parse_hookimpl_opts(self, plugin, name):
if res is not None and not isinstance(res, dict):
# false positive
res = None
# TODO: remove when we drop implprefix in 1.0
elif res is None and self._implprefix and name.startswith(self._implprefix):
_warn_for_function(
DeprecationWarning(
"The `implprefix` system is deprecated please decorate "
"this function using an instance of HookimplMarker."),
method
)
res = {}
return res

Expand Down
12 changes: 12 additions & 0 deletions testing/test_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,15 @@ def test_result_deprecated():
r = _Result(10, None)
with pytest.deprecated_call():
assert r.result == 10


def test_implprefix_deprecated():
with pytest.deprecated_call():
pm = PluginManager('blah', implprefix='blah_')

class Plugin:
def blah_myhook(self, arg1):
return arg1

with pytest.deprecated_call():
pm.register(Plugin())