From 96b649462ecf4e7f4ca99624eceb5960c98bb1de Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Feb 2017 02:18:03 -0500 Subject: [PATCH] Handle py2.6 and better docs - don't use "Positional" in warning message - support python 2.6 sets - don't include __multicall__ in args comparison - document `varnames()` new pair return value --- pluggy.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pluggy.py b/pluggy.py index 5ac2518b..101e6c6d 100644 --- a/pluggy.py +++ b/pluggy.py @@ -579,11 +579,11 @@ def __repr__(self): def varnames(func): - """Return argument name tuple for a function, method, class or callable. + """Return tuple of positional and keywrord argument names for a function, + method, class or callable. - In case of a class, its "__init__" method is considered. - For methods the "self" parameter is not included unless you are passing - an unbound method with Python3 (which has no support for unbound methods) + In case of a class, its ``__init__`` method is considered. + For methods the ``self`` parameter is not included. """ cache = getattr(func, "__dict__", {}) try: @@ -702,13 +702,15 @@ def __repr__(self): def __call__(self, **kwargs): assert not self.is_historic() - notincall = set(self.argnames) - set(kwargs.keys()) - if notincall: - warnings.warn( - "Positional arg(s) %s are declared in the hookspec " - "but can not be found in this hook call" % notincall, - FutureWarning - ) + if self.argnames: + notincall = set(self.argnames) - set(['__multicall__']) - set( + kwargs.keys()) + if notincall: + warnings.warn( + "Argument(s) {0} which are declared in the hookspec " + "can not be found in this hook call" + .format(tuple(notincall)) + ) return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) def call_historic(self, proc=None, kwargs=None):