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

A few minor fixes #224

Merged
merged 4 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,9 @@ using the :py:meth:`pluggy._HookCaller.call_historic()` method:


# call with history; no results returned
pm.hook.myhook.call_historic(config=config, args=sys.argv, result_callback=callback)
pm.hook.myhook.call_historic(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

kwargs={"config": config, "args": sys.argv}, result_callback=callback
)

# ... more of our program ...

Expand Down
10 changes: 5 additions & 5 deletions src/pluggy/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def varnames(func):
try:
func = getattr(func, "__call__", func)
except Exception:
return ()
return (), ()

try: # func MUST be a function or method here or we won't parse any args
spec = _getargspec(func)
Expand All @@ -171,9 +171,9 @@ def varnames(func):
args, defaults = tuple(spec.args), spec.defaults
if defaults:
index = -len(defaults)
args, defaults = args[:index], tuple(args[index:])
args, kwargs = args[:index], tuple(args[index:])
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that this name is better.

else:
defaults = ()
kwargs = ()

# strip any implicit instance arg
# pypy3 uses "obj" instead of "self" for default dunder methods
Expand All @@ -185,10 +185,10 @@ def varnames(func):
args = args[1:]

try:
cache["_varnames"] = args, defaults
cache["_varnames"] = args, kwargs
except TypeError:
pass
return args, defaults
return args, kwargs


class _HookRelay(object):
Expand Down
11 changes: 1 addition & 10 deletions testing/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import pytest
from pluggy import HookCallError, HookspecMarker, HookimplMarker
from pluggy.hooks import HookImpl
from pluggy.callers import _multicall, _legacymulticall, _LegacyMultiCall
from pluggy.callers import _multicall, _legacymulticall


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


def test_uses_copy_of_methods():
Copy link
Contributor

Choose a reason for hiding this comment

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

@bluetech you're saying this test was broken for you?

I don't recall seeing that issue but we are planning on removing all of this as per #59 anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

The test has a typo return instead of assert. If the typo is fixed, it fails. Actually the methods are not copied. Since I think the test is ill conceived and tests deprecated functionality, I opted to just remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

out = [lambda: 42]
mc = _LegacyMultiCall(out, {})
repr(mc)
out[:] = []
res = mc.execute()
return res == 42


def MC(methods, kwargs, firstresult=False):
caller = _multicall
hookfuncs = []
Expand Down