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
Linked PRs
Documentation
The example:
dataclasses.html#mutable-default-values
not only raises the
ValueErrorbeing discussed, but also an unwantedTypeErrorwhen you calladd(), that distracts from the point of the example.Would be better to call
append()to add a single element to the listLinked PRs