[Python-ideas] TypeHinting: From variable name to type. Yes: no change to language, just convetion

Thomas Güttler guettliml at thomas-guettler.de
Mon Oct 22 04:53:27 EDT 2018

Am 21.10.18 um 16:44 schrieb David Mertz:
> On Fri, Oct 19, 2018 at 3:18 AM Thomas Güttler <guettliml at thomas-guettler.de <mailto:guettliml at thomas-guettler.de>> wrote:
>     Now my idea: Per module and/or per file type hinting from variable name.
>     Maybe a magic docstring in the __init__.py file:
>     variable-name-mapping:
>        {
>          request: django.http.HttpRequest,
>     }
> In general, I like this idea; but really only on a per-file basis.  A short header at the top would be easy enough for 
> an IDE or linter to scan.  But imposing the conventions project-wide feels too broad.
> There might, of course, be cases where the same name is used for different purposes in the same file.  But the tool can 
> alert the developer of that... and in that one file, she could either remove the header of refactor the names used, as 
> made sense for that particular code.
> This is certainly not something that requires language support.  It can easily be purely a convention, as long as 
> different IDEs, linters, type checkers, etc. agree on what the convention is.  Maybe at some point in the future, if the 
> convention becomes adopted, there might be some help in having a standard library module, or even minimal language 
> recognition, of the convention.  But let's work on adopting a convention first.

Yes, this sounds good. There is no need to change the python language, it is should be a convetion.

   Thomas Güttler

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