- Demo and HLD show
params.model_stage.namebut pushed code removed.name(only.cuid) params.model_stageisNonewhen no status →AttributeErroron.name/.cuidaccess (Luis's null pointer concern)
class ModelStageParams:
"""Simple object to provide dot notation access to model stage properties."""
def __init__(self, name=None, cuid=None):
self.name = name
self.cuid = cuidInjection — always inject an instance, never None:
# Add model_stage for InventoryModel objects (same pattern as finding_type)
if self.is_inventory_model():
if self.status:
params["model_stage"] = ModelStageParams(
name=self.status.name, cuid=self.status.cuid
)
else:
params["model_stage"] = ModelStageParams() # .name=None, .cuid=None| Expression | No status | Has status |
|---|---|---|
params.model_stage.name |
None (no crash) |
"Production" |
params.model_stage.cuid |
None (no crash) |
"clx1a2b3c" |
params.model_stage.name == "Production" |
False (correct) |
True |
params.model_stage.cuid == "clx1a2b3c" |
False (correct) |
True |
No guard pattern needed. Users can't hit AttributeError. .name back for readability, .cuid for rename-safety.