Skip to content

Commit 6b964eb

Browse files
authored
Merge pull request #166 from altendky/playing_around
Fixes annotation for QLineEdit to allow None as argument.
2 parents 7b58dd0 + 95e8059 commit 6b964eb

File tree

7 files changed

+23
-3
lines changed

7 files changed

+23
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
sudo apt-get install --yes libgl1
6363
# Required to stubtest QtMultimedia
6464
sudo apt-get install --yes libpulse-mainloop-glib0
65+
sudo apt-get install --yes libgl1 libgl1-mesa-dev xvfb x11-utils libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
6566
- name: Install
6667
run: |
6768
pip install --upgrade pip setuptools wheel

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2424
detected by latest mypy 0.930
2525
* [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize
2626
* [#189](https://github.com/python-qt-tools/PyQt5-stubs/pull/189) Fix QListWidget, QTreeWidget and QTableWidget so that their respective items are now optional in many places when used as argument or return value
27+
* [#165](https://github.com/python-qt-tools/PyQt5-stubs/pull/165) allow `None` as argument for `QLineEdit.setText()`
28+
2729
## 5.15.2.0
2830

2931
### Added

PyQt5-stubs/QtWidgets.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7147,7 +7147,7 @@ class QLineEdit(QWidget):
71477147
def undo(self) -> None: ...
71487148
def selectAll(self) -> None: ...
71497149
def clear(self) -> None: ...
7150-
def setText(self, a0: str) -> None: ...
7150+
def setText(self, a0: typing.Optional[str]) -> None: ...
71517151
def hasAcceptableInput(self) -> bool: ...
71527152
def setInputMask(self, inputMask: str) -> None: ...
71537153
def inputMask(self) -> str: ...

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def find_version(*file_paths):
5252
packages=["PyQt5-stubs"],
5353
extras_require={
5454
"build": ["docker==4.2.0"],
55-
"dev": ["mypy", "pytest"],
55+
"dev": ["mypy", "pytest", "pytest-xvfb"],
5656
},
5757
classifiers=[
5858
"Development Status :: 4 - Beta",

tests/qlineedit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Tests for QLineEdit."""
2+
from PyQt5.QtWidgets import QLineEdit
3+
4+
# test that QLineEdit.setText() accepts None as parameter
5+
edit = QLineEdit()
6+
edit.setText(None)

tests/test_stubs.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
from pathlib import Path
33
import pytest
44
from mypy import api
5+
from PyQt5.QtWidgets import QApplication
56

67

78
TESTS_DIR = Path(__file__).parent
89

910

11+
@pytest.fixture(name="qapplication", scope="session")
12+
def qapplication_fixture():
13+
application = QApplication.instance()
14+
if application is None:
15+
application = QApplication([])
16+
17+
return application
18+
19+
1020
def gen_tests():
1121
"""List of all tests files included in the directory tests"""
1222
for path in TESTS_DIR.glob('*.py'):
@@ -53,7 +63,7 @@ def test_stubs_qflags() -> None:
5363
list(gen_tests()),
5464
ids=[v.name for v in gen_tests()]
5565
)
56-
def test_files(filepath):
66+
def test_files(filepath, qapplication):
5767
"""Run the test files to make sure they work properly."""
5868
code = filepath.read_text(encoding='utf-8')
5969
exec(compile(code, filepath, 'exec'), {})

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ setenv:
88
linux: OS_MARKER = linux
99
macos: OS_MARKER = macos
1010
windows: OS_MARKER = windows
11+
QT_DEBUG_PLUGINS = 1
1112
extras =
1213
dev
1314
commands =

0 commit comments

Comments
 (0)