[Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Thomas Güttler
Imaging you are developing in the django context. Everytime you use a variable named "request" or "response" your human brains knows that this is a subclass of django.http.HttpRequest and django.http.HttpResponse. How to give the IDE this knowledge? One solution is the do typehinting everywhe

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Anders Hovmöller
> On 19 Oct 2018, at 09:18, Thomas Güttler wrote: > > Imaging you are developing in the django context. > > Everytime you use a variable named "request" or "response" your human brains > knows that this is a subclass of django.http.HttpRequest and > django.http.HttpResponse. > > How to give

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Robert Vanden Eynde
That would be a feature in my "python dialect" future library. Taking one valid python program and producing another python program : def f(request): return HttpResponse('ok') → def f(request: HttpRequest): return HttpResponse('ok') The dialect options would include "all top functions in

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Thomas Güttler
Am 19.10.18 um 10:22 schrieb Robert Vanden Eynde: That would be a feature in my "python dialect" future library. Taking one valid python program and producing another python program : def f(request):     return HttpResponse('ok') → def f(request: HttpRequest): return HttpResponse('ok') Th

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Ivan Levkivskyi
On Fri, 19 Oct 2018 at 08:19, Thomas Güttler wrote: > [...] > This makes the type mapping available for all files in this directory (or > sub-directories). > What do you think? > I don't think this should be a language feature. _Maybe_ it can be some kind of an agreed format between IDEs. But in

Re: [Python-ideas] Python-ideas Digest, Vol 143, Issue 73

2018-10-19 Thread Bartłomiej Bartnicki
e 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: > > > > """ > &g

Re: [Python-ideas] TypeHinting: From variable name to type (IDE Support only)

2018-10-19 Thread Thomas Güttler
Am 19.10.18 um 11:42 schrieb Ivan Levkivskyi: On Fri, 19 Oct 2018 at 08:19, Thomas Güttler mailto:[email protected]>> wrote: [...] This makes the type mapping available for all files in this directory (or sub-directories). What do you think? I don't think this should

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Steven D'Aprano
On Fri, Oct 19, 2018 at 09:18:02AM +0200, Thomas Güttler wrote: > Imaging you are developing in the django context. > > Everytime you use a variable named "request" or "response" your human brains > knows that this is a subclass of django.http.HttpRequest and > django.http.HttpResponse. Not *my

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Anders Hovmöller
> On 19 Oct 2018, at 12:15, Steven D'Aprano wrote: > > On Fri, Oct 19, 2018 at 09:18:02AM +0200, Thomas Güttler wrote: > >> Imaging you are developing in the django context. >> >> Everytime you use a variable named "request" or "response" your human brains >> knows that this is a subclass of

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Elazar
Related: https://github.com/python/mypy/issues/2103 - Elazar On Fri, Oct 19, 2018 at 2:15 PM Anders Hovmöller wrote: > > > > On 19 Oct 2018, at 12:15, Steven D'Aprano wrote: > > > > On Fri, Oct 19, 2018 at 09:18:02AM +0200, Thomas Güttler wrote: > > > >> Imaging you are developing in the djang