]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116535: Fix distracting "TypeError" in example code (gh-116538)
authorDeclan <5962877+dec1@users.noreply.github.com>
Sat, 9 Mar 2024 21:52:57 +0000 (22:52 +0100)
committerGitHub <noreply@github.com>
Sat, 9 Mar 2024 21:52:57 +0000 (16:52 -0500)
Doc/library/dataclasses.rst

index 4ada69d63abada19a394b1b8d1d021873f6d9ac9..c612c138fc6ea8f342bf16ea5d010a3d12154a83 100644 (file)
@@ -719,7 +719,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::
 
@@ -728,7 +728,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