Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import collections.abc
import copyreg
import functools
import keyword
import operator
import sys
import types
Expand Down Expand Up @@ -998,8 +999,12 @@ def _make_forward_ref(code, *, parent_fwdref=None, **kwargs):
if parent_fwdref.__owner__ is not None:
kwargs['owner'] = parent_fwdref.__owner__
forward_ref = annotationlib.ForwardRef(code, **kwargs)
# For compatibility, eagerly compile the forwardref's code.
forward_ref.__forward_code__
# For compatibility, eagerly compile the forwardref's code so that any
# SyntaxError is raised immediately rather than when the forward
# reference is evaluated. Similar to 'ForwardRef.evaluate(), we only compile
Comment thread
Viicos marked this conversation as resolved.
Outdated
# it if necessary:
if not (code.isidentifier() and not keyword.iskeyword(code)):
forward_ref.__forward_code__
return forward_ref


Expand Down
Loading