Skip to content

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commented Dec 3, 2025

@DavidCEllis
Copy link
Contributor

I am kicking myself on the __annotate__ access. Honestly surprised it didn't trip any existing tests.

It looks like the sqlalchemy field issue is from replacing and subsequently attempting to restore annotations in order to add fields to a dataclass as there's no mechanism for doing so without annotations. The check to fix this is fine, I'm actually surprised I hadn't written this as a comprehension.

Again, sorry for missing these possibilities.

Copy link

@basnijholtbasnijholt left a comment

Choose a reason for hiding this comment

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

I just locally applied the changes in Lib/dataclasses.py and it fixed all the failing tests on github.com/pipefunc/pipefunc.

Copy link
Member

@ericvsmithericvsmith left a comment

Choose a reason for hiding this comment

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

A small nit, but otherwise looks good to me.

# gh-142214: The annotation may be missing in unusual dynamic cases.
# If so, just skip it.
if k in cls_annotations:
new_annotations[k] = cls_annotations[k]
Copy link
Member

Choose a reason for hiding this comment

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

Don't in and [] both do a lookup? Maybe it would be better as:

ifann:=cls_annotations.get(k): new_annotations[k] =ann

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that None is a valid annotation here so this would miss None values?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Correct. To save a lookup we could do a try-except KeyError instead. I don't have a preference but I can switch to that if you like.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think try/except makes sense as in most cases the key should be there. The key not being there should only be in cases where something has modified annotations and removed things after the class has been processed.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Done

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@JelleZijlstra
Copy link
MemberAuthor

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

@ericvsmith: please review the changes made to this pull request.

Copy link
Member

@ericvsmithericvsmith left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks!

@JelleZijlstraJelleZijlstra merged commit 53ec7c8 into python:mainDec 5, 2025
51 of 54 checks passed
@miss-islington-app
Copy link

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 5, 2025
@bedevere-app
Copy link

GH-142277 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14 bugs and security fixes label Dec 5, 2025
@JelleZijlstraJelleZijlstra deleted the fixdatacl branch December 5, 2025 04:06
JelleZijlstra added a commit that referenced this pull request Dec 5, 2025
…2277) gh-142214: Fix two regressions in dataclasses (GH-142223) (cherry picked from commit 53ec7c8) Co-authored-by: Jelle Zijlstra <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for freeto 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

@JelleZijlstra@DavidCEllis@ericvsmith@sobolevn@basnijholt@AlexWaygood