Skip to content

Commit f1a2270

Browse files
author
Tyler Goodlet
committed
Handle firstresult hooks that return None
Only return the first result when at least one result has been returned by underlying hook implementations. Fixes #68
1 parent 5ab312c commit f1a2270

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pluggy/callers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def execute(self):
107107
pass
108108

109109
if firstresult:
110-
return outcome.get_result()[0]
110+
result = outcome.get_result()
111+
return result[0] if result else None
111112

112113
return outcome.get_result()
113114

testing/test_hookrelay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def hello(self, arg):
112112

113113
pm.register(Plugin1())
114114
res = pm.hook.hello(arg=3)
115-
assert res == None
115+
assert res is None
116116

117117

118118
def test_firstresult_no_plugin(pm):
@@ -126,4 +126,4 @@ def hello(self, arg):
126126

127127
pm.add_hookspecs(Api)
128128
res = pm.hook.hello(arg=3)
129-
assert res == None
129+
assert res is None

0 commit comments

Comments
 (0)