Skip to content

Run remaining un-run examples - #1421

Merged
larsoner merged 5 commits into
enthought:mainfrom
larsoner:coverage-generator-and-targets
Aug 20, 2026
Merged

Run remaining un-run examples#1421
larsoner merged 5 commits into
enthought:mainfrom
larsoner:coverage-generator-and-targets

Conversation

@larsoner

Copy link
Copy Markdown
Collaborator

... and then fix errors found while running them with warnings-as-errors.

larsoner and others added 5 commits August 19, 2026 15:33
The gallery render has held its examples to warnings-as-errors for a while;
`pytest examples` did not, so the thirty it runs could warn freely.  Make them
fatal there too, from one shared inventory rather than a second copy:
`scripts/render_docs.py`'s `WARNING_FILTERS` moves to
`mayavi/tests/common.py:EXAMPLE_WARNING_FILTERS`, which both callers now read.
It has to be applied in Python -- pytest's own `filterwarnings` covers the
process pytest runs in, and every case here is a subprocess.

Six of the thirty warned.  Four are the pyface workbench
PendingDeprecationWarning, unsatisfiable until the import has somewhere to move
to, and are filtered.  The other two are real:

- `tvtk/pyface/ui/qt4/actor_editor.py` tried `traitsui.qt4.editor` before
  `traitsui.qt.editor`.  On traitsui >= 8 the first still resolves, through the
  shadowed-module alias, and warns while doing it.  `scene_editor.py` beside it
  already had them the right way round; match it.
- `examples/mayavi/advanced_visualization/datasets.py` called two things VTK 9.6
  deprecated: `CellArray.set_cells(n, cells)`, which 9.7 removes outright, and
  the `UnstructuredGrid.set_cells` overload taking cell locations.
  `import_legacy_format` takes the same flat (npts, p0, p1, ...) array the
  example already builds -- it is what `array_handler` uses internally -- and
  the two-argument `set_cells` replaces the other.  The hand-built `offset`
  array goes with them: the cell array carries its own offsets now, so building
  one was teaching something no longer true.

`mayavi/tests/datasets.py:mixed_type_ug` is a copy of that same code, reached by
nothing that runs with warnings fatal, so it would have gone on quietly until a
9.7 row hit it.  Same fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Taken from the docs-site artifact of the Docs build on this branch, since the
render is only reproducible within one environment and a local macOS render
moves all seventy-five of them.

The one that matters is example_coil_design_application: its figure has been a
picture of two coils and no magnetic field ever since np.NAN went away, because
the exception was raised inside a traits notification handler and swallowed.
It now has the B field, the axes and the field node in the pipeline tree.

The other twenty-five are drift that predates this branch -- the Docs run on
main at 3ea411b reports the same twenty-six -- so committing them is what
makes the job's diff empty again rather than anything this branch renders
differently.  example_magnetic_field is not among them: it is in
FLAKY_EXAMPLES, so the render now runs it (which is how its divide-by-zero was
found) but keeps the committed image.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The new tvtk/tests/test_ivtk.py takes the pyqt6 row down -- not with a failure
but with exit 134, so the run dies before pytest can say why.  Reproduced in a
PyQt6 venv: two independent upstream bugs, both of which every IVTK window (and
so ivtk.viewer()) walks into, and neither of which is tvtk's to fix.

pyface's _MenuItem calls QMenu.addAction(text, slot, shortcut).  PyQt6 has no
such overload -- its three-argument forms are (text, slot, type) and
(text, shortcut, slot) -- so building the menu bar raises TypeError.  That is
what failed test_ivtk, which has no splitter to reach the second one.

traitsui's _GroupSplitter._resize_items seeds its sizes from Item.width, a
Float, and returns early on `if avail <= 0` before coercing anything, so a
splitter that is still zero-sized reaches QSplitter.setSizes([-1.0, -1.0]).
PyQt6 rejects the floats; the call is inside a showEvent, where the TypeError
is unraisable, so Qt aborts the process.  That is the exit 134, and no skip
inside the test could have caught it -- hence skipping the class.

Both reproduce against pyface and traitsui main, so the skip cannot be keyed on
a release yet.  PySide6 coerces the floats and has the addAction overload, so
the rest of the matrix still covers what these tests are for -- the pyface 8
create() regression in tvtk/tools/ivtk.py.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
PyQt6 dropped the unscoped enums, but pyface still names QFont.TypeWriter --
in its console widget, its code editor and its font registry -- so building
the Python shell view there raises AttributeError.  Verified against pyface
8.0.0 on PyQt6: `PythonShell(parent).create()` fails without the alias and
builds with it.

mayavi had this fix and lost it.  It was written as a helper of
`fix_python_shell_view`, and when envisage 8.0.1 made that workaround
unnecessary the whole block went, alias included -- but the alias is a pyface
bug, nothing to do with envisage, and is still needed.  It comes back as a
function of its own, applied from `mayavi_workbench_application.run()` beside
`fix_view_chooser()`.

Nothing had noticed because nothing built a shell: the pyqt6 row's suites do
not, and the docs render is PySide6.  So `test_workbench_fixes.py` now builds
one, which fails with exactly that AttributeError if the alias is taken away
again.

Also names this as the third of the upstream bugs behind the PyQt6 skip in
tvtk/tests/test_ivtk.py -- the previous commit's message and comment had only
the two that the abort left visible.  The two `WithCrust` windows hit
QFont.TypeWriter through the same console widget; nothing applies the alias on
a tvtk-only path, and fixing just that one would not make the windows work
while the pyface menu and traitsui splitter bugs stand, so the skip stays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@larsoner
larsoner merged commit fe0572d into enthought:main Aug 20, 2026
58 of 61 checks passed
@larsoner
larsoner deleted the coverage-generator-and-targets branch August 20, 2026 15:23
@larsoner

Copy link
Copy Markdown
Collaborator Author

Good to run these for example for #1422, so let's get this in!

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.

1 participant