Skip to main content
mypy logo

CI

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 and QSizeF 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 a Qt.CursorShape
  • add conversion from QByteArray to bytes
  • add exec() to QDialog
  • fix data() and setData() 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

Metadata

Release files for PySide2-stubs 5.15.2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PySide2-stubs 5.15.2.1.2
File Size Uploaded
PySide2-stubs-5.15.2.1.2.tar.gz 622.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PySide2-stubs 5.15.2.1.2
File Interpreter ABI Platform
PySide2_stubs-5.15.2.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / PySide2-stubs-5.15.2.1.2.tar.gz

Download URL PySide2-stubs-5.15.2.1.2.tar.gz
Size 622.8 kB
Tags Source
SHA-256 checksum
How to use checksums
87b25aa47a4f99898e2282874e4f27411034780f6643461b1cf39b02b4937657
BLAKE2b-256 checksum
How to use checksums
766408fea82fd4c1cd3452710de3e5b8ce06a4181265d8033f0611df9a09218a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / PySide2_stubs-5.15.2.1.2-py3-none-any.whl

Download URL PySide2_stubs-5.15.2.1.2-py3-none-any.whl
Size 542.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bbe78bab9ab015f6d38cbcdca24dd7d4c5180236bcb62e3eddadcd1a390fea8
BLAKE2b-256 checksum
How to use checksums
ab500faddd258216350be57e289a74d0b5eb66de2d1605c1e98e9094d3a5738d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

5.15.2.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page