From ad34dae3cf25b5a212c8a2f9b9a5bfb227c3b2ef Mon Sep 17 00:00:00 2001 From: hujc Date: Thu, 23 Apr 2026 05:46:02 +0000 Subject: [PATCH] Make ShapeConfig strict with slots=True Plain @dataclass types silently accept writes to undeclared attribute names, creating dead attributes with no diagnostic. When a ShapeConfig field is renamed, existing cfg.old_name = value writes in downstream consumers keep running but become no-ops. Seen in practice in isaac-sim/IsaacLab#5289: PR #1732 renamed ShapeConfig.contact_margin to gap. The downstream write builder.default_shape_cfg.contact_margin = 0.01 continued to run for weeks after the rename, created a dead attribute, and the intended 1 cm shape gap was never applied. Add slots=True to the @dataclass decorator on ShapeConfig so writes to unknown attribute names raise AttributeError at the write site. Future ShapeConfig renames will be loud for every consumer. --- newton/_src/sim/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newton/_src/sim/builder.py b/newton/_src/sim/builder.py index 171527de3d..9c07063ec8 100644 --- a/newton/_src/sim/builder.py +++ b/newton/_src/sim/builder.py @@ -210,7 +210,7 @@ class ActuatorEntry: output_indices: list[list[int]] # Per-actuator output indices args: list[dict[str, Any]] # Per-actuator array params (scalar params in dict key) - @dataclass + @dataclass(slots=True) class ShapeConfig: """ Represents the properties of a collision shape used in simulation.