Python is DOOMED! Again!

Chris Angelico rosuav at gmail.com
Tue Jan 27 16:08:43 EST 2015


On Wed, Jan 28, 2015 at 7:58 AM, Mario Figueiredo <marfig at gmail.com> wrote:
> Looking at PEP 3107, i'm left wondering: what if I have for instance
> already annotated my functions for parameter marshalling, following the
> syntax expected of that specific library, and now I want to annotate
> them for type hinting for the purposes of static analysis?

This is the kind of argument that keeps on coming up. Everyone has a
"What if" scenario about function annotations... and almost nobody
actually has a codebase that uses them. It's equivalent to asking:
"What if I already used docstrings to control URL routing, and now I
want to use them for function documentation?". Well, simple. You move
your other-use-of-annotations out to something else (probably a
decorator) before you add type hints. Until that time, you're welcome
to continue using annotations for something other than type hinting;
you just can't do both at once on the same function.

ChrisA



More information about the Python-list mailing list