Open carljm opened 6 years ago
A tool that does something like that is https://github.com/edreamleo/make-stub-files — it writes a stub file, but isn’t there a tool that merges stubs back into the source?
Yep, https://github.com/ambv/retype does that.
Also, this echoes IMPLICIT INTEGER in FORTRAN. :-) -- --Guido (mobile)
@carljm Imagine you do update the source code like you explained. 99 methods were updated. And the next day you create a new method. Now you have 99 methods with type annotation and 1 method without it. But now IDE support could happen: It automatically annotates your new method with the help of the name2type mapping. Wouldn't this be nice? But for this to happen, you must not remove the name2type mapping.
Thank you for your feedback. I will wait until all my code switched to Python3.
Maybe after that name2type mapping is not needed any more.
I can't see wanting to use this as a long-term way of specifying types in any codebase I work on (too implicit, types divorced from code, when reading the code it just looks un-annotated), but I can definitely imagine using it as a way to bootstrap type annotations on an existing large codebase with strong conventions, in the spirit of existing tools like MonkeyType and pyannotate. In other words, you specify a name to type mapping and run the tool over your code, and it annotates any unannotated argument of that name with the given type. Then you can discard the name-to-type mapping and proceed normally, annotating new code as it is written.