Repository navigation
Description
Why
A lecture that prints a DeprecationWarning or FutureWarning builds green today, and the warning sits in the published page until the library removes the feature and the lecture breaks. Nothing in QuantEcon's builds reports it by class:
build-lectures'error-outputscheck finds error outputs, not warnings.-Wcovers Sphinx's and myst-nb's warnings. myst-nb'sexecute.stderr_output: warn(nb_output_stderr) does turn any stderr output into amystnb.stderrwarning, cached pages included. But it names no warning class and fires on any stderr, and no lecture repository sets it.
QuantEcon/action-check-warnings was written for this, and is to be archived: it has no workflow consumer, and was last pushed on 2025-10-01. Its open issues record what went wrong with it:
- it read the built HTML's
cell_outputclasses, which depend on the Jupyter Book version (MAINT: check-warnings should be reviewed when JB2 is released meta#200); - it reported the warnings in its own test fixtures (BUG: check-warnings is reporting warnings from
testset when building running PRs (for other actions) meta#207); - on a pull request it checked every page, not only the ones that changed, and opened duplicate issues ([check-warnings] ENH: Update PR mode to check corresponding changed files only meta#224, BUG: get
check-warningsto run on the files being changed with in PR mode lecture-python.myst#554).
The need is still there. This issue proposes meeting it in build-lectures, where the outputs already are.
How warnings appear in a notebook
Checked with nbclient 0.11, ipykernel 6.31 and IPython 9.15:
- every warning that reaches the output is a
streamoutput onstderr, as a<file>:<line>: <Class>: <message>line, even one raised inside_repr_html_, and neverdisplay_data; - these never reach it: a
DeprecationWarningattributed to library code (IPython shows it only for__main__), anyPendingDeprecationWarning(hidden by the default filters), repeats from the same line, anything afterwarnings.filterwarnings('ignore'), and a thread's warning after its cell ends; - a warning turned into an error becomes an
erroroutput, whicherror-outputsalready finds; nb_output_stderracts only when the page is rendered: the notebook myst-nb writes, and the cache, keep stderr. So underremove,remove-warnor a cell'sremove-stderrtag, the page hides a warning this check would still see.
Proposal
New inputs on build-lectures, with a passthrough on build-jupyter-cache as error-outputs has:
| Input | Values | Default |
|---|---|---|
warning-outputs |
ignore, warn or fail |
ignore at first, so that no build changes on release |
warning-patterns |
warning class names to report, one per line, matched as a substring of the class | DeprecationWarning, FutureWarning, Pandas4Warning |
Matching by substring catches subclasses such as MatplotlibDeprecationWarning (the real case in QuantEcon/lecture-python.myst#587). Pandas4Warning is listed because pandas 3's deprecation subclass doesn't contain the base name.
How it works:
- It reads the notebooks
build-lecturesalready reads forerror-outputsin_build/jupyter_execute, not the HTML, so it doesn't depend on the theme. Likeerror-outputs, it depends on myst-nb'sjupyter_executeand jupyter-cache, so Jupyter Book 2 (MAINT: check-warnings should be reviewed when JB2 is released meta#200) would need it rewritten. - It checks only notebooks with a source under
source-dir, which keeps removed lectures out. Fixtures stay out because it reads only the book being built. - Each match gets an annotation on the source file at the cell's line, and the step summary lists all of them, since annotations are capped at 10 per step. A
warning-output-countoutput gives the total. - It opens no issue: the step summary and annotations are the report.
Which pages it reads decides where it's useful. Reading the execution cache's copy of cached pages, as #326 (still open, for #322) does for errors, would report every page on every pull request over a restored cache, which is QuantEcon/meta#224's complaint. Reading only the notebooks the build executed reports just the pages whose code changed on a pull request, and every page in cache.yml's weekly build from scratch. So the proposal is the second: in the templates, ci.yml sets warn (the warnings a pull request's own changed pages print), and cache.yml sets warn for a whole-book weekly report through build-jupyter-cache. fail in publish.yml would block a release over an upstream deprecation, so the templates don't use it.
Open questions
- The first release's default:
ignore, orwarn?warnchanges no build's result, but adds annotations to consumers' runs. - The opt-out for a warning a lecture prints on purpose: reuse the existing
remove-stderrcell tag (the page hides it, so the check skips it too), or a separate tag that keeps the warning visible but unreported? - Should cells whose stderr the page removes (
nb_output_stderr: removeorremove-warn) be skipped, or reported with a note that readers don't see them?
Claude Code (on behalf of mmcky)
Activity