Skip to content

Instantly share code, notes, and snippets.

@panchicore
Created February 25, 2026 20:50
Show Gist options
  • Select an option

  • Save panchicore/9e8835ff9c0a1a0cea030ee427ea37d7 to your computer and use it in GitHub Desktop.

Select an option

Save panchicore/9e8835ff9c0a1a0cea030ee427ea37d7 to your computer and use it in GitHub Desktop.

ModelStageParams — add .name back + null-safe

Problem

  1. Demo and HLD show params.model_stage.name but pushed code removed .name (only .cuid)
  2. params.model_stage is None when no status → AttributeError on .name/.cuid access (Luis's null pointer concern)

Fix

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 = cuid

Injection — 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

Result

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment