Skip to content

Commit cf059aa

Browse files
authored
Merge pull request #46 from MichalTHEDUDE/feature/NewStyleClasses
Moving to new style classes (object inheritance) - Issue #44
2 parents 21771da + 0759210 commit cf059aa

File tree

9 files changed

+71
-71
lines changed

9 files changed

+71
-71
lines changed

docs/examples/firstexample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
hookimpl = pluggy.HookimplMarker("myproject")
55

66

7-
class MySpec:
7+
class MySpec(object):
88
"""A hook specification namespace.
99
"""
1010
@hookspec
@@ -13,7 +13,7 @@ def myhook(self, arg1, arg2):
1313
"""
1414

1515

16-
class Plugin_1:
16+
class Plugin_1(object):
1717
"""A hook implementation namespace.
1818
"""
1919
@hookimpl
@@ -22,7 +22,7 @@ def myhook(self, arg1, arg2):
2222
return arg1 + arg2
2323

2424

25-
class Plugin_2:
25+
class Plugin_2(object):
2626
"""A 2nd hook implementation namespace.
2727
"""
2828
@hookimpl

pluggy.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
_py3 = sys.version_info > (3, 0)
1010

1111

12-
class HookspecMarker:
12+
class HookspecMarker(object):
1313
""" Decorator helper class for marking functions as hook specifications.
1414
1515
You can instantiate it with a project_name to get a decorator.
@@ -47,7 +47,7 @@ def setattr_hookspec_opts(func):
4747
return setattr_hookspec_opts
4848

4949

50-
class HookimplMarker:
50+
class HookimplMarker(object):
5151
""" Decorator helper class for marking functions as hook implementations.
5252
5353
You can instantiate with a project_name to get a decorator.
@@ -101,7 +101,7 @@ def normalize_hookimpl_opts(opts):
101101
opts.setdefault("optionalhook", False)
102102

103103

104-
class _TagTracer:
104+
class _TagTracer(object):
105105
def __init__(self):
106106
self._tag2proc = {}
107107
self.writer = None
@@ -148,7 +148,7 @@ def setprocessor(self, tags, processor):
148148
self._tag2proc[tags] = processor
149149

150150

151-
class _TagTracerSub:
151+
class _TagTracerSub(object):
152152
def __init__(self, root, tags):
153153
self.root = root
154154
self.tags = tags
@@ -188,7 +188,7 @@ def _wrapped_call(wrap_controller, func):
188188
return call_outcome.get_result()
189189

190190

191-
class _CallOutcome:
191+
class _CallOutcome(object):
192192
""" Outcome of a function call, either an exception or a proper result.
193193
Calling the ``get_result`` method will return the result or reraise
194194
the exception raised when the function was called. """
@@ -221,7 +221,7 @@ def _reraise(cls, val, tb):
221221
""")
222222

223223

224-
class _TracedHookExecution:
224+
class _TracedHookExecution(object):
225225
def __init__(self, pluginmanager, before, after):
226226
self.pluginmanager = pluginmanager
227227
self.before = before
@@ -517,7 +517,7 @@ def subset_hook_caller(self, name, remove_plugins):
517517
return orig
518518

519519

520-
class _MultiCall:
520+
class _MultiCall(object):
521521
""" execute a call into multiple python functions/methods. """
522522

523523
# XXX note that the __multicall__ argument is supported only
@@ -611,7 +611,7 @@ def varnames(func):
611611
return tuple(args)
612612

613613

614-
class _HookRelay:
614+
class _HookRelay(object):
615615
""" hook holder object for performing 1:N hook calls where N is the number
616616
of registered plugins.
617617
@@ -715,7 +715,7 @@ def _maybe_apply_history(self, method):
715715
proc(res[0])
716716

717717

718-
class HookImpl:
718+
class HookImpl(object):
719719
def __init__(self, plugin, plugin_name, function, hook_impl_opts):
720720
self.function = function
721721
self.argnames = varnames(self.function)

testing/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def he_pm(request, pm):
1515
from pluggy import HookspecMarker
1616
hookspec = HookspecMarker("example")
1717

18-
class Hooks:
18+
class Hooks(object):
1919
@hookspec
2020
def he_method1(self, arg):
2121
return arg + 1

testing/test_details.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def parse_hookimpl_opts(self, module_or_class, name):
1515
opts = {}
1616
return opts
1717

18-
class Plugin:
18+
class Plugin(object):
1919
def x1meth(self):
2020
pass
2121

2222
@hookimpl(hookwrapper=True, tryfirst=True)
2323
def x1meth2(self):
2424
pass
2525

26-
class Spec:
26+
class Spec(object):
2727
@hookspec
2828
def x1meth(self):
2929
pass
@@ -48,11 +48,11 @@ def test_plugin_getattr_raises_errors():
4848
"""Pluggy must be able to handle plugins which raise weird exceptions
4949
when getattr() gets called (#11).
5050
"""
51-
class DontTouchMe:
51+
class DontTouchMe(object):
5252
def __getattr__(self, x):
5353
raise Exception('cant touch me')
5454

55-
class Module:
55+
class Module(object):
5656
pass
5757

5858
module = Module()

testing/test_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def test_varnames():
55
def f(x):
66
i = 3 # noqa
77

8-
class A:
8+
class A(object):
99
def f(self, y):
1010
pass
1111

@@ -26,11 +26,11 @@ def f(x, y=3):
2626

2727

2828
def test_varnames_class():
29-
class C:
29+
class C(object):
3030
def __init__(self, x):
3131
pass
3232

33-
class D:
33+
class D(object):
3434
pass
3535

3636
class E(object):

testing/test_hookrelay.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def test_happypath(pm):
10-
class Api:
10+
class Api(object):
1111
@hookspec
1212
def hello(self, arg):
1313
"api hook 1"
@@ -17,7 +17,7 @@ def hello(self, arg):
1717
assert hasattr(hook, 'hello')
1818
assert repr(hook.hello).find("hello") != -1
1919

20-
class Plugin:
20+
class Plugin(object):
2121
@hookimpl
2222
def hello(self, arg):
2323
return arg + 1
@@ -32,14 +32,14 @@ def hello(self, arg):
3232

3333

3434
def test_argmismatch(pm):
35-
class Api:
35+
class Api(object):
3636
@hookspec
3737
def hello(self, arg):
3838
"api hook 1"
3939

4040
pm.add_hookspecs(Api)
4141

42-
class Plugin:
42+
class Plugin(object):
4343
@hookimpl
4444
def hello(self, argwrong):
4545
pass
@@ -51,7 +51,7 @@ def hello(self, argwrong):
5151

5252

5353
def test_only_kwargs(pm):
54-
class Api:
54+
class Api(object):
5555
@hookspec
5656
def hello(self, arg):
5757
"api hook 1"
@@ -61,14 +61,14 @@ def hello(self, arg):
6161

6262

6363
def test_firstresult_definition(pm):
64-
class Api:
64+
class Api(object):
6565
@hookspec(firstresult=True)
6666
def hello(self, arg):
6767
"api hook 1"
6868

6969
pm.add_hookspecs(Api)
7070

71-
class Plugin:
71+
class Plugin(object):
7272
@hookimpl
7373
def hello(self, arg):
7474
return arg + 1

testing/test_method_ordering.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@pytest.fixture
1414
def hc(pm):
15-
class Hooks:
15+
class Hooks(object):
1616
@hookspec
1717
def he_method1(self, arg):
1818
pass
@@ -149,7 +149,7 @@ def he_method2():
149149

150150

151151
def test_hookspec(pm):
152-
class HookSpec:
152+
class HookSpec(object):
153153
@hookspec()
154154
def he_myhook1(arg1):
155155
pass
@@ -181,14 +181,14 @@ def he_myhook1(arg1):
181181

182182

183183
def test_decorator_functional(pm):
184-
class HookSpec:
184+
class HookSpec(object):
185185
@hookspec(firstresult=True)
186186
def he_myhook(self, arg1):
187187
""" add to arg1 """
188188

189189
pm.add_hookspecs(HookSpec)
190190

191-
class Plugin:
191+
class Plugin(object):
192192
@hookimpl()
193193
def he_myhook(self, arg1):
194194
return arg1 + 1
@@ -204,12 +204,12 @@ def test_load_setuptools_instantiation(monkeypatch, pm):
204204
def my_iter(name):
205205
assert name == "hello"
206206

207-
class EntryPoint:
207+
class EntryPoint(object):
208208
name = "myname"
209209
dist = None
210210

211211
def load(self):
212-
class PseudoPlugin:
212+
class PseudoPlugin(object):
213213
x = 42
214214
return PseudoPlugin()
215215

@@ -235,12 +235,12 @@ def test_load_setuptools_not_installed(monkeypatch, pm):
235235
def test_add_tracefuncs(he_pm):
236236
l = []
237237

238-
class api1:
238+
class api1(object):
239239
@hookimpl
240240
def he_method1(self):
241241
l.append("he_method1-api1")
242242

243-
class api2:
243+
class api2(object):
244244
@hookimpl
245245
def he_method1(self):
246246
l.append("he_method1-api2")
@@ -274,12 +274,12 @@ def after(outcome, hook_name, hook_impls, kwargs):
274274
def test_hook_tracing(he_pm):
275275
saveindent = []
276276

277-
class api1:
277+
class api1(object):
278278
@hookimpl
279279
def he_method1(self):
280280
saveindent.append(he_pm.trace.root.indent)
281281

282-
class api2:
282+
class api2(object):
283283
@hookimpl
284284
def he_method1(self):
285285
saveindent.append(he_pm.trace.root.indent)
@@ -311,14 +311,14 @@ def he_method1(self):
311311
def test_prefix_hookimpl():
312312
pm = PluginManager(hookspec.project_name, "hello_")
313313

314-
class HookSpec:
314+
class HookSpec(object):
315315
@hookspec
316316
def hello_myhook(self, arg1):
317317
""" add to arg1 """
318318

319319
pm.add_hookspecs(HookSpec)
320320

321-
class Plugin:
321+
class Plugin(object):
322322
def hello_myhook(self, arg1):
323323
return arg1 + 1
324324

@@ -331,7 +331,7 @@ def hello_myhook(self, arg1):
331331
def test_prefix_hookimpl_dontmatch_module():
332332
pm = PluginManager(hookspec.project_name, "hello_")
333333

334-
class BadPlugin:
334+
class BadPlugin(object):
335335
hello_module = __import__('email')
336336

337337
pm.register(BadPlugin())

testing/test_multicall.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ def MC(methods, kwargs, firstresult=False):
2626

2727

2828
def test_call_passing():
29-
class P1:
29+
class P1(object):
3030
@hookimpl
3131
def m(self, __multicall__, x):
3232
assert len(__multicall__.results) == 1
3333
assert not __multicall__.hook_impls
3434
return 17
3535

36-
class P2:
36+
class P2(object):
3737
@hookimpl
3838
def m(self, __multicall__, x):
3939
assert __multicall__.results == []
@@ -55,7 +55,7 @@ def test_keyword_args():
5555
def f(x):
5656
return x + 1
5757

58-
class A:
58+
class A(object):
5959
@hookimpl
6060
def f(self, x, y):
6161
return x + y

0 commit comments

Comments
 (0)