Type annotations in the stdlib

In general, having a third-party substitute (typeshed) for a first-party feature (typing) of first-party modules (the standard library) doesn’t feel cohesive and adds to a sense of jankiness.

Not confusing readers is certainly something to strive for, but considering that those readers are now likely to be more developers, I don’t think it takes high priority.

I think type-annotating the standard library is something to which will bring further benefits (such as better documentation for std-lib developers and readers), and is therefore worthwhile.

I think it makes sense to have that as a repeat blocker: if any module attributes are annotated, then all must be. I don’t think it should be a blocker on starting to annotate.

I don’t think it makes sense to keep the stubs in typeshed. We can just *-import after the Python release:

import sys as _sys
import typing as _typing

if _sys.version_info < (3, 12):
     ...  # original stubs
else:
    if _typing.TYPE_CHECKING:
        from mod import *
3 Likes