@dataclass — the class shape AI ships in every modern Python project — step 6 of 9
Claude wrote a dataclass with a literal [] as a default. The class
definition itself raises ValueError: mutable default .... The fix
is field(default_factory=list).
field is already imported on line 1. Replace the broken default on
line 6 so the class defines successfully and the print at the bottom
shows an empty list per instance.
Expected output:
Inbox(owner='maya', messages=[])
Inbox(owner='marcus', messages=[])
Claude wrote a dataclass with a literal [] as a default. The class
definition itself raises ValueError: mutable default .... The fix
is field(default_factory=list).
field is already imported on line 1. Replace the broken default on
line 6 so the class defines successfully and the print at the bottom
shows an empty list per instance.
Expected output:
Inbox(owner='maya', messages=[])
Inbox(owner='marcus', messages=[])
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.