Skip to content

Type-check against PySide6's bundled stubs and other type related cleanups, update minimum requirements and validate - #478

Open
jenshnielsen wants to merge 8 commits into
toolsforexperiments:masterfrom
jenshnielsen:pyside6-bundled-stubs
Open

jenshnielsen wants to merge 8 commits into
toolsforexperiments:masterfrom
jenshnielsen:pyside6-bundled-stubs

Conversation

@jenshnielsen

@jenshnielsen jenshnielsen commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Drop the third-party PySide6-stubs package from the test requirements. Its last release targets PySide6 6.7, and mypy preferred it over the stubs that ship with PySide6 itself.

The bundled stubs type Slot correctly, so the eight @Slot(...) # type: ignore[arg-type] comments are no longer needed. They also mark nullable return values, which needed small fixes:

  • assert that self.layout() is set before adding or removing widgets (PlotWidgetContainer, Collapsible, pyqtgraph AutoPlot)
  • assert the exclusive grid button group has a checked button
  • inspectr: build the date list as list[str], which DateList.updateDates expects (now checked, since slots keep their signatures)

FileModel.currently_selected_tags() tested the truthiness of
checkState(). With PyQt5 CheckState is int-like, but with PyQt6 and
PySide6 it is a Python Enum whose members are all truthy, so every tag
(including the "Tag Filter" header) was reported as selected regardless
of which boxes were checked. Compare against CheckState.Checked instead
and add a regression test.

Enable mypy's truthy-bool error code, which flags this class of bug.
The only other hit was a dead if childItem: in the JSON viewer:
TreeItem.child() always returns an item for an index hasIndex() has
already validated.

Drop the third-party PySide6-stubs package from the test requirements.
Its last release targets PySide6 6.7, and mypy preferred it over the
stubs that ship with PySide6 itself.

The bundled stubs type Slot correctly, so the eight
`@Slot(...)  # type: ignore[arg-type]` comments are no longer needed.
They also mark nullable return values, which needed small fixes:
- assert that self.layout() is set before adding or removing widgets
  (PlotWidgetContainer, Collapsible, pyqtgraph AutoPlot)
- assert the exclusive grid button group has a checked button
- inspectr: build the date list as list[str], which DateList.updateDates
  expects (now checked, since slots keep their signatures)
FileModel.currently_selected_tags() tested the truthiness of
checkState(). With PyQt5 CheckState is int-like, but with PyQt6 and
PySide6 it is a Python Enum whose members are all truthy, so every tag
(including the "Tag Filter" header) was reported as selected regardless
of which boxes were checked. Compare against CheckState.Checked instead
and add a regression test.

Enable mypy's truthy-bool error code, which flags this class of bug.
The only other hit was a dead `if childItem:` in the JSON viewer:
TreeItem.child() always returns an item for an index hasIndex() has
already validated.
@jenshnielsen jenshnielsen changed the title Type-check against PySide6's bundled stubs Type-check against PySide6's bundled stubs and other type related cleanups Nov 3, 2026
backend_qt5agg is the Qt5-era name. In current matplotlib it is a thin
alias for backend_qtagg that also sets _QT_FORCE_QT5_BINDING, which
makes matplotlib prefer a Qt5 binding when none is imported yet.
backend_qtagg works with both Qt5 and Qt6 bindings and needs
matplotlib >= 3.5.
- xarray: plottr never imports it. It is still installed, as a
  dependency of xhistogram and qcodes, which use it.
- psutil and packaging: only the tests use them, so move them to
  test_requirements.txt.
- typing-extensions: plottr only imports TypedDict from it, which is in
  the standard library's typing module on every Python plottr supports.
Most declared minimum versions predate Python 3.12, plottr's oldest
supported Python, and could not be installed or did not work there.
Raise each floor to the oldest release that works on Python 3.12 with
both numpy 1.26 and numpy 2:

- numpy 1.26: first release with Python 3.12 wheels.
- pandas 2.2.2, matplotlib 3.8.4, h5py 3.11: first releases built for
  numpy 2. Older ones (e.g. pandas 2.1.x, matplotlib 3.7.3, h5py 3.10)
  install fine but fail to import when the resolver pairs them with
  numpy 2 ("numpy.dtype size changed"), since they do not cap numpy.
- lmfit 1.1: first release with a wheel; 1.0.x cannot be built on
  Python 3.12.
- watchdog 2.3: first release with Linux and Windows wheels.
- pyzmq 25.1.1: first release with Python 3.12 wheels.
- qtpy 2.3: qtpy 1.x imports distutils, which Python 3.12 removed, and
  2.0-2.2 fail to import with current PySide6.
- pyqtgraph 0.13.3: 0.12.x fails much of the test suite with current
  PySide6.
- versioningit 2.2.1: same as the build requirement (and what qcodes
  needs).
- Qt binding extras: PySide6 6.6 is the first release for Python 3.12
  (6.8.0 has a known crash). PyQt6 6.7 is the first release that pins
  its matching Qt libraries; with older PyQt6 the resolver installs the
  newest Qt and plottr crashes. PyQt5 5.15.10 is the first release that
  works on Python 3.12.

Validated by resolving every declared dependency at its minimum with
`uv pip compile --resolution lowest-direct` on Python 3.12 and running
the test suite: with each of the pyside6, pyqt6 and pyqt5 extras, and
with numpy pinned to 2.0.0 and to the latest 2.x.

Also bring requirements.txt in line with pyproject.toml: it lacked
versioningit and unicodeit.
@jenshnielsen jenshnielsen changed the title Type-check against PySide6's bundled stubs and other type related cleanups Type-check against PySide6's bundled stubs and other type related cleanups, update minimum requirements Nov 3, 2026
Resolve every dependency at the lowest version pyproject.toml allows
(uv's lowest-direct resolution, including the pyside6 and qcodes
extras) on Python 3.12, the oldest supported Python, and run the test
suite against that. The test tools are installed constrained to those
pins, so they cannot move them. This keeps the declared minimum
versions honest as plottr's code changes.
astral-sh/setup-uv only publishes full version tags, so @v10 does not
resolve and the minimum-dependencies job failed while setting up.
@jenshnielsen jenshnielsen changed the title Type-check against PySide6's bundled stubs and other type related cleanups, update minimum requirements Type-check against PySide6's bundled stubs and other type related cleanups, update minimum requirements and validate Nov 3, 2026
The minimum-dependencies CI job printed PySide6 "Sort Warning"s
("Signals and slots in QMetaObject 'DataSelector' are not ordered
correctly, this may lead to issues"). These are not harmless: with
PySide6 6.6.0 through 6.10.0 the affected signals of plottr's nodes,
such as newDataStructure, are never delivered, not even to a plain
Python slot. The DataSelector's UI then stays empty and does not follow
option changes. PySide6 6.10.1 delivers them and no longer warns;
PyQt5 and PyQt6 are not affected.

Raise the PySide6 floor to 6.10.1 (which also makes the 6.8.0 exclusion
redundant), and make test_data_selector_node_ui check that the UI
actually receives the data structure and selection. That test fails
with PySide6 6.10.0 and passes with 6.10.1, so the minimum-dependencies
job now covers this.

With PySide6 6.10.1, matplotlib before 3.10.6 can raise "Internal C++
object (MPLPlot) already deleted" from a deferred redraw of a closed
canvas; 3.10.6 added the missing check (matplotlib PR #30399).
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