[Python-Dev] Type hints -- a mediocre programmer's reaction (original) (raw)
Robert Collins robertc at robertcollins.net
Mon Apr 20 22:15:13 CEST 2015
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 21 April 2015 at 08:07, Guido van Rossum <guido at python.org> wrote:
The situation is possibly even bleaker (or happier, depending on your position :-) for inline type hints in 3rd party packages -- few package authors will be satisfied with supporting only Python 3.5 and later. True, you can support Python 3.2 and up by declaring the 3rd party typing package as a dependency (unless Python 3.5+ is detected), but I don't expect this to become a popular approach overnight.
mypy has a codec for 2.x which strips type annotations - https://github.com/JukkaL/mypy/tree/master/mypy/codec - while you can't run mypy under 2.x, you can run it under 3.x to perform the analysis, and ones code still runs under 2.x.
Another route - the one I've been experimenting with as I get familiar with mypy - is to just use type comments exclusively. Function type comments currently break, but that seems like a fairly shallow bug to me, rather than something that shouldn't work. The advantage of that route is that editors which make comments appear in subtle colours, makes the type hints be unobtrusive without specific syntax colouring support.
-Rob
-- Robert Collins <rbtcollins at hp.com> Distinguished Technologist HP Converged Cloud
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]