Skip to content

Commit

Permalink
Handle py2.6 and better docs
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Tyler Goodlet committed Feb 16, 2017
1 parent 6c23946 commit e52f039
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pluggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e52f039

Please sign in to comment.