From bc9d3053544addbfbb8c428e2be36bcbe7d3470c Mon Sep 17 00:00:00 2001 From: siddhugolu Date: Mon, 23 Oct 2017 01:46:02 +0530 Subject: [PATCH] modified as requested --- qutebrowser/app.py | 1 - qutebrowser/browser/browsertab.py | 1 - qutebrowser/browser/commands.py | 7 ++++--- qutebrowser/browser/downloads.py | 3 --- qutebrowser/browser/network/pac.py | 1 - qutebrowser/browser/webkit/webview.py | 1 - qutebrowser/commands/command.py | 1 - qutebrowser/commands/userscripts.py | 2 +- qutebrowser/completion/models/completionmodel.py | 1 - qutebrowser/misc/backendproblem.py | 1 - qutebrowser/misc/earlyinit.py | 1 - qutebrowser/misc/split.py | 1 - scripts/asciidoc2html.py | 1 - scripts/dev/src2asciidoc.py | 4 ++-- scripts/dev/ua_fetch.py | 1 - tests/conftest.py | 1 - tests/end2end/fixtures/webserver.py | 2 +- tests/unit/browser/test_tab.py | 1 - tests/unit/browser/webkit/network/test_pac.py | 1 - tests/unit/browser/webkit/test_webkitelem.py | 1 - tests/unit/config/test_configfiles.py | 2 +- tests/unit/config/test_configinit.py | 1 - tests/unit/misc/test_ipc.py | 4 ++-- tests/unit/utils/test_debug.py | 1 - tests/unit/utils/test_qtutils.py | 3 +-- 25 files changed, 12 insertions(+), 32 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index fdf174288..a64d2236e 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -496,7 +496,6 @@ def _init_modules(args, crash_handler): macros.init() # Init backend-specific stuff browsertab.init() - # pylint: enable=too-many-statements class Quitter: diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index f14506e3c..141555290 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -677,7 +677,6 @@ class AbstractTab(QWidget): self._install_event_filter() self.zoom.set_default() - # pylint: enable=protected-access def _install_event_filter(self): raise NotImplementedError diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 4c5087575..c1cff0e37 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1490,8 +1490,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') def view_source(self): """Show the source of the current page in a new tab.""" - # pylint: disable=no-member - # WORKAROUND for https://bitbucket.org/logilab/pylint/issue/491/ + tab = self._current_widget() if tab.data.viewing_source: raise cmdexc.CommandError("Already viewing source!") @@ -1504,10 +1503,13 @@ class CommandDispatcher: def show_source_cb(source): """Show source as soon as it's ready.""" + # WORKAROUND for https://github.com/PyCQA/pylint/issues/491 + # pylint: disable=no-member lexer = pygments.lexers.HtmlLexer() formatter = pygments.formatters.HtmlFormatter( full=True, linenos='table', title='Source for {}'.format(current_url.toDisplayString())) + # pylint: enable=no-member highlighted = pygments.highlight(source, lexer, formatter) new_tab = self._tabbed_browser.tabopen() @@ -1515,7 +1517,6 @@ class CommandDispatcher: new_tab.data.viewing_source = True tab.dump_async(show_source_cb) - # pylint: enable=no-member @cmdutils.register(instance='command-dispatcher', scope='window', debug=True) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index e8c4e75c1..07e5c7c30 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -239,7 +239,6 @@ class FileDownloadTarget(_DownloadTarget): def __init__(self, filename): # pylint: disable=super-init-not-called self.filename = filename - # pylint: enable=super-init-not-called def suggested_filename(self): return os.path.basename(self.filename) @@ -259,7 +258,6 @@ class FileObjDownloadTarget(_DownloadTarget): def __init__(self, fileobj): # pylint: disable=super-init-not-called self.fileobj = fileobj - # pylint: enable=super-init-not-called def suggested_filename(self): try: @@ -287,7 +285,6 @@ class OpenFileDownloadTarget(_DownloadTarget): def __init__(self, cmdline=None): # pylint: disable=super-init-not-called self.cmdline = cmdline - # pylint: enable=super-init-not-called def suggested_filename(self): raise NoFilenameError diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py index 350365892..69158fe62 100644 --- a/qutebrowser/browser/network/pac.py +++ b/qutebrowser/browser/network/pac.py @@ -254,7 +254,6 @@ class PACFetcher(QObject): def __eq__(self, other): # pylint: disable=protected-access return self._pac_url == other._pac_url - # pylint: enable=protected-access def __repr__(self): return utils.get_repr(self, url=self._pac_url, constructor=True) diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py index e0e853730..4f1ff10c8 100644 --- a/qutebrowser/browser/webkit/webview.py +++ b/qutebrowser/browser/webkit/webview.py @@ -184,7 +184,6 @@ class WebView(QWebView): window=self.win_id) # pylint: disable=protected-access return tabbed_browser.tabopen(background=False)._widget - # pylint: enable=protected-access def paintEvent(self, e): """Extend paintEvent to emit a signal if the scroll position changed. diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 543eac176..9baa4efe7 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -100,7 +100,6 @@ class Command: if scope != 'global' and instance is None: raise ValueError("Setting scope without setting instance makes " "no sense!") - # pylint: enable=too-many-locals self.name = name self.maxsplit = maxsplit diff --git a/qutebrowser/commands/userscripts.py b/qutebrowser/commands/userscripts.py index f57f46f4f..d86cb8ccf 100644 --- a/qutebrowser/commands/userscripts.py +++ b/qutebrowser/commands/userscripts.py @@ -56,10 +56,10 @@ class _QtFIFOReader(QObject): # can add O_NONBLOCK. # pylint: disable=no-member,useless-suppression fd = os.open(filepath, os.O_RDWR | os.O_NONBLOCK) + # pylint: enable=no-member,useless-suppression self._fifo = os.fdopen(fd, 'r') self._notifier = QSocketNotifier(fd, QSocketNotifier.Read, self) self._notifier.activated.connect(self.read_line) - # pylint: enable=no-member,useless-suppression @pyqtSlot() def read_line(self): diff --git a/qutebrowser/completion/models/completionmodel.py b/qutebrowser/completion/models/completionmodel.py index bf21f2cbc..398673200 100644 --- a/qutebrowser/completion/models/completionmodel.py +++ b/qutebrowser/completion/models/completionmodel.py @@ -154,7 +154,6 @@ class CompletionModel(QAbstractItemModel): """Override QAbstractItemModel::columnCount.""" # pylint: disable=unused-argument return 3 - # pylint: enable=unused-argument def canFetchMore(self, parent): """Override to forward the call to the categories.""" diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py index 4c35e970d..f126ceda5 100644 --- a/qutebrowser/misc/backendproblem.py +++ b/qutebrowser/misc/backendproblem.py @@ -287,7 +287,6 @@ def _try_import_backends(): assert results.webengine_error is not None return results - # pylint: enable=unused-variable def _handle_ssl_support(fatal=False): diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index 2afd569b6..af53b73a7 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -187,7 +187,6 @@ def check_ssl_support(): from PyQt5.QtNetwork import QSslSocket except ImportError: _die("Fatal error: Your Qt is built without SSL support.") - # pylint: enable=unused-variable def _check_modules(modules): diff --git a/qutebrowser/misc/split.py b/qutebrowser/misc/split.py index 070659ef9..3f3b2d362 100644 --- a/qutebrowser/misc/split.py +++ b/qutebrowser/misc/split.py @@ -119,7 +119,6 @@ class ShellLexer: self.token += nextchar else: raise AssertionError("Invalid state {!r}!".format(self.state)) - # pylint: enable=too-many-branches,too-many-statements if self.state in self.escape and not self.keep: self.token += self.state if self.token or self.quoted: diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index 911983547..aa6c82469 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -182,7 +182,6 @@ class AsciiDoc: asciidoc_args = ['--theme=qute', '-a toc', '-a toc-placement=manual'] self.call(modified_src, dst, *asciidoc_args) - # pylint: enable=too-many-locals,too-many-statements def _build_website(self): """Prepare and build the website.""" diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 8e06dcafb..bf1fc8fd0 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -160,9 +160,9 @@ def _get_configtypes(): configtypes.MappingType, # pylint: disable=protected-access configtypes._Numeric] and + # pylint: enable=protected-access issubclass(e, configtypes.BaseType)) yield from inspect.getmembers(configtypes, predicate) - # pylint: enable=protected-access def _get_setting_types_quickref(): @@ -501,7 +501,6 @@ def regenerate_manpage(filename): """Update manpage OPTIONS using an argparse parser.""" # pylint: disable=protected-access parser = qutebrowser.get_argparser() - # pylint: enable=protected-access groups = [] # positionals, optionals and user-defined groups for group in parser._action_groups: @@ -514,6 +513,7 @@ def regenerate_manpage(filename): if action_data is not None: groupdata.append(action_data) groups.append('\n'.join(groupdata)) + # pylint: enable=protected-access options = '\n'.join(groups) # epilog if parser.epilog is not None: diff --git a/scripts/dev/ua_fetch.py b/scripts/dev/ua_fetch.py index 8b8f25799..b276eff27 100755 --- a/scripts/dev/ua_fetch.py +++ b/scripts/dev/ua_fetch.py @@ -73,7 +73,6 @@ def filter_list(complete_list, browsers): if found: break return table - # pylint: enable=too-many-nested-blocks def add_diversity(table): diff --git a/tests/conftest.py b/tests/conftest.py index 14c793bbd..301658d56 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -172,7 +172,6 @@ def pytest_configure(config): # pylint: disable=unused-variable if config.webengine: import PyQt5.QtWebEngineWidgets - # pylint: enable=unused-variable @pytest.fixture(scope='session', autouse=True) diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py index 442b6afe3..7060e30b9 100644 --- a/tests/end2end/fixtures/webserver.py +++ b/tests/end2end/fixtures/webserver.py @@ -80,7 +80,6 @@ class Request(testprocess.Line): '/500-inline': [http.client.INTERNAL_SERVER_ERROR], } - # pylint: enable=no-member for i in range(15): path_to_statuses['/redirect/{}'.format(i)] = [http.client.FOUND] for suffix in ['', '1', '2', '3', '4', '5', '6']: @@ -88,6 +87,7 @@ class Request(testprocess.Line): path_to_statuses[key] = [http.client.UNAUTHORIZED, http.client.OK] default_statuses = [http.client.OK, http.client.NOT_MODIFIED] + # pylint: enable=no-member sanitized = QUrl('http://localhost' + self.path).path() # Remove ?foo expected_statuses = path_to_statuses.get(sanitized, default_statuses) diff --git a/tests/unit/browser/test_tab.py b/tests/unit/browser/test_tab.py index 64ed533aa..4b674e583 100644 --- a/tests/unit/browser/test_tab.py +++ b/tests/unit/browser/test_tab.py @@ -91,7 +91,6 @@ class Tab(browsertab.AbstractTab): def _install_event_filter(self): pass - # pylint: enable=abstract-method @pytest.mark.xfail(run=False, reason='Causes segfaults, see #1638') diff --git a/tests/unit/browser/webkit/network/test_pac.py b/tests/unit/browser/webkit/network/test_pac.py index 5e8beb0cf..7519c0fd2 100644 --- a/tests/unit/browser/webkit/network/test_pac.py +++ b/tests/unit/browser/webkit/network/test_pac.py @@ -94,7 +94,6 @@ def _pac_noexcept_test(call): ("known.domain", "'1.2.3.4'"), ("bogus.domain.foobar", "null") ]) -# pylint: enable=line-too-long, invalid-name def test_dnsResolve(monkeypatch, domain, expected): def mock_fromName(host): diff --git a/tests/unit/browser/webkit/test_webkitelem.py b/tests/unit/browser/webkit/test_webkitelem.py index 2efa848b8..3174d7281 100644 --- a/tests/unit/browser/webkit/test_webkitelem.py +++ b/tests/unit/browser/webkit/test_webkitelem.py @@ -130,7 +130,6 @@ def get_webelem(geometry=None, frame=None, *, null=False, style=None, elem.styleProperty.side_effect = _style_property wrapped = webkitelem.WebKitElement(elem, tab=None) return wrapped - # pylint: enable=too-many-locals,too-many-branches class SelectionAndFilterTests: diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 6c040eab8..776356fef 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -109,10 +109,10 @@ class TestYaml: # WORKAROUND for https://github.com/PyCQA/pylint/issues/574 # pylint: disable=superfluous-parens if 'magenta' in (old_config or ''): + # pylint: enable=superfluous-parens assert ' colors.hints.fg: magenta' in lines if insert: assert ' tabs.show: never' in lines - # pylint: enable=superfluous-parens def test_init_save_manager(self, yaml, fake_save_manager): yaml.init_save_manager(fake_save_manager) diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py index 925f123eb..1501b794d 100644 --- a/tests/unit/config/test_configinit.py +++ b/tests/unit/config/test_configinit.py @@ -177,7 +177,6 @@ class TestEarlyInit: assert config.instance._values == {} else: assert config.instance._values == {'colors.hints.fg': 'magenta'} - # pylint: enable=too-many-locals,too-many-branches def test_invalid_change_filter(self, init_patch, args): config.change_filter('foobar') diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 21d15a734..281bd4ac4 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -294,7 +294,6 @@ class TestListen: @pytest.mark.posix def test_permissions_posix(self, ipc_server): - # pylint: disable=no-member,useless-suppression ipc_server.listen() sockfile = ipc_server._server.fullServerName() sockdir = os.path.dirname(sockfile) @@ -302,8 +301,10 @@ class TestListen: file_stat = os.stat(sockfile) dir_stat = os.stat(sockdir) + # pylint: disable=no-member,useless-suppression file_owner_ok = file_stat.st_uid == os.getuid() dir_owner_ok = dir_stat.st_uid == os.getuid() + # pylint: enable=no-member,useless-suppression file_mode_ok = file_stat.st_mode & 0o777 == 0o700 dir_mode_ok = dir_stat.st_mode & 0o777 == 0o700 @@ -311,7 +312,6 @@ class TestListen: sockdir, dir_stat.st_uid, dir_stat.st_mode)) print('sockfile: {} / owner {} / mode {:o}'.format( sockfile, file_stat.st_uid, file_stat.st_mode)) - # pylint: enable=no-member,useless-suppression assert file_owner_ok or dir_owner_ok assert file_mode_ok or dir_mode_ok diff --git a/tests/unit/utils/test_debug.py b/tests/unit/utils/test_debug.py index 6d9c8f7c4..9b77b9628 100644 --- a/tests/unit/utils/test_debug.py +++ b/tests/unit/utils/test_debug.py @@ -267,7 +267,6 @@ class TestGetAllObjects: global object registry - 0 objects: """).rstrip('\n') - # pylint: enable=unused-variable assert debug.get_all_objects(start_obj=root) == expected diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index 42f8030db..d580d677a 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -702,12 +702,12 @@ class TestPyQIODevice: whence = os.SEEK_HOLE elif hasattr(os, 'SEEK_DATA'): whence = os.SEEK_DATA + # pylint: enable=no-member,useless-suppression else: pytest.skip("Needs os.SEEK_HOLE or os.SEEK_DATA available.") pyqiodev.open(QIODevice.ReadOnly) with pytest.raises(io.UnsupportedOperation): pyqiodev.seek(0, whence) - # pylint: enable=no-member,useless-suppression @pytest.mark.flaky() def test_qprocess(self, py_proc): @@ -907,4 +907,3 @@ class TestEventLoop: QTimer.singleShot(400, self.loop.quit) self.loop.exec_() assert not self.loop._executing - # pylint: enable=attribute-defined-outside-init