create hookimpl by using the official pluggy API#12
create hookimpl by using the official pluggy API#12obestwalter wants to merge 1 commit intomasterfrom
Conversation
|
wtf? |
|
I started looking into that whole hook pluggy thing today and this is how I understand it. Importing this directly is not necessary and instead you can fetch the marker through the API. If I got something wrong, it would be nice if you explained it to me. |
|
I looked at examples from pytest now and there the hookimpl is imported directly from pytest, so I guess you are referring to that? To me it makes perfect sense to not do that and instead use the pluggy API as the source where I get my hookimpl marker as plugin writer. Then I don't even have to wonder, where it is defined and how it is called. in tox are two places where hookimpl is created and it is imported from two different places by different plugins, so it already started to be a mess. I would like to tidy that up before it gets worse. The cleanest way IMO is if the plugin writer does not even have to care, from where the hookimpl should be imported, as it does not need to be imported at all. |
|
you should have as single place in your project where you declare the hookimpl markers, and those should be the canonical sources |
I agree with that, which is in part the reason why I started fixing this as tox already had two hookimpl objects. Some imported from tox directly and some from tox.config - which led me to the thought that importing anything from the project I write a plugin for should not be necessary for a simple plugin using a plugin system. Otherwise I can just go ahead and start monkeypatching, subclassing and overwrtiting stuff again :) But this is not an answer to my question. Is it wrong to use the pluggy API, to create the hookimpl marker rather than importing it? |
|
a plugin for your project should know about your project, it should have to know about pluggy and details of making objects of pluggy that fit your project as well - you provide them correctly configured, end of discussion |
|
Closing this. Looks like the recommended/better/right way is importing the object from the host project: pytest-dev/pluggy#130 Thanks @RonnyPfannschmidt for making me start to ask the right questions. |
|
im glad i was able to help you |
No description provided.