Skip to content

Add :hide_err: option to suppress [runpythonerror] from runpython output#56

Merged
sdpython merged 5 commits into
mainfrom
copilot/add-option-to-remove-runpythonerror
Apr 29, 2026
Merged

Add :hide_err: option to suppress [runpythonerror] from runpython output#56
sdpython merged 5 commits into
mainfrom
copilot/add-option-to-remove-runpythonerror

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

When using .. runpython:: with :rst:, any stderr output (deprecation warnings, etc.) causes [runpythonerror] to be literally appended to the RST content and rendered into the final documentation. There was no way to suppress this.

Changes

  • New :hide_err: flag option on RunPythonDirective — when present, skips appending the \n[runpythonerror]\n<stderr> block to the output content
  • Docstring updated to document the new option alongside existing ones
  • New test test_runpython_hide_err verifying the error block is suppressed while stdout is preserved

Usage

.. runpython::
    :rst:
    :hide_err:

    import warnings
    warnings.warn("deprecated", DeprecationWarning)
    print("This RST output still appears cleanly")

Without :hide_err:, the DeprecationWarning would render as [runpythonerror] followed by the warning text in the output.

Copilot AI changed the title [WIP] Add option to remove runpython error message Add :hide_err: option to suppress [runpythonerror] from runpython output Apr 29, 2026
Copilot AI requested a review from xadupre April 29, 2026 16:44
@xadupre xadupre marked this pull request as ready for review April 29, 2026 17:40
@sdpython sdpython merged commit 45e0ff9 into main Apr 29, 2026
16 of 22 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.

when running runpython with rst, it shows [runpythonerror], there should be an option to remove it

3 participants