FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) by miss-islington · Pull Request #158946 · python/cpython · GitHub

Repository navigation

[3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) - #158946

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-0f1d4a7-3.15
Open

miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-0f1d4a7-3.15

Conversation

miss-islington commented Oct 7, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

With string annotations, dataclasses looks up the first name of each
annotation to detect ClassVar, InitVar and KW_ONLY. If that name was a
lazy import that could not be resolved, the lookup raised and the class
could not be created, while the same class works with non-string
annotations.

This resolves lazy imports the way annotationlib does: try to resolve
them, and treat a failure like a missing name.
(cherry picked from commit 0f1d4a7)

Co-authored-by: Brittany Reynoso breynoso@meta.com

…tations (pythonGH-158939)

With string annotations, dataclasses looks up the first name of each
annotation to detect ClassVar, InitVar and KW_ONLY. If that name was a
lazy import that could not be resolved, the lookup raised and the class
could not be created, while the same class works with non-string
annotations.

This resolves lazy imports the way annotationlib does: try to resolve
them, and treat a failure like a missing name.
(cherry picked from commit 0f1d4a7)

Co-authored-by: Brittany Reynoso <breynoso@meta.com>

JelleZijlstra 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

@brittanyrey I'm thinking this can wait for 3.15.1, what do you think?

Copy link
Copy Markdown
Contributor

@JelleZijlstra that's my gut feeling.

@pablogsal what do you think?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL