[Python-ideas] TypeHinting: From variable name to type
Robert Vanden Eynde
robertve92 at gmail.com
Fri Oct 19 04:22:08 EDT 2018
That would be a feature in my "python dialect" future library. Taking one
valid python program and producing another python program :
def f(request: HttpRequest):
The dialect options would include "all top functions in this module" for
example, and parameters about the naming convention (explicit list of
conversion or rules to create the mapping).
Le ven. 19 oct. 2018 à 09:18, Thomas Güttler <guettliml at thomas-guettler.de>
a écrit :
> Imaging you are developing in the django context.
> Everytime you use a variable named "request" or "response" your human
> knows that this is a subclass of django.http.HttpRequest and
> How to give the IDE this knowledge?
> One solution is the do typehinting everywhere the veriable gets used.
> But why does the human brain not need this?
> Because it is intelligent?
> I would not call this intelligence. There is a simple
> dictionary in the brain of the developer, which maps:
> variable-name --> Type
> And this mapping dict exists once per library.
> If you are developing in the requests http lib, then
> there is a different mapping. Then "response" means
> type requests.Response.
> Now my idea: Per module and/or per file type hinting from variable name.
> Maybe a magic docstring in the __init__.py file:
> request: django.http.HttpRequest,
> This makes the type mapping available for all files in this directory (or
> What do you think?
> Disclaimer: For reasons I don't want to explain in detail, I am not
> allowed to
> do implement things like this. This is just an idea. I would feel proud
> and thankfull
> if someone likes it that much, that he implements it.
> Thomas Guettler http://www.thomas-guettler.de/
> I am looking for feedback:
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas