napari: [Qt6 pyside6 6.5] TypeError on start
π Bug
Trying to launch napari from command line with pyside6==6.5.0 fails with an error:
Traceback (most recent call last):
File "/Users/piotrsobolewski/Dev/miniforge3/envs/nap-test/bin/napari", line 8, in <module>
sys.exit(main())
File "/Users/piotrsobolewski/Dev/napari/napari/__main__.py", line 566, in main
_run()
File "/Users/piotrsobolewski/Dev/napari/napari/__main__.py", line 326, in _run
viewer = Viewer()
File "/Users/piotrsobolewski/Dev/napari/napari/viewer.py", line 67, in __init__
self._window = Window(self, show=show)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/qt_main_window.py", line 589, in __init__
self._qt_viewer.dockLayerList, tabify=False, menu=self.window_menu
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/qt_viewer.py", line 357, in dockLayerList
layerListLayout.addWidget(self.layers)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/qt_viewer.py", line 335, in layers
self._layers = QtLayerList(self.viewer.layers)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/containers/qt_layer_list.py", line 46, in __init__
super().__init__(root, parent)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/containers/qt_list_view.py", line 43, in __init__
self.setRoot(root)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/containers/_base_item_view.py", line 87, in setRoot
self.setModel(create_model(root, self))
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/containers/_factory.py", line 72, in create_model
return QtLayerListModel(obj, parent=parent)
File "/Users/piotrsobolewski/Dev/napari/napari/_qt/containers/_base_item_model.py", line 80, in __init__
super().__init__(parent=parent)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
To Reproduce
Steps to reproduce the behavior:
- make fresh conda env (python 3.10)
- pip install pyside6 (will yield 6.5.0
- pip install -e . (napari from main)
- try to launch using
napari
Expected behavior
Should work
Environment
macOS 13.2.1, arm64, python 3.10, napari from main, pyside6 6.5.0 from pip Edit: update: also occurs with 13.3.1, python 3.11.3, pyside 6.5.1
Additional context
This is also reflected in failing tests, see: https://github.com/napari/napari/pull/5702 Some discussion here: https://github.com/pyapp-kit/app-model/issues/93 and https://napari.zulipchat.com/#narrow/stream/212875-general/topic/Qt.206.2E5
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 24 (19 by maintainers)
Hi! So not totally sure what changed in PySide6 >=6.5.0 for the error to happen but basically changing the order of inheritance seems like changes also the order used when you call
super
to call the respective__init__
methods of the inherited classes. I think the MRO (Method Resolution Order) depends on the order you put the classes your class inherits.My guess is that leaving last the plain Python class while also inherithing a PySide6>=6.5.0 causes
super
to call the class__init__
passing all the args/kwargs which causes theTypeError
. Changing the other seems like workarounds this since possibly the args/kwargs donβt get passed to the plain Python class__init__
(maybe the MRO mechanism detects is not necessary to pass the args/kwargs in that call?)As mentioned, this is more like a guess because Iβm not completly sure to fully get the way MRO works to be honest, but tests passed over the superqt PR when I encountered the problem there so I took that as a win π
Edit: Edited this because I got lost in my own explanation π
Hi all π - thanks for your efforts here. Itβs currently a big blocker for us at deeplabcut, so if our dev team can allocate time/efforts please let us know and cc @jeylau β€οΈ
Just as an update, pyside6 6.5.2 was released and this issue remains. The fix in https://github.com/napari/napari/pull/6062 still works, but alas so do the test failures from https://github.com/napari/napari/issues/5657
Ok building 6.5.1.1 https://github.com/conda-forge/pyside2-feedstock/pull/195 to help with testing.
I have a branch with the swap of position and it seems to work fine. However, we hit a different issue: https://github.com/napari/napari/issues/5657 I will make a PR, but I expect that tests will fail. Edit: note pyside6 6.5.1 is bad regardless of this fix, with
TypeError: actionTriggered(int) only accepts 1 argument(s), 2 given!
when for example opening samples, so it requires 6.5.1.1Would swapping the order of the subclasses be acceptable for napari? The presumption is that it would be accompanied with a comment as to why this is important for PySide6.
Thanks @dalthviz I think maybe we should take the same approach in napari, so we can test on pyside >6.5
Maybe, Issue 2354 has been getting good attention. The developers translated my example and adapted it for their internal validation and reuploaded it. so iβm pretty confident that there will be some improvement.
To recreate the PySide6 issue
now i need to figure out their issue reporting system:
https://bugreports.qt.io/browse/PYSIDE-2354
(not officially involved with deeplabcut but thanks for the ping)
Lets see if we can backport the patch: https://github.com/conda-forge/pyside2-feedstock/pull/191
It looks like it is working with PyQt6, so the problem is only touching PySide6.