[Python-ideas] Proposal: Use mypy syntax for function annotations
Stephen J. Turnbull
stephen at xemacs.org
Thu Aug 21 03:42:45 CEST 2014
Terry Reedy writes:
> If the annotation for a library are in a separate skeleton file
You mean stub file, right? (Stub is the term used so far in this
thread.)
To develop Terry's idea a bit more explicitly, ISTM that during early
development, you use Python 3 with annotations in file. Then when you
need to test Python 2, you use a tool (as yet to be developed) which
generates a Python file that has had all annotations stripped, and a
stub file[1]. Throw away the stub file, test the Python file, and
return to development.
For distribution (to *both* Python 3 and Python 2 users) you ignore
the original annotated code and distribute the generated Python file
and the stubs file. Probably there would be a tool for combining the
Python and stub files back into an annotated Python file.
The two tools (stripper and annotator) can be very accurate (although
the annotator may not produce precisely the style desired by users,
the tools probably can be designed so that the re-annotated file
accurately reflects the style used by the authors).
Is the implied workflow really so burdensome? Especially to
downstream?
Note that Terry works on IDLE, so it seems likely that at least one
Python IDE would support this workflow very well. :-)
Footnotes:
[1] Yes, I know, the stub file is actually Python, too. You know
what I mean.
More information about the Python-ideas
mailing list