A mutable list should not be assigned as one shared default. Configure the dataclass field with default_factory=list so each new Bowl invokes list and receives a fresh scoops list. section 9.10
Fresh scoop lists with a dataclass
from typing import List from dataclasses import dataclass, field @dataclass class Bowl(): scoops: List[Scoop] = field(default_factory=list) def add_scoops(self, *new_scoops): for one_scoop in new_scoops: self.scoops.append(one_scoop) def __repr__(self): return '\n'.join(s.flavor for s in self.scoops)
