Skip to content

Type annotation infrastructure and initial typing for qtbot.py #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9ba8b5f
try import from qtpy
herobank110 May 22, 2025
cc46c75
mypy precommit
herobank110 May 22, 2025
5d7df2f
ignore attrdefined
herobank110 May 22, 2025
a792e9f
only check src
herobank110 May 22, 2025
3721805
ignore more types
herobank110 May 22, 2025
1102449
add pytyped files-partial
herobank110 May 31, 2025
03f68e7
change qtpy to Any alias
herobank110 May 31, 2025
91570c2
save
herobank110 Jun 2, 2025
9b73490
add more typing
herobank110 Jun 8, 2025
6fe03d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 8, 2025
4402f35
update to mypy 1.16
herobank110 Jun 12, 2025
cc71bc6
change Generator to Iterator
herobank110 Jun 12, 2025
696492b
move error types to classvars
herobank110 Jun 12, 2025
9be150d
add mypy config file
herobank110 Jun 12, 2025
daa953b
exclude docs, remove type ignore comment
herobank110 Jun 13, 2025
f4cbcfa
change cast to annotation
herobank110 Jun 13, 2025
054f95f
change cast str to str conversion
herobank110 Jun 13, 2025
2ea1012
ignore unused ignore
herobank110 Jun 13, 2025
9bc38ef
type alias annotation for qt objects
herobank110 Jun 13, 2025
ce166ea
remove quotes from type
herobank110 Jun 13, 2025
280baef
Update CHANGELOG.rst
nicoddemus Jun 13, 2025
8217be6
Update setup.py
nicoddemus Jun 13, 2025
9548e72
Update qtbot.py
nicoddemus Jun 13, 2025
39ae0c3
Update qtbot.py
nicoddemus Jun 13, 2025
f66f688
remove already default config
herobank110 Jun 23, 2025
ae7381c
remove deprecated annotations
herobank110 Jun 23, 2025
fbb1ddb
pytest dependency for mypy
herobank110 Jun 23, 2025
5e4dbd5
fix wrong type ignore
herobank110 Jun 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ repos:
files: ^(HOWTORELEASE.rst|README.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.16.0'
hooks:
- id: mypy
additional_dependencies: [pytest]
exclude: ^docs/
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ UNRELEASED
- Added official support for Python 3.13.
- Dropped support for EOL Python 3.8.
- Dropped support for EOL PySide 2.
- Type annotations are now provided. Note that because the Qt library used is defined at runtime, Qt classes are currently annotated as ``Any``.
- Fixed PySide6 exceptions / warnings about being unable to disconnect signals
with ``qtbot.waitSignal`` (`#552`_, `#558`_).
- Reduced the likelyhood of trouble when using ``qtbot.waitSignal(s)`` and
Expand Down
8 changes: 8 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[mypy]
exclude = ^docs/
pretty = True
show_error_codes = True
strict_equality = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unused_ignores = True
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
packages=find_packages(where="src"),
package_dir={"": "src"},
entry_points={"pytest11": ["pytest-qt = pytestqt.plugin"]},
install_requires=["pytest", "pluggy>=1.1"],
install_requires=["pytest", "pluggy>=1.1", "typing_extensions"],
extras_require={
"doc": ["sphinx", "sphinx_rtd_theme"],
"dev": ["pre-commit", "tox"],
Expand Down
2 changes: 1 addition & 1 deletion src/pytestqt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# _version is automatically generated by setuptools_scm
from pytestqt._version import version

__version__ = version
__version__: str = version
4 changes: 4 additions & 0 deletions src/pytestqt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import sys
import traceback
from contextlib import contextmanager
from types import TracebackType

import pytest
from pytestqt.utils import get_marker

CapturedException = tuple[type[BaseException], BaseException, TracebackType]
CapturedExceptions = list[CapturedException]


@contextmanager
def capture_exceptions():
Expand Down
1 change: 1 addition & 0 deletions src/pytestqt/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
partial
2 changes: 1 addition & 1 deletion src/pytestqt/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def exec(self, obj, *args, **kwargs):

def get_versions(self):
if self.pytest_qt_api == "pyside6":
import PySide6
import PySide6 # type: ignore[import-not-found,unused-ignore]

version = PySide6.__version__

Expand Down
Loading