From 12520bf4ba7906c59a06d2254ac6c713c29ef1f5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 May 2017 19:08:59 +0200 Subject: [PATCH] Install PyQt from PyPI for pylint This means we can be sure to have QtWebEngine available and won't have QtWebKit. --- .pylintrc | 2 +- qutebrowser/browser/webengine/certificateerror.py | 2 -- qutebrowser/browser/webengine/interceptor.py | 2 -- qutebrowser/browser/webengine/webenginedownloads.py | 2 -- qutebrowser/browser/webengine/webengineelem.py | 7 ------- qutebrowser/browser/webengine/webengineinspector.py | 2 -- qutebrowser/browser/webengine/webenginequtescheme.py | 2 -- qutebrowser/browser/webengine/webenginesettings.py | 2 -- qutebrowser/browser/webengine/webenginetab.py | 2 -- qutebrowser/browser/webengine/webview.py | 2 -- qutebrowser/utils/log.py | 1 - scripts/dev/run_pylint_on_tests.py | 2 +- tests/conftest.py | 3 +-- tests/end2end/fixtures/webserver.py | 2 +- tests/unit/browser/webkit/test_qt_javascript.py | 1 - tox.ini | 2 +- 16 files changed, 5 insertions(+), 31 deletions(-) diff --git a/.pylintrc b/.pylintrc index c94058297..177dbffd0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -70,7 +70,7 @@ valid-metaclass-classmethod-first-arg=cls [TYPECHECK] # WORKAROUND for https://github.com/PyCQA/astroid/pull/357 -ignored-modules=pytest +ignored-modules=pytest,PyQt5,PyQt5.QtWebKit # MsgType added as WORKAROUND for # https://bitbucket.org/logilab/pylint/issues/690/ # UnsetObject because pylint infers any objreg.get(...) as UnsetObject. diff --git a/qutebrowser/browser/webengine/certificateerror.py b/qutebrowser/browser/webengine/certificateerror.py index 07c4bbe1b..c97e51b81 100644 --- a/qutebrowser/browser/webengine/certificateerror.py +++ b/qutebrowser/browser/webengine/certificateerror.py @@ -19,9 +19,7 @@ """Wrapper over a QWebEngineCertificateError.""" -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineCertificateError -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.utils import usertypes, utils, debug diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py index e02f621a3..0cb2d446e 100644 --- a/qutebrowser/browser/webengine/interceptor.py +++ b/qutebrowser/browser/webengine/interceptor.py @@ -19,9 +19,7 @@ """A request interceptor taking care of adblocking and custom headers.""" -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInterceptor -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.config import config from qutebrowser.browser import shared diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py index f1ca2e6e3..7eec132ed 100644 --- a/qutebrowser/browser/webengine/webenginedownloads.py +++ b/qutebrowser/browser/webengine/webenginedownloads.py @@ -25,9 +25,7 @@ import urllib import functools from PyQt5.QtCore import pyqtSlot, Qt -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineDownloadItem -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import downloads from qutebrowser.utils import debug, usertypes, message, log, qtutils diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py index dc170115d..f7ab41ead 100644 --- a/qutebrowser/browser/webengine/webengineelem.py +++ b/qutebrowser/browser/webengine/webengineelem.py @@ -25,9 +25,7 @@ from PyQt5.QtCore import QRect, Qt, QPoint, QEventLoop from PyQt5.QtGui import QMouseEvent from PyQt5.QtWidgets import QApplication -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineSettings -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.utils import log, javascript from qutebrowser.browser import webelem @@ -192,14 +190,9 @@ class WebEngineElement(webelem.AbstractWebElement): def _click_editable(self, click_target): # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58515 - # pylint doesn't know about Qt.MouseEventSynthesizedBySystem - # because it was added in Qt 5.6, but we can be sure we use that with - # QtWebEngine. - # pylint: disable=no-member,useless-suppression ev = QMouseEvent(QMouseEvent.MouseButtonPress, QPoint(0, 0), QPoint(0, 0), QPoint(0, 0), Qt.NoButton, Qt.NoButton, Qt.NoModifier, Qt.MouseEventSynthesizedBySystem) - # pylint: enable=no-member,useless-suppression self._tab.send_event(ev) # This actually "clicks" the element by calling focus() on it in JS. self._js_call('focus') diff --git a/qutebrowser/browser/webengine/webengineinspector.py b/qutebrowser/browser/webengine/webengineinspector.py index cbb258039..8fa8bcb2d 100644 --- a/qutebrowser/browser/webengine/webengineinspector.py +++ b/qutebrowser/browser/webengine/webengineinspector.py @@ -22,9 +22,7 @@ import os from PyQt5.QtCore import QUrl -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineView -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import inspector diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py index 5acf6fcba..2e9aedd3e 100644 --- a/qutebrowser/browser/webengine/webenginequtescheme.py +++ b/qutebrowser/browser/webengine/webenginequtescheme.py @@ -20,10 +20,8 @@ """QtWebEngine specific qute://* handlers and glue code.""" from PyQt5.QtCore import QBuffer, QIODevice -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler, QWebEngineUrlRequestJob) -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import qutescheme from qutebrowser.utils import log, qtutils diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index 8076df674..bd499e7e0 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -30,10 +30,8 @@ Module attributes: import os import logging -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile, QWebEngineScript) -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import shared from qutebrowser.config import config, websettings diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 13b6c7d30..f44d3e6da 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -25,10 +25,8 @@ import sip from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl, QTimer from PyQt5.QtGui import QKeyEvent from PyQt5.QtNetwork import QAuthenticator -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWidgets import QApplication from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import browsertab, mouse, shared from qutebrowser.browser.webengine import (webview, webengineelem, tabhistory, diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index 0cb9bb612..fd6fc99cb 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -23,9 +23,7 @@ import functools from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, PYQT_VERSION from PyQt5.QtGui import QPalette -# pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage -# pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import shared from qutebrowser.browser.webengine import certificateerror, webenginesettings diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 1cea959ee..5bf8424ff 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -342,7 +342,6 @@ def qt_message_handler(msg_type, context, msg): QtCore.QtFatalMsg: logging.CRITICAL, } try: - # pylint: disable=no-member,useless-suppression qt_to_logging[QtCore.QtInfoMsg] = logging.INFO except AttributeError: # Qt < 5.5 diff --git a/scripts/dev/run_pylint_on_tests.py b/scripts/dev/run_pylint_on_tests.py index b9fb4845d..e6263692b 100644 --- a/scripts/dev/run_pylint_on_tests.py +++ b/scripts/dev/run_pylint_on_tests.py @@ -68,7 +68,7 @@ def main(): no_docstring_rgx = ['^__.*__$', '^setup$'] args = (['--disable={}'.format(','.join(disabled)), '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx)), - '--ignored-modules=helpers,pytest'] + + '--ignored-modules=helpers,pytest,PyQt5'] + sys.argv[2:] + files) env = os.environ.copy() env['PYTHONPATH'] = os.pathsep.join(pythonpath) diff --git a/tests/conftest.py b/tests/conftest.py index 2fdf8ab9a..6ac9515ce 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -168,10 +168,9 @@ def pytest_configure(config): webengine_env = os.environ.get('QUTE_BDD_WEBENGINE', '') config.webengine = bool(webengine_arg or webengine_env) # Fail early if QtWebEngine is not available - # pylint: disable=no-name-in-module,unused-variable,useless-suppression + # pylint: disable=unused-variable if config.webengine: import PyQt5.QtWebEngineWidgets - # pylint: enable=no-name-in-module,unused-variable,useless-suppression @pytest.fixture(scope='session', autouse=True) diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py index 8fc674e42..acb99acfe 100644 --- a/tests/end2end/fixtures/webserver.py +++ b/tests/end2end/fixtures/webserver.py @@ -62,7 +62,7 @@ class Request(testprocess.Line): def _check_status(self): """Check if the http status is what we expected.""" # WORKAROUND for https://github.com/PyCQA/pylint/issues/399 (?) - # pylint: disable=no-member, useless-suppression + # pylint: disable=no-member path_to_statuses = { '/favicon.ico': [http.client.NOT_FOUND], '/does-not-exist': [http.client.NOT_FOUND], diff --git a/tests/unit/browser/webkit/test_qt_javascript.py b/tests/unit/browser/webkit/test_qt_javascript.py index fd8a0c496..72d1f4ce0 100644 --- a/tests/unit/browser/webkit/test_qt_javascript.py +++ b/tests/unit/browser/webkit/test_qt_javascript.py @@ -51,7 +51,6 @@ def test_element_js_webkit(webview, js_enabled, expected): def test_simple_js_webengine(callback_checker, webengineview, js_enabled, expected): """With QtWebEngine, runJavaScript works even when JS is off.""" - # pylint: disable=no-name-in-module,useless-suppression # If we get there (because of the webengineview fixture) we can be certain # QtWebEngine is available from PyQt5.QtWebEngineWidgets import QWebEngineSettings diff --git a/tox.ini b/tox.ini index ea30c7236..722dad3c4 100644 --- a/tox.ini +++ b/tox.ini @@ -186,8 +186,8 @@ passenv = deps = {[testenv]deps} -r{toxinidir}/misc/requirements/requirements-pylint.txt + -r{toxinidir}/misc/requirements/requirements-pyqt.txt commands = - {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {posargs} {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no {posargs}