Skip to content
This repository was archived by the owner on Feb 17, 2019. It is now read-only.

create hookimpl by using the official pluggy API#12

Closed
obestwalter wants to merge 1 commit intomasterfrom
use-pluggy-api
Closed

create hookimpl by using the official pluggy API#12
obestwalter wants to merge 1 commit intomasterfrom
use-pluggy-api

Conversation

@obestwalter
Copy link
Member

No description provided.

@RonnyPfannschmidt
Copy link

wtf?

@obestwalter
Copy link
Member Author

obestwalter commented Apr 14, 2018

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.

@obestwalter
Copy link
Member Author

obestwalter commented Apr 14, 2018

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.

@RonnyPfannschmidt
Copy link

you should have as single place in your project where you declare the hookimpl markers, and those should be the canonical sources

@obestwalter
Copy link
Member Author

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?

@RonnyPfannschmidt
Copy link

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

@obestwalter
Copy link
Member Author

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.

@RonnyPfannschmidt
Copy link

im glad i was able to help you

@obestwalter obestwalter deleted the use-pluggy-api branch April 16, 2018 10:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants