That's a mypy-specific hack, not something that's guaranteed by a PEP -- but it works great with mypy!

On Mon, Jan 18, 2021 at 4:40 PM Brandt Bucher <> wrote:
Doesn't explicitly setting it yourself still work?


    import xxx  # modules used only in type hints.

This seems to work for mypy, at least. Even just doing `if False:` works correctly (and is arguably the most efficient at runtime).
Python-ideas mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct:

--Guido van Rossum (
Pronouns: he/him (why is my pronoun here?)