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

Thomas Güttler guettliml at thomas-guettler.de
Fri Oct 19 05:30:53 EDT 2018

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')
> 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).

I think creating source code from source code is most of the time not the best solution.
Except you call the result not "source code" but "binary executable code". [1]

I think it would be great if this could work for local variables (which are not in the arg/kwargs of the method), too:


def foo():
     response = get_response_from_paradise()

If `get_response_from_paradise()` has not spec for the return type, then it would be great to guess
the return type from the general "wisdom".


[1]: https://github.com/guettli/programming-guidelines/blob/master/README.rst#source-code-generation-is-a-stupid-idea

Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines

More information about the Python-ideas mailing list