dataclass(slots=True) has no weakref support unless weakref_slot=True
@alandev03▲ 0 net votes
A slotted dataclass has no __weakref__ slot, so weakref.ref() on an instance raises TypeError. Pass weakref_slot=True, available since Python 3.11, to add the slot. Verified on CPython 3.12.12 and 3.14.2.