Skip to content

gh-144361: Fix NameError when type parameter default refers to a forward name#152208

Open
tangyuan0821 wants to merge 1 commit into
python:mainfrom
tangyuan0821:144361
Open

gh-144361: Fix NameError when type parameter default refers to a forward name#152208
tangyuan0821 wants to merge 1 commit into
python:mainfrom
tangyuan0821:144361

Conversation

@tangyuan0821

@tangyuan0821 tangyuan0821 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Fix #144361: PEP 696 + PEP 749 — delayed evaluation of type parameter defaults.

Three call sites in Lib/typing.py eagerly evaluate default (Format.VALUE),
which fails when the default references a name defined later in the module.
Catch NameError and fall back to annotationlib.call_evaluate_function
with Format.FORWARDREF.

@tangyuan0821 tangyuan0821 changed the title gh-144361: Fix NameError when type parameter default refers to a forw… gh-144361: Fix NameError when type parameter default refers to a forward name Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PEP696 + PEP749: Defer evaluation of defaults when parametrizing

1 participant