Closed
Description
Documentation
The example:
dataclasses.html#mutable-default-values
@dataclass
class D:
x: list = [] # This code raises ValueError
def add(self, element):
self.x += element
not only raises the ValueError
being discussed, but also an unwanted TypeError
when you call add()
, that distracts from the point of the example.
Would be better to call append()
to add a single element to the list