@@ -186,8 +186,8 @@ decorators are used to *mark* functions for detection by a ``PluginManager``:
186186
187187 from pluggy import HookspecMarker, HookimplMarker
188188
189- hookspec = HookspecMarker(' project_name' )
190- hookimpl = HookimplMarker(' project_name' )
189+ hookspec = HookspecMarker(" project_name" )
190+ hookimpl = HookimplMarker(" project_name" )
191191
192192
193193 Each decorator type takes a single ``project_name `` string as its
@@ -224,7 +224,8 @@ which has been appropriately marked.
224224 import sys
225225 from pluggy import PluginManager, HookimplMarker
226226
227- hookimpl = HookimplMarker(' myproject' )
227+ hookimpl = HookimplMarker(" myproject" )
228+
228229
229230 @hookimpl
230231 def setup_project (config , args ):
@@ -236,7 +237,8 @@ which has been appropriately marked.
236237
237238 return config
238239
239- pm = PluginManager(' myproject' )
240+
241+ pm = PluginManager(" myproject" )
240242
241243 # load all hookimpls from the local module's namespace
242244 plugin_name = pm.register(sys.modules[__name__ ])
@@ -273,7 +275,8 @@ will be executed *first* or *last* respectively in the hook call loop:
273275 import sys
274276 from pluggy import PluginManager, HookimplMarker
275277
276- hookimpl = HookimplMarker(' myproject' )
278+ hookimpl = HookimplMarker(" myproject" )
279+
277280
278281 @hookimpl (trylast = True )
279282 def setup_project (config , args ):
@@ -288,6 +291,7 @@ will be executed *first* or *last* respectively in the hook call loop:
288291 class SomeOtherPlugin (object ):
289292 """ Some other plugin defining the same hook.
290293 """
294+
291295 @hookimpl (tryfirst = True )
292296 def setup_project (self , config , args ):
293297 """ Report what args were passed before calling
@@ -298,7 +302,8 @@ will be executed *first* or *last* respectively in the hook call loop:
298302
299303 return config
300304
301- pm = PluginManager(' myproject' )
305+
306+ pm = PluginManager(" myproject" )
302307
303308 # load from the local module's namespace
304309 pm.register(sys.modules[__name__ ])
@@ -334,8 +339,7 @@ be implemented as generator function with a single ``yield`` in its body:
334339 should return json encoded config options.
335340 """
336341 if config.debug:
337- print (" Pre-hook config is {} " .format(
338- config.tojson()))
342+ print (" Pre-hook config is {} " .format(config.tojson()))
339343
340344 # get initial default config
341345 defaults = config.tojson()
@@ -347,8 +351,7 @@ be implemented as generator function with a single ``yield`` in its body:
347351 print (" JSON config override is {} " .format(item))
348352
349353 if config.debug:
350- print (" Post-hook config is {} " .format(
351- config.tojson()))
354+ print (" Post-hook config is {} " .format(config.tojson()))
352355
353356 if config.use_defaults:
354357 outcome.force_result(defaults)
@@ -387,15 +390,17 @@ should be added before registering corresponding *hookimpls*:
387390 import sys
388391 from pluggy import PluginManager, HookspecMarker
389392
390- hookspec = HookspecMarker(' myproject' )
393+ hookspec = HookspecMarker(" myproject" )
394+
391395
392396 @hookspec
393397 def setup_project (config , args ):
394398 """ This hook is used to process the initial config and input
395399 arguments.
396400 """
397401
398- pm = PluginManager(' myproject' )
402+
403+ pm = PluginManager(" myproject" )
399404
400405 # load from the local module's namespace
401406 pm.add_hookspecs(sys.modules[__name__ ])
@@ -437,6 +442,7 @@ In other words this is ok:
437442 def myhook (config , args ):
438443 pass
439444
445+
440446 @hookimpl
441447 def myhook (args ):
442448 print (args)
@@ -450,6 +456,7 @@ whereas this is not:
450456 def myhook (config , args ):
451457 pass
452458
459+
453460 @hookimpl
454461 def myhook (config , args , extra_arg ):
455462 print (args)
@@ -513,7 +520,9 @@ if a hookspec specifies a ``warn_on_impl``, pluggy will trigger it for any plugi
513520
514521.. code-block :: python
515522
516- @hookspec (warn_on_impl = DeprecationWarning (" oldhook is deprecated and will be removed soon" ))
523+ @hookspec (
524+ warn_on_impl = DeprecationWarning (" oldhook is deprecated and will be removed soon" )
525+ )
517526 def oldhook ():
518527 pass
519528
@@ -530,7 +539,8 @@ A ``PluginManager`` is instantiated with a single
530539.. code-block :: python
531540
532541 import pluggy
533- pm = pluggy.PluginManager(' my_project_name' )
542+
543+ pm = pluggy.PluginManager(" my_project_name" )
534544
535545
536546 The ``project_name `` value is used when a ``PluginManager `` scans for *hook *
@@ -643,7 +653,8 @@ assertion should not error:
643653
644654 from pluggy import PluginManager, HookimplMarker
645655
646- hookimpl = HookimplMarker(' myproject' )
656+ hookimpl = HookimplMarker(" myproject" )
657+
647658
648659 class Plugin1 (object ):
649660 @hookimpl
@@ -652,21 +663,24 @@ assertion should not error:
652663 """
653664 return 1
654665
666+
655667 class Plugin2 (object ):
656668 @hookimpl
657669 def myhook (self , args ):
658670 """ Default implementation.
659671 """
660672 return 2
661673
674+
662675 class Plugin3 (object ):
663676 @hookimpl
664677 def myhook (self , args ):
665678 """ Default implementation.
666679 """
667680 return 3
668681
669- pm = PluginManager(' myproject' )
682+
683+ pm = PluginManager(" myproject" )
670684 pm.register(Plugin1())
671685 pm.register(Plugin2())
672686 pm.register(Plugin3())
@@ -697,23 +711,27 @@ point:
697711
698712 from pluggy import PluginManager, HookimplMarker
699713
700- hookimpl = HookimplMarker(' myproject' )
714+ hookimpl = HookimplMarker(" myproject" )
715+
701716
702717 class Plugin1 (object ):
703718 @hookimpl
704719 def myhook (self , args ):
705720 return 1
706721
722+
707723 class Plugin2 (object ):
708724 @hookimpl
709725 def myhook (self , args ):
710726 raise RuntimeError
711727
728+
712729 class Plugin3 (object ):
713730 @hookimpl
714731 def myhook (self , args ):
715732 return 3
716733
734+
717735 @hookimpl (hookwrapper = True )
718736 def myhook (self , args ):
719737 outcome = yield
@@ -724,7 +742,8 @@ point:
724742 # log the error details
725743 print (outcome.excinfo)
726744
727- pm = PluginManager(' myproject' )
745+
746+ pm = PluginManager(" myproject" )
728747
729748 # register plugins
730749 pm.register(Plugin1())
@@ -752,11 +771,9 @@ using the :py:meth:`pluggy._HookCaller.call_historic()` method:
752771 def callback (result ):
753772 print (" historic call result is {result} " .format(result = result))
754773
774+
755775 # call with history; no results returned
756- pm.hook.myhook.call_historic(
757- config = config, args = sys.argv,
758- result_callback = callback
759- )
776+ pm.hook.myhook.call_historic(config = config, args = sys.argv, result_callback = callback)
760777
761778 # ... more of our program ...
762779
@@ -813,7 +830,7 @@ undo function to disable the behaviour.
813830
814831.. code-block :: python
815832
816- pm = PluginManager(' myproject' )
833+ pm = PluginManager(" myproject" )
817834 # magic line to set a writer function
818835 pm.trace.root.setwriter(print )
819836 undo = pm.enable_tracing()
@@ -832,6 +849,7 @@ The expected signature and default implementations for these functions is:
832849 def before (hook_name , methods , kwargs ):
833850 pass
834851
852+
835853 def after (outcome , hook_name , methods , kwargs ):
836854 pass
837855
0 commit comments