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

Ship a pytest plugin? #97

Open
blueyed opened this issue Jan 14, 2020 · 5 comments · May be fixed by #107
Open

Ship a pytest plugin? #97

blueyed opened this issue Jan 14, 2020 · 5 comments · May be fixed by #107

Comments

@blueyed
Copy link
Contributor

blueyed commented Jan 14, 2020

There's an example conftest (#11), but it would be possible to ship a pytest entrypoint plugin (via e.g. a pytest_pyannotate module), that could be used via pytest --pyannotate then automatically.

I'd be happy to add it, but wanted to ask for feedback first.

Just for reference: Instagram/MonkeyType#25

@JukkaL
Copy link

JukkaL commented Jan 14, 2020

I'm not familiar with pytest entrypoint plugins. Can you explain what this would mean in a bit more detail?

@blueyed
Copy link
Contributor Author

blueyed commented Jan 14, 2020

diff --git i/setup.py w/setup.py
index 7cc0d2f..554486f 100644
--- i/setup.py
+++ w/setup.py
@@ -20,7 +20,15 @@ def get_long_description():
       platforms=['POSIX'],
       packages=['pyannotate_runtime', 'pyannotate_tools',
                 'pyannotate_tools.annotations', 'pyannotate_tools.fixes'],
-      entry_points={'console_scripts': ['pyannotate=pyannotate_tools.annotations.__main__:m>
+      modules=['pytest_pyannotate'],
+      entry_points={
+          "console_scripts": [
+              "pyannotate=pyannotate_tools.annotations.__main__:main",
+          ],
+          "pytest11": [
+              "pytest-pyannotate = pytest_pyannotate",
+          ],
+      },
       classifiers=[
           'Development Status :: 3 - Alpha',
           'Environment :: Console',

And then have the plugin in pytest_pyannotate.py, which would be similar to example/example_conftest.py (could be moved there).

The main benefit of course it that it easily allows to use pyannotate with pytest-based projects (although having the example conftest is very good already - this would just make the integration more seemingly etc)

@gvanrossum
Copy link
Contributor

If you're willing to contribute the code that sounds like a good idea to me.

(Though I am no longer a Dropbox employee and I don't know if I can still merge PRs. I can definitely still review code though. :-)

@tuukkamustonen
Copy link

There's https://github.com/kensho-technologies/pytest-annotate at least.

@terencehonles
Copy link

I guess I didn't see this, but I basically did this with #107 I didn't add it as an entry point since I doubt you actually want to run it any time it's installed to the system and instead you'll probably want to opt in via pytest's plugin config/argument https://docs.pytest.org/en/latest/plugins.html#installing-and-using-plugins.

I updated the documentation to match.

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

Successfully merging a pull request may close this issue.

5 participants