-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
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
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir