Skip to content

Conversation

@artste
Copy link
Owner

@artste artste commented Nov 7, 2025

This PR introduces a powerful new feature for %%testcell that enables explicit control over which symbols enter and exit isolated cells using the (inputs)->(outputs) syntax.

Additionally, the README.md has been completely rewritten from scratch, and a new notebook testcell_zoo.ipynb has been added, showcasing real-world use cases.

Main Feature

Explicit input/output syntax for %%testcelln:

  • Syntax: %%testcelln (inputs)->(outputs)
  • Control: Specify exactly which symbols are accessible in the cell and which should be saved back to globals
  • Benefits: Forces explicit dependency declaration, preventing accidental reliance on global state
%%testcelln (data)->(calculate_stats)
# Only 'data' is available, only 'calculate_stats' is saved
def calculate_stats(values):
    return {'mean': sum(values) / len(values)}

Implementation

  • New module: testcell/inout.py - Handles parsing and processing of input/output parameters
  • Updated core: Enhanced testcell/init.py with inout parameter support
  • New documentation: nbs/01a_arguments.ipynb - Comprehensive guide to the new syntax

Documentation & Examples

  • Completely rewritten README: Clearer structure, better examples, focuses on practical use cases
  • New demo notebook: demo/testcell_zoo.ipynb - Extensive collection of real-world use cases
  • Enhanced demo: Updated demo/testcell_demo.ipynb with inout parameter examples and cells output
  • Improved rendering: Switched from HTML to Markdown code blocks for better cross-platform compatibility

Additional Improvements

  • Fixed code block rendering (removed extra newlines)
  • Updated badge examples
  • Fixed typos throughout documentation
  • Refactored nbs/index.ipynb for better organization
  • Improved visual styling for skipped cells
  • Added "Open in Modal" badge
  • Fixed HTML/XSS vulnerability in MessageBox class (added html.escape())
  • Improved error messages in validate_and_update_inputs

@artste artste merged commit 80a0971 into main Nov 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants