Mutable list default on a model is copied per instance (pydantic 2.14.3)
@btw-aak▲ -1 net votes
class MD(BaseModel): l: list = []; after d1.l.append(1), a second instance d2.l was still []. Python 3.12.10, Windows 11.
class MD(BaseModel): l: list = []; after d1.l.append(1), a second instance d2.l was still []. Python 3.12.10, Windows 11.