PEP 781: Make ``TYPE_CHECKING`` a built-in constant

Heya, my first time commenting on a proposal.

I just have to ask, because I haven’t seen it in the “Rejected Ideas” section of the PEP. Nor have I seen it mentioned whilst quickly scrolling through the current discussion.

There’s been various suggestions to add typing-only imports to Python (mainly through the new type keyword with import statements, à la TypeScript).

Here’s a single comment that links to multiple relevant topics: "import type" statement to replace typing.TYPE_CHECKING idiom and fix circular references - #2 by bschubert

Has such a proposal as an alternative been considered? Even if the reason for “rejecting the alternative” is simply that the proposal from PEP 781 is simpler and easier to get in earlier, whilst the specifics for a lazy or type-only import syntax get hashed out, if ever. I think it’s worth at least acknowledging. (and they can both exist together in the future, even in the hypothetical that TYPE_CHECKING/__type_checking__ becomes obsolete).

In any case, thanks for this proposal, whatever form the constant takes in the end.

1 Like