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 <brandtbucher@gmail.com> wrote:
Doesn't explicitly setting it yourself still work?

```
TYPE_CHECKING = False

if TYPE_CHECKING:
    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 -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/P5W5ETPGVXN47OW27RICUQQRJZCBVFKQ/
Code of Conduct: http://python.org/psf/codeofconduct/


--
--Guido van Rossum (python.org/~guido)
Pronouns: he/him (why is my pronoun here?)