[New-bugs-announce] [issue29974] typing.TYPE_CHECKING doc example is incorrect

Mathias Rav report at bugs.python.org
Mon Apr 3 13:32:43 EDT 2017


New submission from Mathias Rav:

The documentation of typing.TYPE_CHECKING has an example (introduced in issue #26141) that would lead to NameError at runtime. The example shows how to limit the import of "expensive_mod" to type checkers, but then goes on to use "expensive_mod.some_type" in a type annotation that is evaluated at runtime ("local_var: expensive_mod.some_type"). The use case of TYPE_CHECKING is probably meant for type annotations placed in comments, e.g. "local_var  # type: expensive_mod.some_type".

----------
assignee: docs at python
components: Documentation
messages: 291085
nosy: docs at python, rav
priority: normal
severity: normal
status: open
title: typing.TYPE_CHECKING doc example is incorrect
type: enhancement
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29974>
_______________________________________


More information about the New-bugs-announce mailing list