[PySide] PySide2 typing stubs are available

Philippe Fremy phil at freehackers.org
Tue May 31 12:20:44 CEST 2022


Hi,

If you are into using type annotations for your python programs, you 
have certainly been disappointed by the typing stubs delivered by Qt. 
The official version fails to detect many errors and reports many errors 
for perfectly valid code.

But things are changing: I have started a PySide2-stubs package. The 
first version is already available at pypi 
(https://pypi.org/project/PySide2-stubs/ ).

The package provides updated typing information for all of PySide2. It 
fixes some very basic typing issues:
- fix Signal with method emit()
- fix qVersion() returning string, not bytes
- fix QMessageBox.warning, information, critical, question, about, 
aboutQt to accept None as parent argument
- fix QAction.setShortcut() to accept string as argument
- fix QTreeWidgetItem comparison with <
- fix QTimer.timeout undeclared signal
- fix QLineEdit.setText() to accept None

The current version is already useful but still has many wrong types 
declared (all QFlags are declared with a wrong type for example). I'll 
continue working on it until I get something reasonably usable.

Don't hesitate to join the effort if you like typed python code.

Have a nice day,

Philippe



More information about the PySide mailing list