script-widget 0.1.19__tar.gz → 0.1.21__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. script_widget-0.1.21/CHANGELOG.md +6 -0
  2. {script_widget-0.1.19 → script_widget-0.1.21}/CLAUDE.md +44 -3
  3. {script_widget-0.1.19/src/script_widget.egg-info → script_widget-0.1.21}/PKG-INFO +1 -1
  4. script_widget-0.1.21/docs/pages/example.ipynb +739 -0
  5. script_widget-0.1.21/docs/pages/overview.ipynb +401 -0
  6. {script_widget-0.1.19 → script_widget-0.1.21}/pyproject.toml +1 -1
  7. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget/executor.py +7 -2
  8. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget/widget.py +146 -41
  9. {script_widget-0.1.19 → script_widget-0.1.21/src/script_widget.egg-info}/PKG-INFO +1 -1
  10. script_widget-0.1.19/CHANGELOG.md +0 -0
  11. script_widget-0.1.19/docs/pages/example.ipynb +0 -5104
  12. script_widget-0.1.19/docs/pages/overview.ipynb +0 -85
  13. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/agents/code-api-consistency-reviewer.md +0 -0
  14. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/agents/code-frontend-reviewer.md +0 -0
  15. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/agents/code-python-reviewer.md +0 -0
  16. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/agents/code-theming-reviewer.md +0 -0
  17. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/agents/code-ui-heuristics-reviewer.md +0 -0
  18. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/commands/review-apply.md +0 -0
  19. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/commands/review-init.md +0 -0
  20. {script_widget-0.1.19 → script_widget-0.1.21}/.claude/commands/review.md +0 -0
  21. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/Dockerfile +0 -0
  22. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/README.md +0 -0
  23. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/devcontainer.json +0 -0
  24. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/init-firewall.sh +0 -0
  25. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/mcp-setup/generate-config.sh +0 -0
  26. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/mcp-setup/install.sh +0 -0
  27. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/mcp-setup/pixi.toml +0 -0
  28. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/mcp-setup/servers.txt +0 -0
  29. {script_widget-0.1.19 → script_widget-0.1.21}/.devcontainer/mcp-setup/test-servers.sh +0 -0
  30. {script_widget-0.1.19 → script_widget-0.1.21}/.gitattributes +0 -0
  31. {script_widget-0.1.19 → script_widget-0.1.21}/.github/workflows/conda-release.yml +0 -0
  32. {script_widget-0.1.19 → script_widget-0.1.21}/.github/workflows/pypi-release.yml +0 -0
  33. {script_widget-0.1.19 → script_widget-0.1.21}/.github/workflows/quarto-publish.yml +0 -0
  34. {script_widget-0.1.19 → script_widget-0.1.21}/.gitignore +0 -0
  35. {script_widget-0.1.19 → script_widget-0.1.21}/.vscode/vscode.css +0 -0
  36. {script_widget-0.1.19 → script_widget-0.1.21}/LICENSE +0 -0
  37. {script_widget-0.1.19 → script_widget-0.1.21}/README.md +0 -0
  38. {script_widget-0.1.19 → script_widget-0.1.21}/conda-build/README.md +0 -0
  39. {script_widget-0.1.19 → script_widget-0.1.21}/conda-build/build_env.yaml +0 -0
  40. {script_widget-0.1.19 → script_widget-0.1.21}/conda-build/meta.yaml +0 -0
  41. {script_widget-0.1.19 → script_widget-0.1.21}/data/data_table.csv +0 -0
  42. {script_widget-0.1.19 → script_widget-0.1.21}/docs/.gitignore +0 -0
  43. {script_widget-0.1.19 → script_widget-0.1.21}/docs/README.md +0 -0
  44. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_extensions/machow/interlinks/.gitignore +0 -0
  45. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_extensions/machow/interlinks/_extension.yml +0 -0
  46. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_extensions/machow/interlinks/interlinks.lua +0 -0
  47. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_inv/griffe_objects.txt +0 -0
  48. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_inv/numpy_objects.txt +0 -0
  49. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_inv/python_objects.txt +0 -0
  50. {script_widget-0.1.19 → script_widget-0.1.21}/docs/_quarto.yml +0 -0
  51. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/ExerciseOutputWidget.qmd +0 -0
  52. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/ExerciseResult.qmd +0 -0
  53. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/_sidebar.yml +0 -0
  54. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/_styles-quartodoc.css +0 -0
  55. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/index.qmd +0 -0
  56. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/register_exercise_magic.qmd +0 -0
  57. {script_widget-0.1.19 → script_widget-0.1.21}/docs/api/run_exercise.qmd +0 -0
  58. {script_widget-0.1.19 → script_widget-0.1.21}/docs/autodoc.mustache +0 -0
  59. {script_widget-0.1.19 → script_widget-0.1.21}/docs/custom.scss +0 -0
  60. {script_widget-0.1.19 → script_widget-0.1.21}/docs/objects.txt +0 -0
  61. {script_widget-0.1.19 → script_widget-0.1.21}/docs/styles.css +0 -0
  62. {script_widget-0.1.19 → script_widget-0.1.21}/pixi.lock +0 -0
  63. {script_widget-0.1.19 → script_widget-0.1.21}/review-kit/README.md +0 -0
  64. {script_widget-0.1.19 → script_widget-0.1.21}/review-kit/TEMPLATE_AUTHORS.md +0 -0
  65. {script_widget-0.1.19 → script_widget-0.1.21}/review-kit/USAGE.md +0 -0
  66. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/bump_version.py +0 -0
  67. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/docs-build-render.sh +0 -0
  68. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/docs-run-notebooks.sh +0 -0
  69. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/git-commit.sh +0 -0
  70. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/github-release.sh +0 -0
  71. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/rename.py +0 -0
  72. {script_widget-0.1.19 → script_widget-0.1.21}/scripts/tmux-project.sh +0 -0
  73. {script_widget-0.1.19 → script_widget-0.1.21}/setup.cfg +0 -0
  74. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget/__init__.py +0 -0
  75. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget.egg-info/SOURCES.txt +0 -0
  76. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget.egg-info/dependency_links.txt +0 -0
  77. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget.egg-info/requires.txt +0 -0
  78. {script_widget-0.1.19 → script_widget-0.1.21}/src/script_widget.egg-info/top_level.txt +0 -0
  79. {script_widget-0.1.19 → script_widget-0.1.21}/test/conftest.py +0 -0
  80. {script_widget-0.1.19 → script_widget-0.1.21}/test/test_executor.py +0 -0
  81. {script_widget-0.1.19 → script_widget-0.1.21}/test/test_frontend.py +0 -0
  82. {script_widget-0.1.19 → script_widget-0.1.21}/test/test_widget.py +0 -0
@@ -0,0 +1,6 @@
1
+
2
+ ## [v0.1.19] - 2026-07-20
3
+ ### Bug Fixes
4
+ - [`81d59dc`](https://github.com/munch-group/script-widget/commit/81d59dc5a032272d97617688453bf67151d64c47) - pin conda recipe python to requires-python range *(commit by [@kaspermunch](https://github.com/kaspermunch))*
5
+
6
+ [v0.1.19]: https://github.com/munch-group/script-widget/compare/v0.1.18...v0.1.19
@@ -1,5 +1,8 @@
1
1
  # CLAUDE.md
2
2
 
3
+ This file provides guidance to Claude Code (claude.ai/code) when working
4
+ with code in this repository.
5
+
3
6
  Project context for `script-widget` -- a Jupyter cell magic that runs a cell
4
7
  in a fresh, isolated namespace, built on
5
8
  [anywidget](https://anywidget.dev).
@@ -52,7 +55,11 @@ The package is `script_widget` under `src/`:
52
55
  and the trailing value (if any) is reported as a `text/plain` output.
53
56
  Returns an `ExerciseResult(stdout, stderr, outputs, error, traceback)` --
54
57
  never raises; a `SyntaxError` or any runtime exception is caught and
55
- reported via `.error`/`.traceback`.
58
+ reported via `.error`/`.traceback`. With a live `ip`, `.traceback` comes
59
+ from `ip.InteractiveTB.structured_traceback()`/`.stb2text()` (the same
60
+ machinery IPython itself uses to print an uncaught exception), so it
61
+ carries the same ANSI color codes a normal notebook traceback would --
62
+ see "Colored tracebacks" under Architecture.
56
63
  - `src/script_widget/widget.py` -- `ExerciseOutputWidget` (the
57
64
  `anywidget.AnyWidget`) + the embedded `_ESM`/`_CSS` frontend strings +
58
65
  `register_exercise_magic()`. The widget's traits are copied from an
@@ -61,7 +68,10 @@ The package is `script_widget` under `src/`:
61
68
  frontend's `render()` draws once from the model's initial state with no
62
69
  change listeners. The embedded CSS's class prefix (`sw-*`) tracks the
63
70
  package name (`script_widget`), not the magic name -- it's an internal
64
- styling namespace, not user-facing.
71
+ styling namespace, not user-facing. The box itself is always a plain gray
72
+ (no color/header change on success vs. failure); stdout and stderr are
73
+ merged into one white `.sw-output` block rather than two separately
74
+ colored ones.
65
75
  - `src/script_widget/__init__.py` -- re-exports `ExerciseResult`/
66
76
  `run_exercise`/`ExerciseOutputWidget`/`register_exercise_magic` from
67
77
  `executor.py`/`widget.py`. Importing `script_widget` therefore both
@@ -121,6 +131,26 @@ registered (a no-op if inline mode isn't active, matching normal notebook
121
131
  behavior in that case too). It's called in a `finally`, so a figure drawn
122
132
  before an exception still gets flushed and shown, exactly like a real cell.
123
133
 
134
+ ### Colored tracebacks
135
+
136
+ A `%%exercise` traceback is meant to look like a normal uncaught-exception
137
+ display, not a plain `traceback.format_exc()` dump. The backend gets this
138
+ for free by reusing IPython's own formatter rather than reimplementing it:
139
+ `ip.InteractiveTB.structured_traceback(*sys.exc_info())` +
140
+ `.stb2text(...)` -- exactly the call `InteractiveShell` itself makes before
141
+ printing an exception -- which returns text with real ANSI SGR escape
142
+ codes (IPython 9's traceback formatter is pygments-based, so source-context
143
+ lines carry full syntax highlighting via 256-color codes, not just the 16
144
+ basic ones used for the exception header/filename/line number). The
145
+ frontend has no ANSI-rendering library to lean on (`_ESM` is dependency-free
146
+ by design), so `widget.py`'s `_ESM` embeds a small SGR-code interpreter
147
+ (`ansiToHtml`/`applySGR`/`xterm256`) that turns those escape codes into
148
+ colored `<span>`s, using the exact hex values JupyterLab itself uses for
149
+ `.ansi-*-fg` so the result matches a real notebook's palette. Text with no
150
+ escape codes at all (the no-`ip` fallback path's plain
151
+ `traceback.format_exc()`) round-trips through the same function as a single
152
+ unstyled text node.
153
+
124
154
  ## Gotchas
125
155
 
126
156
  - **Mutating a shared object via an import IS visible outside the cell.**
@@ -164,8 +194,14 @@ Pixi-managed (config in `pyproject.toml` under `[tool.pixi.*]`; channels
164
194
  (dev/test only, for the figure-capture tests), `quarto`/`quartodoc`,
165
195
  `pytest`.
166
196
 
167
- - Dev install: `pixi run install-dev` (editable, no build isolation).
197
+ - Dev install: `pixi run install-dev` (`pip install --no-build-isolation
198
+ --force-reinstall --no-deps .` -- a real, **non-editable** install, despite
199
+ the task name; re-run it after every `src/` edit or `import script_widget`
200
+ picks up the stale previously-installed copy, not your change).
168
201
  - Run tests: `pixi run test` (== `pytest test/`).
202
+ - Run a single test: `pixi run pytest test/test_executor.py::test_exception_is_caught_and_reported`
203
+ (or plain `pytest ...` -- `test/conftest.py` puts `src/` on `sys.path`, so
204
+ this works even without `install-dev`).
169
205
  - Try the widget: open a notebook, `import script_widget`, then
170
206
  ```
171
207
  %%exercise
@@ -184,6 +220,11 @@ Pixi-managed (config in `pyproject.toml` under `[tool.pixi.*]`; channels
184
220
  - Release: `pixi run bump` / `release` / `version` drive
185
221
  `scripts/bump_version.py` + a tag push, which triggers the conda/PyPI
186
222
  workflows.
223
+ - Code review: `/review <target-file>` fans out specialist subagents
224
+ (Python, frontend, API consistency, UI heuristics, theming) into a
225
+ prioritized report under `.claude/review-reports/`; `/review-apply`
226
+ applies that report's findings in small, test-gated, one-commit-per-batch
227
+ steps. See `review-kit/README.md` for the full workflow.
187
228
 
188
229
  ## Distribution
189
230
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: script-widget
3
- Version: 0.1.19
3
+ Version: 0.1.21
4
4
  Summary: Jupyter widget that runs a cell in a fresh, isolated namespace (the %%exercise cell magic)
5
5
  Author-email: Kasper Munch <kaspermunch@birc.au.dk>
6
6
  License: MIT