Skip to content

gh-116535: Fix distracting "TypeError" in example code#116538

Merged
ericvsmith merged 2 commits into
python:mainfrom
dec1:dataclass_doc_example
Mar 9, 2024
Merged

gh-116535: Fix distracting "TypeError" in example code#116538
ericvsmith merged 2 commits into
python:mainfrom
dec1:dataclass_doc_example

Conversation

@dec1

@dec1 dec1 commented Mar 9, 2024

Copy link
Copy Markdown
Contributor

Fix: TypeError: 'int' object is not iterable when you call the sample code:

Note this is not the advertised (and expected) ValueError, which is fixed by using field

@dataclass
class D:
    x: list = []      # This code no longer raises ValueError
    def add(self, element):
        self.x += element # calling this (with an int element) raises TypeError

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

@dec1 dec1 requested a review from ericvsmith as a code owner March 9, 2024 10:06
@ghost

ghost commented Mar 9, 2024

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@Privat33r-dev Privat33r-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution

@ericvsmith ericvsmith added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Mar 9, 2024
@ericvsmith ericvsmith merged commit db8f423 into python:main Mar 9, 2024
@miss-islington-app

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 9, 2024
…h-116538)

(cherry picked from commit db8f423)

Co-authored-by: Declan <5962877+dec1@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 9, 2024

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 9, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 9, 2024
…h-116538)

(cherry picked from commit db8f423)

Co-authored-by: Declan <5962877+dec1@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 9, 2024

Copy link
Copy Markdown

GH-116552 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Mar 9, 2024
ericvsmith pushed a commit that referenced this pull request Mar 9, 2024
) (gh-116551)

gh-116535: Fix distracting "TypeError" in example code (gh-116538)
(cherry picked from commit db8f423)

Co-authored-by: Declan <5962877+dec1@users.noreply.github.com>
ericvsmith pushed a commit that referenced this pull request Mar 9, 2024
) (gh-116552)

gh-116535: Fix distracting "TypeError" in example code (gh-116538)
(cherry picked from commit db8f423)

Co-authored-by: Declan <5962877+dec1@users.noreply.github.com>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants