On Mon, Apr 20, 2015 at 1:15 PM, Robert Collins <robe...@robertcollins.net> wrote:
> On 21 April 2015 at 08:07, Guido van Rossum <gu...@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. > I know, it was my idea. :-) But I think stubs are usually better of you want to support PY2. The experience when the codec is not installed is really poor. > 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. > There are definitely some tooling issues around annotations (e.g. I've had to file at least one bug with "pep8"), but in cases like this the language must lead, and tooling will follow. The idea of using comments exclusively is interesting, although I think there are also some real downsides. (As an example: Jython is thinking of making some use of type hints for code generation, and they strongly prefer to have the hints in the AST, whereas comments don't show up in the AST at all.) -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com