Skip to content

Fixes annotation for QLineEdit to allow None as argument. #166

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 22 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
sudo apt-get install --yes libgl1
# Required to stubtest QtMultimedia
sudo apt-get install --yes libpulse-mainloop-glib0
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
- name: Install
run: |
pip install --upgrade pip setuptools wheel
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
detected by latest mypy 0.930
* [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize
* [#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
* [#165](https://github.com/python-qt-tools/PyQt5-stubs/pull/165) allow `None` as argument for `QLineEdit.setText()`

## 5.15.2.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion PyQt5-stubs/QtWidgets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7147,7 +7147,7 @@ class QLineEdit(QWidget):
def undo(self) -> None: ...
def selectAll(self) -> None: ...
def clear(self) -> None: ...
def setText(self, a0: str) -> None: ...
def setText(self, a0: typing.Optional[str]) -> None: ...
def hasAcceptableInput(self) -> bool: ...
def setInputMask(self, inputMask: str) -> None: ...
def inputMask(self) -> str: ...
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def find_version(*file_paths):
packages=["PyQt5-stubs"],
extras_require={
"build": ["docker==4.2.0"],
"dev": ["mypy", "pytest"],
"dev": ["mypy", "pytest", "pytest-xvfb"],
},
classifiers=[
"Development Status :: 4 - Beta",
Expand Down
6 changes: 6 additions & 0 deletions tests/qlineedit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Tests for QLineEdit."""
from PyQt5.QtWidgets import QLineEdit

# test that QLineEdit.setText() accepts None as parameter
edit = QLineEdit()
edit.setText(None)
12 changes: 11 additions & 1 deletion tests/test_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
from pathlib import Path
import pytest
from mypy import api
from PyQt5.QtWidgets import QApplication


TESTS_DIR = Path(__file__).parent


@pytest.fixture(name="qapplication", scope="session")
def qapplication_fixture():
application = QApplication.instance()
if application is None:
application = QApplication([])

return application


def gen_tests():
"""List of all tests files included in the directory tests"""
for path in TESTS_DIR.glob('*.py'):
Expand Down Expand Up @@ -53,7 +63,7 @@ def test_stubs_qflags() -> None:
list(gen_tests()),
ids=[v.name for v in gen_tests()]
)
def test_files(filepath):
def test_files(filepath, qapplication):
"""Run the test files to make sure they work properly."""
code = filepath.read_text(encoding='utf-8')
exec(compile(code, filepath, 'exec'), {})
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setenv:
linux: OS_MARKER = linux
macos: OS_MARKER = macos
windows: OS_MARKER = windows
QT_DEBUG_PLUGINS = 1
extras =
dev
commands =
Expand Down