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

Class based plugins and entrypoints #357

Open
chevignon93 opened this issue Jul 19, 2022 · 2 comments
Open

Class based plugins and entrypoints #357

chevignon93 opened this issue Jul 19, 2022 · 2 comments

Comments

@chevignon93
Copy link

chevignon93 commented Jul 19, 2022

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.

@RonnyPfannschmidt
Copy link
Member

Registration of class based plugins already is supported

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

@RonnyPfannschmidt
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants