Skip to content

Commit e52f039

Browse files
author
Tyler Goodlet
committed
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
1 parent 6c23946 commit e52f039

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pluggy.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,11 @@ def __repr__(self):
579579

580580

581581
def varnames(func):
582-
"""Return argument name tuple for a function, method, class or callable.
582+
"""Return tuple of positional and keywrord argument names for a function,
583+
method, class or callable.
583584
584-
In case of a class, its "__init__" method is considered.
585-
For methods the "self" parameter is not included unless you are passing
586-
an unbound method with Python3 (which has no support for unbound methods)
585+
In case of a class, its ``__init__`` method is considered.
586+
For methods the ``self`` parameter is not included.
587587
"""
588588
cache = getattr(func, "__dict__", {})
589589
try:
@@ -702,13 +702,15 @@ def __repr__(self):
702702

703703
def __call__(self, **kwargs):
704704
assert not self.is_historic()
705-
notincall = set(self.argnames) - set(kwargs.keys())
706-
if notincall:
707-
warnings.warn(
708-
"Positional arg(s) %s are declared in the hookspec "
709-
"but can not be found in this hook call" % notincall,
710-
FutureWarning
711-
)
705+
if self.argnames:
706+
notincall = set(self.argnames) - set(['__multicall__']) - set(
707+
kwargs.keys())
708+
if notincall:
709+
warnings.warn(
710+
"Argument(s) {0} which are declared in the hookspec "
711+
"can not be found in this hook call"
712+
.format(tuple(notincall))
713+
)
712714
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
713715

714716
def call_historic(self, proc=None, kwargs=None):

0 commit comments

Comments
 (0)