← 返回首页
[3.9] bpo-41249: Fix postponed annotations for TypedDict (GH-27017) by Fidget-Spinner · Pull Request #27205 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

[3.9] bpo-41249: Fix postponed annotations for TypedDict (GH-27017)#27205

Merged
ambv merged 2 commits into
python:3.9from
Fidget-Spinner:backport-41249-3.9
Jul 17, 2021
Merged

[3.9] bpo-41249: Fix postponed annotations for TypedDict (GH-27017)#27205
ambv merged 2 commits into
python:3.9from
Fidget-Spinner:backport-41249-3.9

Conversation

Fidget-Spinner commented Jul 17, 2021
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

This fixes TypedDict to work with get_type_hints and postponed evaluation of annotations across modules.

This is done by adding the module name to ForwardRef at the time the object is created and using that to resolve the globals during the evaluation.

Co-authored-by: Ken Jin 28750310+Fidget-Spinner@users.noreply.github.com
(cherry picked from commit 889036f)

Co-authored-by: Germán Méndez Bravo german.mb@gmail.com

https://bugs.python.org/issue41249

This fixes TypedDict to work with get_type_hints and postponed evaluation of annotations across modules. This is done by adding the module name to ForwardRef at the time the object is created and using that to resolve the globals during the evaluation. Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Yeah!

Copy link
Copy Markdown
Member

Oh wait, test_typing failed!

Comment thread Lib/test/test_typing.py Outdated Show resolved Hide resolved
ambv merged commit fa674bd into python:3.9 Jul 17, 2021
Fidget-Spinner deleted the backport-41249-3.9 branch July 17, 2021 09:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Footer

© 2026 GitHub, Inc.