GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-82129: Improve annotations for make_dataclass() by JelleZijlstra · Pull Request #133406 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented May 4, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Closes #82129. Closes #122262.

This is on top of @sobolevn's #122262 but jumps through a few more hoops to achieve these goals:

  • The annotations on dataclasses with make_dataclass() are sensible in all formats
  • We don't import typing until we really have to
  • Issue: get_type_hints fails if there are un-annotated fields in a dataclass #82129

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sobolevn and others added 14 commits July 25, 2024 10:17
@sobolevn
pythongh-82128: Provide __annotate__ method for dataclasses from `m…
c2d85b7
…ake_dataclass`
@sobolevn
Merge branch 'main' into issue-82129-2
de409ad
@sobolevn
Fix NameError
642f849
@sobolevn
Merge branch 'main' into issue-82129-2
69251ac
@sobolevn
Address review
5ec3a08
@sobolevn @carljm
Update Misc/NEWS.d/next/Library/2024-09-18-09-15-40.gh-issue-82129.GQ…
43caa3f
…wt3u.rst

Co-authored-by: Carl Meyer <[email protected]>
@sobolevn
Introduce _ANY_MARKER
33b279d
@sobolevn
Merge branch 'main' into issue-82129-2
d5ddb16
@sobolevn
WIP
3b26e36
@JelleZijlstra
Merge branch 'main' into issue-82129-2
2c4d618
@JelleZijlstra
alt
309da4c
@JelleZijlstra
better
3d7eb6e
@JelleZijlstra
comment
9565089
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into gh18219-alt
c013e7b
@bedevere-app bedevere-app Bot mentioned this pull request May 4, 2025
get_type_hints fails if there are un-annotated fields in a dataclass #82129
Closed
JelleZijlstra
JelleZijlstra commented May 4, 2025
View reviewed changes
Comment thread Lib/annotationlib.py
try:
ann = _get_dunder_annotations(obj)
except NameError:
except Exception:

@JelleZijlstra JelleZijlstra May 4, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I made a separate PR (with tests) for this change in #133407.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sobolevn
sobolevn reviewed May 4, 2025
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you for reviving this PR! It looks like it achieves its main goal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra
JelleZijlstra marked this pull request as ready for review May 4, 2025 22:59
@JelleZijlstra
JelleZijlstra requested a review from ericvsmith as a code owner May 4, 2025 22:59
@bedevere-app bedevere-app Bot added the awaiting core review label May 4, 2025
@JelleZijlstra
JelleZijlstra requested a review from sobolevn May 4, 2025 23:26
sobolevn
sobolevn approved these changes May 5, 2025
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 5, 2025
@JelleZijlstra
JelleZijlstra merged commit bb5ec6e into python:main May 5, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label May 5, 2025
@JelleZijlstra
JelleZijlstra deleted the gh18219-alt branch May 5, 2025 15:21
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@JelleZijlstra @sobolevn
@carljm @Pranjal095
pythongh-82129: Improve annotations for make_dataclass() (python#133406)
2e9b8e9
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Carl Meyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn approved these changes
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

get_type_hints fails if there are un-annotated fields in a dataclass

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@JelleZijlstra @sobolevn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.