]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-116535: Fix distracting "TypeError" in example code (gh-116538) (gh-116551)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 9 Mar 2024 22:08:12 +0000 (23:08 +0100)
committerGitHub <noreply@github.com>
Sat, 9 Mar 2024 22:08:12 +0000 (17:08 -0500)
gh-116535: Fix distracting "TypeError" in example code (gh-116538)
(cherry picked from commit db8f423f58e336eb6180a70d9886b443d7203c2c)

Co-authored-by: Declan <5962877+dec1@users.noreply.github.com>
Doc/library/dataclasses.rst

index 020818a0812f0c948b2713bb1880690d750f9624..19272376e68c7149cebf574ae08532cd42978001 100644 (file)
@@ -717,7 +717,7 @@ Using dataclasses, *if* this code was valid::
   class D:
       x: list = []      # This code raises ValueError
       def add(self, element):
-          self.x += element
+          self.x.append(element)
 
 it would generate code similar to::
 
@@ -726,7 +726,7 @@ it would generate code similar to::
       def __init__(self, x=x):
           self.x = x
       def add(self, element):
-          self.x += element
+          self.x.append(element)
 
   assert D().x is D().x