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

Alternative approach via stubfiles #23

Open
Stewori opened this issue Nov 20, 2017 · 1 comment
Open

Alternative approach via stubfiles #23

Stewori opened this issue Nov 20, 2017 · 1 comment

Comments

@Stewori
Copy link

Stewori commented Nov 20, 2017

This is not an issue. I just wanted to crosslink an approach with the same goal that might be of help for some use cases (and eventually save us all from doing work twice).

TypeLogger from pytypes can observe types at runtime and then write a PEP-484 stubfile from that information.
All versions of typing are supported and it runs on Python 2.7, 3.3, 3.4, 3.5, 3.6, PyPy and Jython.
See https://github.com/Stewori/pytypes#usage-example-with-profiler.

The approach differs from pyannotate in that it does not write into existing code, but always creates an external PEP-484 conform stubfile that should be suitable for use with mypy (pytypes itself can use it for runtime typechecking).

A nice goodie is that it can take existing type annotations into account and extend them by information acquired from runtime observations.
The tool supports OOP -- classes, inner classes, static methods, class methods and properties -- and automatically writes a proper import section for the types in use.

Disclaimer: It is not perfect yet and still in beta. Please file issues as they come up. Help is welcome!

@gvanrossum
Copy link
Contributor

Thanks for the link! We should combine the best of our tools.

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