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-90562: Mention slots pitfall in dataclass docs by thejcannon · Pull Request #107391 · python/cpython

Conversation

@thejcannon

@thejcannon thejcannon commented Jul 28, 2023 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Doesn't fix the issue, but does call it out so developers know that the issue doesn't lie with them (per-se) and gives them more info on where to go.

Will need to be backported to 3.10 and 3.11.

  • Issue: RFE: @dataclasses.dataclass(slots=True) doesn't support methods using zero-arg super() #90562

📚 Documentation preview 📚: https://cpython-previews--107391.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@thejcannon
Mention slots pitfall in dataclass docs
e40f5f9
@thejcannon
thejcannon requested a review from ericvsmith as a code owner July 28, 2023 15:43
@bedevere-bot bedevere-bot mentioned this pull request Jul 28, 2023
RFE: @dataclasses.dataclass(slots=True) doesn't support methods using zero-arg super() #90562
Closed
@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Jul 28, 2023
@ericvsmith

ericvsmith commented Jul 28, 2023

Copy link
Copy Markdown
Member

I can't say I've seen something like this documented before. I'd like to get some more opinions on it.

thejcannon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@thejcannon

thejcannon commented Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Yeah. If the exception was more clear, maybe it wouldn't be warranted. But it took me longer than I want to admit to put two-and-two together. And then, because I'm super nosy I was able to find the linked issue.

So I feel for the little guy who has to piece it all together. (Speaking of, I should edit to suggest the workaround, the "old-style" super call)

All reactions

Sorry, something went wrong.

Uh oh!

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

thejcannon added 3 commits July 28, 2023 10:53
@thejcannon
Update dataclasses.rst
e9930d7
@thejcannon
Update dataclasses.rst
91bbbd2
@thejcannon
Double trouble
08903c5
@AA-Turner AA-Turner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jul 28, 2023
AA-Turner
AA-Turner reviewed Jul 28, 2023
View reviewed changes
Comment thread Doc/library/dataclasses.rst Outdated
is raised. Calling no-arg ``super()`` in dataclasses using ``slots=True`` will result in
the following Exception being raised:
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
The two-arg ``super()`` is a valid workaround. See :issue:`46404` for full details.

@AA-Turner AA-Turner Jul 28, 2023

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.

We should try to capture everything relevant in the documentation -- what is relevant to the reader from the linked issue that isn't captured in your summary?

A

Sorry, something went wrong.

Uh oh!

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

All reactions

@thejcannon thejcannon Jul 28, 2023

Copy link
Copy Markdown
Contributor 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 think these two points are it. What to look for and how to workaround.

Sorry, something went wrong.

Uh oh!

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

AA-Turner and carljm reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@carljm

carljm commented Jul 28, 2023

Copy link
Copy Markdown
Member

I feel like early in my CPython contribution I remember someone saying "we don't document bugs, we fix them."

But I'm also sympathetic to the point of view that this is a significant limitation that people are likely to hit and with an extremely confusing symptom, and there's no clear fix for it on the horizon, and it would be kinder to our users to surface it in the docs.

So while it bugs me slightly, on the whole I think I'm in favor of this. I'll leave the final say to our documentation experts (and @ericvsmith as dataclasses expert.)

AA-Turner, thejcannon, JelleZijlstra, and LiteApplication reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

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

wookie184
wookie184 approved these changes Aug 7, 2023
View reviewed changes

@wookie184 wookie184 left a comment

Copy link
Copy Markdown
Contributor

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.

This seems sensible to me. It took me a while to find out what was going on when I encountered this issue.

Sorry, something went wrong.

Uh oh!

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

thejcannon reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Comment thread Doc/library/dataclasses.rst Resolved

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Aug 7, 2023
thejcannon and others added 2 commits August 7, 2023 12:02
@thejcannon @AA-Turner
Update Doc/library/dataclasses.rst
fdff6b5
Co-authored-by: Adam Turner <[email protected]>
@erlend-aasland
Merge branch 'main' into patch-1
dde52b3
JelleZijlstra
JelleZijlstra reviewed Mar 12, 2024
View reviewed changes
Comment thread Doc/library/dataclasses.rst Resolved

Uh oh!

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

@thejcannon @JelleZijlstra
Update Doc/library/dataclasses.rst
173d4b1
Co-authored-by: Jelle Zijlstra <[email protected]>
ericvsmith
ericvsmith approved these changes Mar 13, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 13, 2024
@hugovk hugovk removed the needs backport to 3.11 only security fixes label Apr 11, 2024
@hugovk

hugovk commented Apr 11, 2024

Copy link
Copy Markdown
Member

(This now has a merge conflict.)

thejcannon reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 only security fixes label May 9, 2024
@thejcannon
Merge branch 'main' into patch-1
e6b3669
hugovk
hugovk reviewed May 21, 2024
View reviewed changes
Comment thread Doc/library/dataclasses.rst Resolved

Uh oh!

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

@hugovk
Update Doc/library/dataclasses.rst
42606c3
@hugovk
hugovk enabled auto-merge (squash) May 21, 2024 12:06
@hugovk
Merge branch 'main' into patch-1
c4cb9ac
@hugovk
hugovk merged commit e3ed574 into python:main May 21, 2024
@miss-islington-app

miss-islington-app Bot commented May 21, 2024

Copy link
Copy Markdown

Thanks @thejcannon for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label May 21, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2024
@thejcannon @AA-Turner
@JelleZijlstra @erlend-aasland @hugovk @miss-islington
pythongh-90562: Mention slots pitfall in dataclass docs (pythonGH-107391
2580775
)

(cherry picked from commit e3ed574)

Co-authored-by: Josh Cannon <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2024
@thejcannon @AA-Turner
@JelleZijlstra @erlend-aasland @hugovk @miss-islington
pythongh-90562: Mention slots pitfall in dataclass docs (pythonGH-107391
823328c
)

(cherry picked from commit e3ed574)

Co-authored-by: Josh Cannon <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
@bedevere-app

bedevere-app Bot commented May 21, 2024

Copy link
Copy Markdown

GH-119350 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 21, 2024
@bedevere-app

bedevere-app Bot commented May 21, 2024

Copy link
Copy Markdown

GH-119351 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 21, 2024
@thejcannon
thejcannon deleted the patch-1 branch May 21, 2024 19:43
@thejcannon

thejcannon commented May 21, 2024

Copy link
Copy Markdown
Contributor Author

Huzzah! 🎉

wookie184 and hugovk reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

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

hugovk added a commit that referenced this pull request May 23, 2024
@miss-islington @thejcannon
@AA-Turner @JelleZijlstra @erlend-aasland @hugovk
[3.13] gh-90562: Mention slots pitfall in dataclass docs (GH-107391) (#…
89e2689
…119350)

Co-authored-by: Josh Cannon <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
hugovk added a commit that referenced this pull request May 23, 2024
@miss-islington @thejcannon
@AA-Turner @JelleZijlstra @erlend-aasland @hugovk
[3.12] gh-90562: Mention slots pitfall in dataclass docs (GH-107391) (#…
ddaed62
…119351)

Co-authored-by: Josh Cannon <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
@e-gebes

e-gebes commented Jun 19, 2024

Copy link
Copy Markdown

Could you backport this also to the 3.10 docs? I ran into the issue, and since I need to use 3.10 atm I read the 3.10 docs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@hugovk

hugovk commented Jun 19, 2024

Copy link
Copy Markdown
Member

Sorry, 3.10 and 3.11 are only allowed to have security fixes: https://devguide.python.org/versions/

All reactions

Sorry, something went wrong.

Uh oh!

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

@e-gebes e-gebes mentioned this pull request Jun 20, 2024
Security branches: Consider fixing the documentation or adding a notice banner #120795
Closed
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@thejcannon @AA-Turner
@JelleZijlstra @erlend-aasland @hugovk @estyxx
pythongh-90562: Mention slots pitfall in dataclass docs (python#107391)
a378ae7
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments
@hugovk hugovk hugovk left review comments
@AA-Turner AA-Turner AA-Turner left review comments
@ericvsmith ericvsmith ericvsmith approved these changes
+1 more reviewer
@wookie184 wookie184 wookie184 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

11 participants

@thejcannon @ericvsmith @carljm @hugovk @e-gebes @JelleZijlstra @AA-Turner @wookie184 @serhiy-storchaka @bedevere-bot @erlend-aasland
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.