[Python-Dev] Remove typing from the stdlib (original) (raw)

Paul Moore p.f.moore at gmail.com
Fri Nov 3 14:04:34 EDT 2017


On 3 November 2017 at 17:47, Antoine Pitrou <solipsis at pitrou.net> wrote:

On Fri, 3 Nov 2017 12:46:33 -0400 "Eric V. Smith" <eric at trueblade.com> wrote:

On 11/3/2017 12:15 PM, Victor Stinner wrote: > Hi, > > 2017-11-03 15:36 GMT+01:00 Guido van Rossum <guido at python.org>: >> Maybe we should remove typing from the stdlib? >> https://github.com/python/typing/issues/495

> The typing module is not used yet in the stdlib, so there is no > technically reason to keep typing part of the stdlib. IMHO it's > perfectly fine to keep typing and annotations out of the stdlib, since > the venv & pip tooling is now rock solid ;-) I'm planning on using it for PEP 557: https://www.python.org/dev/peps/pep-0557/#class-variables The way the code currently checks for this should still work if typing is not in the stdlib, although of course it's assuming that the name "typing" really is the "official" typing library. I don't think other modules should start relying on the typing module at runtime. The dataclasses module can define its own "ClassVar" thing and then I suspect it's easy to map it to typing.ClassVar. It seems we should be careful not to blur the distinction between declarations that have an effect on actual code, and typing declarations which only affect type-checking tools.

I'm looking forward to the dataclasses module, and I'm perfectly OK with the way that it uses type annotations to declare attributes. I also don't have a problem with it relying on the typing module - but only if the typing module is in the stdlib. I don't think it's good if a standard feature needs an external library for some of its functionality.

So I guess the point is, if we're considering moving typing out of the stdlib, then what's the impact on PEP 557?

Personally, I don't use type annotations myself yet, but I've used code that does and I'm considering looking into them - for a variety of reasons, documentation, IDE support, and the ability to type check my code via mypy. If typing moves out of the stdlib, I'd be much less inclined to do so - adding a runtime dependency is a non-trivial cost in terms of admin for deployment, handling within my (peculiar, if you want to debate workflow) development workflow, etc. Working out how to add type annotations without them being a runtime dependency (just at test-time) is too much work. So I am concerned that if we move typing out of the stdlib, it'll reduce adoption rates.

Paul



More information about the Python-Dev mailing list