Commit ed60b27
Fix three latent bugs in samples/explore_workbook.py
Fresh-eyes review on #1843 (2026-09-17) surfaced three pre-existing
bugs that the samples/_shared.py migration in that PR did not
introduce but did make more visible:
1. Line 127 used a bare type annotation `changed: TSC.CustomViewItem(
id=c.id, name=...)` instead of an assignment, so `changed` was never
bound and the following `server.custom_views.update(changed)` would
NameError.
2. `c` was defined inside the custom-views loop and then referenced
outside it. On a site with zero custom views the loop never runs
and every subsequent reference NameErrors.
3. `if args.delete:` at line 145 referred to a flag that was never
defined in the sample's argparse, so any invocation reaching that
line raised AttributeError.
Fixes:
- Add `=` on line 127 to bind `changed`.
- Collect the custom-views iterator into a list, wrap the update/
export block in `if custom_views:`, and pick the last entry
explicitly (`c = custom_views[-1]`) — matches the intent of the
original "for the last custom view in the list" comment.
- Add a `--delete` argparse flag with `action="store_true"` and a
clear help string. Guard the delete block so it prints a clear
no-op message when the site has no custom views.
No other behavior change. Sample compiles and imports cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6b2bd09 commit ed60b27
1 file changed
Lines changed: 27 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
117 | 122 | | |
118 | 123 | | |
119 | 124 | | |
120 | | - | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
137 | 145 | | |
138 | 146 | | |
139 | 147 | | |
| |||
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
146 | | - | |
147 | | - | |
148 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
149 | 160 | | |
150 | 161 | | |
151 | 162 | | |
| |||
0 commit comments