Skip to content

Commit

Permalink
Updated notes on forward references regarding instrumented code
Browse files Browse the repository at this point in the history
Forward references still need to be resolved in some cases.
  • Loading branch information
agronholm committed Apr 10, 2023
1 parent 08d2f64 commit 9ee9175
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ Notes on forward reference handling
The internal type checking functions, injected to instrumented code by either
:func:`@typechecked <typechecked>` or the import hook, use the "naked" versions of any
annotations, undoing any quotations in them (and the effects of
``from __future__ import annotations``). As such, the
:attr:`~.TypeCheckConfiguration.forward_ref_policy` does not apply to instrumented code.
``from __future__ import annotations``). As such, in instrumented code, the
:attr:`~.TypeCheckConfiguration.forward_ref_policy` only applies when using type
variables containing forward references, or type aliases likewise containing forward
references.

To facilitate the use of types only available to static type checkers, Typeguard
recognizes module-level imports guarded by ``if typing.TYPE_CHECKING:`` or
Expand Down
4 changes: 0 additions & 4 deletions src/typeguard/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ class TypeCheckConfiguration:
Specifies what to do when a forward reference fails to resolve.
Note that this setting only applies to :func:`.check_type`, as instrumented
code eagerly resolves forward references during compilation. See the
:ref:`forwardrefs` section in the documentation for further information.
Default: ``WARN``
.. attribute:: collection_check_strategy
Expand Down

0 comments on commit 9ee9175

Please sign in to comment.