[Python-Dev] Type hints -- a mediocre programmer's reaction (original) (raw)

Guido van Rossum guido at python.org
Mon Apr 20 22:31:24 CEST 2015


On Mon, Apr 20, 2015 at 1:17 PM, Robert Collins <robertc at robertcollins.net> wrote:

On 21 April 2015 at 08:10, Eric Snow <ericsnowcurrently at gmail.com> wrote: > > > > While it helps, this sort of best-practice is still unsettled (and apparently not obvious). In the short term it would make more sense to recommend using stub files for all the reason Harry enumerated. Once the best practices are nailed down through experience with stub files, then we can make recommendations regarding inline type hints. > > -eric

Forgive my ignorance, but can stub files can't annotate variables within functions? E.g. AIUI if there is a stub file, it is used in the static analysis instead of the actual source. Likely I've got it modelled wrong in my head :) -Rob

Correct, stub files are only used to type-check users of a module. If you want a module itself to be type-checked you have to use inline type hints. (Though it has been suggested to combine the hints from the stub with the implementation and use this to type-check the implementation, and some tool chains may actually implement this.)

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150420/ef9d8ba0/attachment.html>



More information about the Python-Dev mailing list