pytest-dev/pluggy

Class based plugins and entrypoints

chevignon93 opened this issue · 2 comments

This is not a bug report but more of a general question about pluggy.

I know there was talks a few years ago of changing the way entry_points are loaded but it hasn't been implemented.

As the developer of the host application, I can easily create a class that contains hook implementations (what the example from the documentation calls "A hook implementation namespace") and register it with the PluginManager but unless I'm missing something obvious, plugin authors can only define their hook implementations as functions (at least this is what all the examples I've seen seem to suggest).

So my question is, is there any plans of allowing/facilitating "Class based plugins" to be loaded via entry_points?

I "hacked" pluggy (just added a couple lines of code) to be able to do it for my program but maybe a solution from the developers could also be useful to others.

Registration of class based plugins already is supported

Autoloading is not, as its unclear if/what to pass to ctors

closing as not planned for direct support as its unclear what to pass as argument

the pattern spearheaded in pytest is to have a module level hook register individual class instances with correct parameters passed over