Skip to content

Commit c62cc6e

Browse files
committed
fix tests
1 parent 4c45f61 commit c62cc6e

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

boulder/validation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,32 @@ def _coerce_value(val: Any, property_name: str = "") -> Any:
303303
else self.simulation.__dict__
304304
)
305305

306-
# Process each field
306+
# Process each field and mirror updates into __dict__ for compatibility
307+
coerced_updates: Dict[str, Any] = {}
307308
for key, value in sim_data.items():
308309
if isinstance(value, str):
309310
coerced = _coerce_value(value, key)
310311
try:
311312
setattr(self.simulation, key, coerced)
313+
# Ensure __dict__ contains coerced values for downstream consumers
314+
coerced_updates[key] = coerced
312315
except Exception as e:
313316
import logging
314317

315318
logging.warning(
316319
f"Failed to set attribute '{key}' on simulation: {e}"
317320
)
318321

322+
# In pydantic v2, extras may live outside __dict__. Update __dict__ for consumers
323+
# that expect direct dict access (e.g., tests using model.simulation.__dict__).
324+
if coerced_updates:
325+
try:
326+
self.simulation.__dict__.update(coerced_updates)
327+
except Exception:
328+
# Best-effort: if __dict__ is not writable, ignore silently
329+
# (attributes have already been set above).
330+
pass
331+
319332

320333
def validate_normalized_config(config: Dict[str, Any]) -> NormalizedConfigModel:
321334
"""Validate a normalized config dict using Pydantic models.

0 commit comments

Comments
 (0)