From 59303d686d93b14cf156f356e5b8f8cad65e48a9 Mon Sep 17 00:00:00 2001 From: Mark Final Date: Sat, 15 Jul 2023 13:15:52 +0100 Subject: [PATCH] Fixes #98. Linting. Using thirdparty PySide6 stubs to help mypy --- cruiz/commands/conaninvocation.py | 4 +--- cruiz/entrypoint.py | 4 ++-- cruiz/revealonfilesystem.py | 8 ++++---- mypy.ini | 5 +++-- requirements_dev.txt | 1 + 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cruiz/commands/conaninvocation.py b/cruiz/commands/conaninvocation.py index 89265d6..bf26e47 100755 --- a/cruiz/commands/conaninvocation.py +++ b/cruiz/commands/conaninvocation.py @@ -85,9 +85,7 @@ def _disconnect_signal(self, result: typing.Any, exception: typing.Any) -> None: self._last_command_running = False def _critical_failure(self, message: str) -> None: - QtWidgets.QMessageBox.critical( - None, "System failure", message # type: ignore[call-overload] - ) + QtWidgets.QMessageBox.critical(None, "System failure", message) sys.exit(1) def invoke( diff --git a/cruiz/entrypoint.py b/cruiz/entrypoint.py index 9c9e8c4..858593f 100755 --- a/cruiz/entrypoint.py +++ b/cruiz/entrypoint.py @@ -20,7 +20,7 @@ if CONAN_SPEC is None: QtWidgets.QApplication() QtWidgets.QMessageBox.critical( - None, # type: ignore + None, "Conan unavailable", "Unable to locate the conan Python package in the current environment.\n" "Use pip install conan[==version].", @@ -75,7 +75,7 @@ def _are_resources_out_of_date() -> bool: if _are_resources_out_of_date(): QtWidgets.QApplication() QtWidgets.QMessageBox.critical( - None, # type: ignore + None, "Resources", "Resources are out of date.\n" "Please build with python3 setup.py build", ) diff --git a/cruiz/revealonfilesystem.py b/cruiz/revealonfilesystem.py index 437d795..4827e47 100644 --- a/cruiz/revealonfilesystem.py +++ b/cruiz/revealonfilesystem.py @@ -43,7 +43,7 @@ def _use_xdg_open(file_info: QtCore.QFileInfo) -> None: xdg_open_path = QtCore.QStandardPaths.findExecutable("xdg-open") if not xdg_open_path: QtWidgets.QMessageBox.critical( - None, # type: ignore + None, "Cannot reveal path", "Unable to find the path to xdg-open", ) @@ -58,7 +58,7 @@ def reveal_on_filesystem(path: pathlib.Path) -> None: """ if not path.exists(): QtWidgets.QMessageBox.critical( - None, "Cannot reveal path", f"Path '{path}' does not exist" # type: ignore + None, "Cannot reveal path", f"Path '{path}' does not exist" ) return file_info = QtCore.QFileInfo(path) @@ -81,7 +81,7 @@ def open_terminal_at(path: str) -> None: file_info = QtCore.QFileInfo(path) if not file_info.exists(): QtWidgets.QMessageBox.critical( - None, # type: ignore + None, "Cannot open terminal at path", f"Path '{path}' does not exist", ) @@ -109,7 +109,7 @@ def open_terminal_at(path: str) -> None: ) else: QtWidgets.QMessageBox.critical( - None, # type: ignore + None, "Cannot open terminal at path", "Unable to detect window manager", ) diff --git a/mypy.ini b/mypy.ini index 3f4d5ca..b05fde0 100644 --- a/mypy.ini +++ b/mypy.ini @@ -46,6 +46,8 @@ strict = True # Temporarily disabling this error code, as PySide6 .pyi files do not expose signals # see https://bugreports.qt.io/browse/PYSIDE-1603 +# that issue is closed, but stubs remain a problem, although some are resolved with +# the thirdparty stubs, see requirements_dev.txt disable_error_code = attr-defined # Per-module options: @@ -78,5 +80,4 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-cruiz.pyside6.*] -ignore_missing_imports = True -follow_imports = silent +disable_error_code = no-untyped-def, no-untyped-call diff --git a/requirements_dev.txt b/requirements_dev.txt index 6ee18cc..8e8bc25 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,3 +6,4 @@ flake8-bugbear flake8-simplify flake8-use-pathlib mypy +PySide6-stubs @ git+https://github.com/python-qt-tools/PySide6-stubs@1e2a21993ce7f2b55828ac250c96973551f8174f