[Python-Dev] Remove typing from the stdlib

Antoine Pitrou antoine at python.org
Fri Nov 3 14:08:16 EDT 2017


Also, as for dataclasses specifically, since it may become as pervasive
as namedtuples, we probably want it to be as light-weight as possible.
Which will be harder to achieve if its *API* depends on the typing
machinery.

Regards

Antoine.


Le 03/11/2017 à 19:04, Paul Moore a écrit :
> 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