Skip to content

Commit cc358fa

Browse files
docs(monitors): note currentStatus removal on MonitorDto
The docs-quickstart at https://docs.devhelm.io/sdk/python/quickstart shows ``monitor.currentStatus`` but the field was removed from the DTO and never came back. Pre-existing SDK users hit this on upgrade and are stuck guessing how to recover the live status of a monitor. Inject a class-level docstring banner via ``inject_strict_config.py`` so the note shows up in IDE hovers and survives regeneration. The banner table is keyed by class name so future runtime-affecting upstream changes can land here without bloating the typegen. Restoring ``current_status`` properly is upstream work in mono; tracked separately. Round-3 DevEx fix P1.Bug9 (in-scope half). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 66bec7b commit cc358fa

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

scripts/inject_strict_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
CLASS_RE = re.compile(r"^class\s+([A-Za-z_][\w]*)\s*\(\s*(BaseModel)\s*\)\s*:\s*$")
5353
CONFIG_LINE = " model_config = ConfigDict(extra='forbid', populate_by_name=True)"
5454

55+
# Doc-banner injections keyed by class name. Inserted as a leading docstring
56+
# inside the target class so the note shows up in IDE hovers and stays put
57+
# across regeneration. Keep messages short and actionable; long-form
58+
# documentation belongs in the API reference, not the generated source.
59+
CLASS_BANNERS: dict[str, str] = {
60+
"MonitorDto": (
61+
"Note: ``currentStatus`` was removed from this DTO. "
62+
"Inspect ``enabled`` and the incident-policy API to derive a "
63+
"live status for a monitor instead."
64+
),
65+
}
66+
5567

5668
# StrEnum members that shadow inherited str methods need a `# type: ignore`
5769
# because mypy thinks they're overriding the base method with an incompatible
@@ -117,10 +129,17 @@ def inject(source: str) -> tuple[str, int]:
117129
if not m:
118130
i += 1
119131
continue
132+
class_name = m.group(1)
120133
# Look at the very next line. If it's already model_config or pass,
121134
# leave the class alone (idempotency / empty class).
122135
next_idx = i + 1
123136
next_line = lines[next_idx] if next_idx < len(lines) else ""
137+
# Inject the class-level docstring banner if requested. Skip if a
138+
# docstring is already present (idempotent on partial reruns).
139+
banner = CLASS_BANNERS.get(class_name)
140+
if banner and not next_line.lstrip().startswith(('"""', "'''")):
141+
out.append(f' """{banner}"""\n')
142+
modified += 1
124143
if "model_config" in next_line:
125144
# Upgrade the existing config line to include populate_by_name=True
126145
# if it isn't already there. Idempotent across re-runs.

src/devhelm/_generated.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6818,6 +6818,8 @@ class MonitorAssertionDto(BaseModel):
68186818

68196819

68206820
class MonitorDto(BaseModel):
6821+
"""Note: ``currentStatus`` was removed from this DTO. Inspect ``enabled`` and the incident-policy API to derive a live status for a monitor instead."""
6822+
68216823
model_config = ConfigDict(extra="forbid", populate_by_name=True)
68226824
id: Annotated[UUID, Field(description="Unique monitor identifier")]
68236825
organization_id: Annotated[

0 commit comments

Comments
 (0)