PEP561 stub files for the *PySide2/Qt5 for Python* framework
Project description
Mypy stubs for the PySide2 (Qt5 for Python)
Author : Philippe Fremy
The official typing stubs delivered along Qt5 for Python/PySide2 are insufficent
for proper typing verification with mypy
. This package fixes this by providing curated and updated stubs.
Improvements:
- fix
Signal
to make it accept method emit() - fix
qVersion()
returns string, not bytes - fix
QMessageBox.warning
, information, critical, question, about, aboutQt to accept None as parent argument - fix
QProgressDialog.setCancelButton()
accepting None - fix
QTreeWidgetItem
comparison with<
- fix
Signal.connect()
return value to bool instead of None - fix
QTimer.timeout
undeclared signal - support all
QSize
andQSizeF
operations - fix
QLineEdit.setText()
to accept None - add
QDialogButtonBox.StandardButton
__or__
operations - fix missing methods being undetected for all Qt objects
- add all missing signals to the stubs (many were missing)
- fix all method accepting a
QCursor
to accept also aQt.CursorShape
- add conversion from
QByteArray
to bytes - add
exec()
to QDialog - fix
data()
andsetData()
to accept Qt.ItemDataRole - add all method for operations on QFlag derived classes:
__or__
,__xor__
, ... - fix all method accepting a QColor to accept also a
Qt.GlobalColor
- fix signature of
QCoreApplication.translate()
- fix
QLabel.setAlignment()
to accept also Qt.AlignmentFlag
See CHANGELOG.md for full details.
This effort was inspired by the PyQt5-stubs project.
Please note that this work is far from complete. Don't hesitate to report problems or propose improvements.
Licensing
As a derived work from PySide2, the stubs are delivered under the LGPL v2.1 . See file LICENSE for more details.
Installation
Simply install the official PySide2-stubs with pip:
$ pip install PySide2-stubs
Or use the latest version from Github:
$ pip install git+https://github.com/python-qt-tools/PySide2-stubs
That's it, in both cases, the new stubs are picked up automatically by mypy
. Typechecking process should be much better.
Help improve the stubs
If you notice incorrect or missing typing information (mypy reports errors eventhough your code is correct), please report it here with the following steps:
- create an issue showing your problem
- even better, create a PR to fix the problem
- make sure to add a test showing what is mistyped. Just create a file under
tests/
, with a name not starting with test. The test suite will run the file and type-check it. - fix the stubs in the PySide2-stubs directory
- and open the PR
- make sure to add a test showing what is mistyped. Just create a file under
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PySide2-stubs-5.15.2.1.2.tar.gz
.
File metadata
- Download URL: PySide2-stubs-5.15.2.1.2.tar.gz
- Upload date:
- Size: 622.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87b25aa47a4f99898e2282874e4f27411034780f6643461b1cf39b02b4937657 |
|
MD5 | 80d42f9c018c3e554ebb2212422fbf12 |
|
BLAKE2b-256 | 766408fea82fd4c1cd3452710de3e5b8ce06a4181265d8033f0611df9a09218a |
File details
Details for the file PySide2_stubs-5.15.2.1.2-py3-none-any.whl
.
File metadata
- Download URL: PySide2_stubs-5.15.2.1.2-py3-none-any.whl
- Upload date:
- Size: 542.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bbe78bab9ab015f6d38cbcdca24dd7d4c5180236bcb62e3eddadcd1a390fea8 |
|
MD5 | 6dd69f1e0d0b6cfd3a281c64103cbe01 |
|
BLAKE2b-256 | ab500faddd258216350be57e289a74d0b5eb66de2d1605c1e98e9094d3a5738d |