<div dir="auto">That would be a feature in my "python dialect" future library. Taking one valid python program and producing another python program :<div dir="auto"><br></div><div dir="auto">def f(request):</div><div dir="auto">    return HttpResponse('ok')</div><div dir="auto"><br></div><div dir="auto">→</div><div dir="auto"><br></div><div dir="auto">def f(request: HttpRequest):</div><div dir="auto">   <span style="font-family:sans-serif">return HttpResponse('ok')</span></div><br><div dir="auto">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).</div></div><br><div class="gmail_quote"><div dir="ltr">Le ven. 19 oct. 2018 à 09:18, Thomas Güttler <<a href="mailto:guettliml@thomas-guettler.de">guettliml@thomas-guettler.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Imaging you are developing in the django context.<br>
<br>
Everytime you use a variable named "request" or "response" your human brains<br>
knows that this is a subclass of  django.http.HttpRequest and django.http.HttpResponse.<br>
<br>
How to give the IDE this knowledge?<br>
<br>
One solution is the do typehinting everywhere the veriable gets used.<br>
<br>
But why does the human brain not need this?<br>
<br>
Because it is intelligent?<br>
<br>
I would not call this intelligence. There is a simple<br>
dictionary in the brain of the developer, which maps:<br>
<br>
variable-name --> Type<br>
<br>
And this mapping dict exists once per library.<br>
<br>
If you are developing in the requests http lib, then<br>
there is a different mapping. Then "response" means<br>
type requests.Response.<br>
<br>
<br>
Now my idea: Per module and/or per file type hinting from variable name.<br>
<br>
Maybe a magic docstring in the __init__.py file:<br>
<br>
"""<br>
variable-name-mapping:<br>
  {<br>
    request: django.http.HttpRequest,<br>
  ...<br>
}<br>
"""<br>
<br>
This makes the type mapping available for all files in this directory (or sub-directories).<br>
<br>
What do you think?<br>
<br>
<br>
<br>
<br>
Disclaimer: For reasons I don't want to explain in detail, I am not allowed to<br>
do implement things like this. This is just an idea. I would feel proud and thankfull<br>
if someone likes it that much, that he implements it.<br>
<br>
<br>
<br>
<br>
-- <br>
Thomas Guettler <a href="http://www.thomas-guettler.de/" rel="noreferrer noreferrer" target="_blank">http://www.thomas-guettler.de/</a><br>
I am looking for feedback: <a href="https://github.com/guettli/programming-guidelines" rel="noreferrer noreferrer" target="_blank">https://github.com/guettli/programming-guidelines</a><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>