From 7dacc89d2ad4cf31010f69e2a40847d7a2b34fc4 Mon Sep 17 00:00:00 2001 From: qutebrowser bot Date: Mon, 6 Feb 2023 04:22:25 +0000 Subject: Update dependencies --- misc/requirements/requirements-dev.txt | 2 +- misc/requirements/requirements-mypy.txt | 6 +++--- misc/requirements/requirements-pylint.txt | 6 +++--- misc/requirements/requirements-sphinx.txt | 4 ++-- misc/requirements/requirements-tests.txt | 6 +++--- misc/requirements/requirements-tox.txt | 6 +++--- requirements.txt | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt index a9a5b8b7f..5db283553 100644 --- a/misc/requirements/requirements-dev.txt +++ b/misc/requirements/requirements-dev.txt @@ -45,4 +45,4 @@ typing_extensions==4.4.0 uritemplate==4.1.1 # urllib3==1.26.14 webencodings==0.5.1 -zipp==3.12.0 +zipp==3.12.1 diff --git a/misc/requirements/requirements-mypy.txt b/misc/requirements/requirements-mypy.txt index 2b4575841..c46c534c0 100644 --- a/misc/requirements/requirements-mypy.txt +++ b/misc/requirements/requirements-mypy.txt @@ -8,11 +8,11 @@ Jinja2==3.1.2 lxml==4.9.2 MarkupSafe==2.1.2 mypy==0.991 -mypy-extensions==0.4.3 +mypy-extensions==1.0.0 pluggy==1.0.0 Pygments==2.14.0 PyQt5-stubs==5.15.6.0 tomli==2.0.1 -types-PyYAML==6.0.12.3 +types-PyYAML==6.0.12.4 typing_extensions==4.4.0 -zipp==3.12.0 +zipp==3.12.1 diff --git a/misc/requirements/requirements-pylint.txt b/misc/requirements/requirements-pylint.txt index 7820791b8..f7ef551a1 100644 --- a/misc/requirements/requirements-pylint.txt +++ b/misc/requirements/requirements-pylint.txt @@ -1,6 +1,6 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py -astroid==2.13.5 +astroid==2.14.1 certifi==2022.12.7 cffi==1.15.1 charset-normalizer==3.0.1 @@ -9,14 +9,14 @@ dill==0.3.6 future==0.18.3 github3.py==3.2.0 idna==3.4 -isort==5.11.4 +isort==5.11.5 lazy-object-proxy==1.9.0 mccabe==0.7.0 pefile==2022.5.30 platformdirs==2.6.2 pycparser==2.21 PyJWT==2.6.0 -pylint==2.15.10 +pylint==2.16.1 python-dateutil==2.8.2 ./scripts/dev/pylint_checkers requests==2.28.2 diff --git a/misc/requirements/requirements-sphinx.txt b/misc/requirements/requirements-sphinx.txt index adba6ff34..a71fe0253 100644 --- a/misc/requirements/requirements-sphinx.txt +++ b/misc/requirements/requirements-sphinx.txt @@ -18,9 +18,9 @@ snowballstemmer==2.2.0 Sphinx==6.1.3 sphinxcontrib-applehelp==1.0.4 sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==2.0.0 +sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 urllib3==1.26.14 -zipp==3.12.0 +zipp==3.12.1 diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index d66bc7947..7868af3d2 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -1,7 +1,7 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py attrs==22.2.0 -beautifulsoup4==4.11.1 +beautifulsoup4==4.11.2 certifi==2022.12.7 charset-normalizer==3.0.1 cheroot==9.0.0 @@ -12,7 +12,7 @@ execnet==1.9.0 filelock==3.9.0 Flask==2.2.2 hunter==3.5.1 -hypothesis==6.65.2 +hypothesis==6.67.1 idna==3.4 importlib-metadata==6.0.0 iniconfig==2.0.0 @@ -53,4 +53,4 @@ typing_extensions==4.4.0 urllib3==1.26.14 vulture==2.7 Werkzeug==2.2.2 -zipp==3.12.0 +zipp==3.12.1 diff --git a/misc/requirements/requirements-tox.txt b/misc/requirements/requirements-tox.txt index fdd62b43c..7cd5a8c46 100644 --- a/misc/requirements/requirements-tox.txt +++ b/misc/requirements/requirements-tox.txt @@ -6,12 +6,12 @@ colorama==0.4.6 distlib==0.3.6 filelock==3.9.0 packaging==23.0 -pip==22.3.1 +pip==23.0 platformdirs==2.6.2 pluggy==1.0.0 pyproject_api==1.5.0 -setuptools==67.0.0 +setuptools==67.1.0 tomli==2.0.1 -tox==4.4.2 +tox==4.4.4 virtualenv==20.17.1 wheel==0.38.4 diff --git a/requirements.txt b/requirements.txt index ea55d5b1a..f97f75d81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ MarkupSafe==2.1.2 Pygments==2.14.0 PyYAML==6.0 typing_extensions==4.4.0 ; python_version<"3.8" -zipp==3.12.0 +zipp==3.12.1 # Unpinned due to recompile_requirements.py limitations pyobjc-core ; sys_platform=="darwin" pyobjc-framework-Cocoa ; sys_platform=="darwin" -- cgit v1.2.3-54-g00ecf From ff8dbc45805013b5a119a0d6b2c943308faeca8e Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 6 Feb 2023 18:53:56 +1300 Subject: lint: broad-exception-raised Mostly pretty lazy fixes. Most of the places in the tests we were already matching on error message, a couple of places we weren't. The tick-tock one was the only one that wasn't being used right where it was raised. Some of them I just changed to RuntimeError because it was shorter than adding the pylint directive. --- qutebrowser/components/misccommands.py | 1 + qutebrowser/utils/standarddir.py | 6 ++++-- scripts/dev/build_release.py | 5 +++-- scripts/dev/src2asciidoc.py | 1 + scripts/dev/update_3rdparty.py | 2 ++ tests/conftest.py | 2 +- tests/end2end/fixtures/quteprocess.py | 2 +- tests/helpers/stubs.py | 6 +++++- tests/unit/browser/test_history.py | 2 +- tests/unit/components/test_misccommands.py | 2 +- tests/unit/extensions/test_loader.py | 2 +- tests/unit/misc/test_ipc.py | 2 +- tests/unit/misc/test_sql.py | 6 ++++-- tests/unit/utils/test_utils.py | 10 ++++++---- 14 files changed, 32 insertions(+), 17 deletions(-) diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py index bf9f80745..98eb5c8f4 100644 --- a/qutebrowser/components/misccommands.py +++ b/qutebrowser/components/misccommands.py @@ -405,6 +405,7 @@ def debug_crash(typ: str = 'exception') -> None: Args: typ: either 'exception' or 'segfault'. """ + # pylint: disable=broad-exception-raised if typ == 'segfault': os.kill(os.getpid(), signal.SIGSEGV) raise Exception("Segfault failed (wat.)") diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index c753e9de6..60d14dc79 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -330,8 +330,10 @@ def _create(path: str) -> None: for k, v in os.environ.items(): if k == 'HOME' or k.startswith('XDG_'): log.init.debug(f"{k} = {v}") - raise Exception("Trying to create directory inside /home during " - "tests, this should not happen.") + raise AssertionError( + "Trying to create directory inside /home during " + "tests, this should not happen." + ) os.makedirs(path, 0o700, exist_ok=True) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 39c730472..18658f920 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -223,7 +223,7 @@ def smoke_test(executable: pathlib.Path, debug: bool) -> None: "", ] - raise Exception("\n".join(lines)) + raise Exception("\n".join(lines)) # pylint: disable=broad-exception-raised def verify_windows_exe(exe_path: pathlib.Path) -> None: @@ -598,7 +598,7 @@ def read_github_token( if optional: return None else: - raise Exception( + raise Exception( # pylint: disable=broad-exception-raised "GitHub token needed, but ~/.gh_token not found, " "and --gh-token not given.") @@ -614,6 +614,7 @@ def github_upload(artifacts: List[Artifact], tag: str, gh_token: str) -> None: tag: The name of the release tag gh_token: The GitHub token to use """ + # pylint: disable=broad-exception-raised import github3 import github3.exceptions utils.print_title("Uploading to github...") diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 1267a278a..732b01f26 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -499,6 +499,7 @@ def _format_block(filename, what, data): what: What to change (authors, options, etc.) data; A list of strings which is the new data. """ + # pylint: disable=broad-exception-raised what = what.upper() oshandle, tmpname = tempfile.mkstemp() try: diff --git a/scripts/dev/update_3rdparty.py b/scripts/dev/update_3rdparty.py index b1991fa1f..71d7ae7b5 100755 --- a/scripts/dev/update_3rdparty.py +++ b/scripts/dev/update_3rdparty.py @@ -66,6 +66,7 @@ def download_nsis_plugins(): def find_pdfjs_asset(assets, legacy): """Find the PDF.js asset to use.""" + # pylint: disable=broad-exception-raised for asset in assets: name = asset["name"] if ( @@ -82,6 +83,7 @@ def get_latest_pdfjs_url(gh_token, legacy): Returns a (version, url)-tuple. """ + # pylint: disable=broad-exception-raised github_api = 'https://api.github.com' endpoint = 'repos/mozilla/pdf.js/releases/latest' request = urllib.request.Request(f'{github_api}/{endpoint}') diff --git a/tests/conftest.py b/tests/conftest.py index 65f76aacc..193b5bb5f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -289,7 +289,7 @@ def pytest_report_header(config): @pytest.fixture(scope='session', autouse=True) def check_display(request): if utils.is_linux and not os.environ.get('DISPLAY', ''): - raise Exception("No display and no Xvfb available!") + raise RuntimeError("No display and no Xvfb available!") @pytest.fixture(autouse=True) diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 6e47814fd..6b99d5bf0 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -523,7 +523,7 @@ class QuteProc(testprocess.Process): profile = self.request.config.getoption('--qute-profile-subprocs') if hasattr(sys, 'frozen'): if profile: - raise Exception("Can't profile with sys.frozen!") + raise RuntimeError("Can't profile with sys.frozen!") executable = str(pathlib.Path(sys.executable).parent / 'qutebrowser') args = [] else: diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 6998958b8..b71e0f3cf 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -630,6 +630,10 @@ class FakeDownloadManager: return False +class FakeHistoryTick(Exception): + pass + + class FakeHistoryProgress: """Fake for a WebHistoryProgress object.""" @@ -648,7 +652,7 @@ class FakeHistoryProgress: def tick(self): if self._raise_on_tick: - raise Exception('tick-tock') + raise FakeHistoryTick('tick-tock') self._value += 1 def finish(self): diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index 51a9effb8..268f21a08 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -471,7 +471,7 @@ class TestRebuild: # Trigger a completion rebuild monkeypatch.setattr(web_history.database, 'user_version_changed', lambda: True) - with pytest.raises(Exception, match='tick-tock'): + with pytest.raises(stubs.FakeHistoryTick, match='tick-tock'): history.WebHistory(web_history.database, progress=progress) assert web_history.metainfo['force_rebuild'] diff --git a/tests/unit/components/test_misccommands.py b/tests/unit/components/test_misccommands.py index 342b39f64..3a4118fb4 100644 --- a/tests/unit/components/test_misccommands.py +++ b/tests/unit/components/test_misccommands.py @@ -78,7 +78,7 @@ def test_debug_trace_exception(mocker): """Check that exceptions thrown by hunter.trace are handled.""" def _mock_exception(): """Side effect for testing debug_trace's reraise.""" - raise Exception('message') + raise Exception('message') # pylint: disable=broad-exception-raised hunter_mock = mocker.patch.object(misccommands, 'hunter') hunter_mock.trace.side_effect = _mock_exception diff --git a/tests/unit/extensions/test_loader.py b/tests/unit/extensions/test_loader.py index e9b8055aa..488c3edc2 100644 --- a/tests/unit/extensions/test_loader.py +++ b/tests/unit/extensions/test_loader.py @@ -91,7 +91,7 @@ class _Hook: def __call__(self, *args): if self.raising: - raise Exception("Should not be called!") + raise AssertionError("Should not be called!") self.called = True diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 51d7c6343..eea4f9bb5 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -262,7 +262,7 @@ class TestSocketName: elif utils.is_linux: pass else: - raise Exception("Unexpected platform!") + raise AssertionError("Unexpected platform!") class TestExceptions: diff --git a/tests/unit/misc/test_sql.py b/tests/unit/misc/test_sql.py index 80ab7513c..42207177e 100644 --- a/tests/unit/misc/test_sql.py +++ b/tests/unit/misc/test_sql.py @@ -406,7 +406,9 @@ class TestTransaction: with database.transaction(): my_table.insert({'column': 1}) my_table.insert({'column': 2}) - raise Exception('something went horribly wrong') - except Exception: + raise RuntimeError( + 'something went horribly wrong and the transaction will be aborted' + ) + except RuntimeError: pass assert database.query('select count(*) from my_table').run().value() == 0 diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index aa063b7c6..4f81783c2 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -425,7 +425,7 @@ class TestPreventExceptions: @utils.prevent_exceptions(42) def func_raising(self): - raise Exception + raise RuntimeError("something went wrong") def test_raising(self, caplog): """Test with a raising function.""" @@ -434,6 +434,7 @@ class TestPreventExceptions: assert ret == 42 expected = 'Error in test_utils.TestPreventExceptions.func_raising' assert caplog.messages == [expected] + assert caplog.records[0].exc_info[1].args[0] == "something went wrong" @utils.prevent_exceptions(42) def func_not_raising(self): @@ -448,7 +449,7 @@ class TestPreventExceptions: @utils.prevent_exceptions(42, True) def func_predicate_true(self): - raise Exception("its-true") + raise RuntimeError("its-true") def test_predicate_true(self, caplog): """Test with a True predicate.""" @@ -456,15 +457,16 @@ class TestPreventExceptions: ret = self.func_predicate_true() assert ret == 42 assert len(caplog.records) == 1 + assert caplog.records[0].exc_info[1].args[0] == "its-true" @utils.prevent_exceptions(42, False) def func_predicate_false(self): - raise Exception("its-false") + raise RuntimeError("its-false") def test_predicate_false(self, caplog): """Test with a False predicate.""" with caplog.at_level(logging.ERROR, 'misc'): - with pytest.raises(Exception, match="its-false"): + with pytest.raises(RuntimeError, match="its-false"): self.func_predicate_false() assert not caplog.records -- cgit v1.2.3-54-g00ecf From bbaffa3e342e223e1ea8d5572eb3c3c7c6019210 Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 6 Feb 2023 18:58:20 +1300 Subject: lint: no-else-raise Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it --- qutebrowser/browser/commands.py | 5 ++--- qutebrowser/browser/qutescheme.py | 5 ++--- qutebrowser/misc/sessions.py | 34 +++++++++++++++------------------- scripts/dev/src2asciidoc.py | 5 ++--- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 6cbfc169c..f9c4bb8e1 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1294,9 +1294,8 @@ class CommandDispatcher: was_added = bookmark_manager.add(url, title, toggle=toggle) except urlmarks.Error as e: raise cmdutils.CommandError(str(e)) - else: - msg = "Bookmarked {}" if was_added else "Removed bookmark {}" - message.info(msg.format(url.toDisplayString())) + msg = "Bookmarked {}" if was_added else "Removed bookmark {}" + message.info(msg.format(url.toDisplayString())) @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 23de022c7..6bf9fc5d7 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -563,9 +563,8 @@ def qute_pdfjs(url: QUrl) -> _HandlerRet: log.misc.warning( "pdfjs resource requested but not found: {}".format(e.path)) raise NotFoundError("Can't find pdfjs resource '{}'".format(e.path)) - else: - mimetype = utils.guess_mimetype(url.fileName(), fallback=True) - return mimetype, data + mimetype = utils.guess_mimetype(url.fileName(), fallback=True) + return mimetype, data @add_handler('warning') diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 0e0d79510..67e22c17d 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -564,19 +564,17 @@ def session_load(name: str, *, except SessionError as e: raise cmdutils.CommandError("Error while loading session: {}" .format(e)) - else: - if clear: - for win in old_windows: - win.close() - if delete: - try: - session_manager.delete(name) - except SessionError as e: - log.sessions.exception("Error while deleting session!") - raise cmdutils.CommandError("Error while deleting session: {}" - .format(e)) - else: - log.sessions.debug("Loaded & deleted session {}.".format(name)) + if clear: + for win in old_windows: + win.close() + if delete: + try: + session_manager.delete(name) + except SessionError as e: + log.sessions.exception("Error while deleting session!") + raise cmdutils.CommandError("Error while deleting session: {}" + .format(e)) + log.sessions.debug("Loaded & deleted session {}.".format(name)) @cmdutils.register() @@ -622,11 +620,10 @@ def session_save(name: ArgType = default, *, with_history=not no_history) except SessionError as e: raise cmdutils.CommandError("Error while saving session: {}".format(e)) + if quiet: + log.sessions.debug("Saved session {}.".format(name)) else: - if quiet: - log.sessions.debug("Saved session {}.".format(name)) - else: - message.info("Saved session {}.".format(name)) + message.info("Saved session {}.".format(name)) @cmdutils.register() @@ -649,8 +646,7 @@ def session_delete(name: str, *, force: bool = False) -> None: log.sessions.exception("Error while deleting session!") raise cmdutils.CommandError("Error while deleting session: {}" .format(e)) - else: - log.sessions.debug("Deleted session {}.".format(name)) + log.sessions.debug("Deleted session {}.".format(name)) def load_default(name): diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 732b01f26..2ad4dd60b 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -526,9 +526,8 @@ def _format_block(filename, what, data): except: os.remove(tmpname) raise - else: - os.remove(filename) - shutil.move(tmpname, filename) + os.remove(filename) + shutil.move(tmpname, filename) def regenerate_manpage(filename): -- cgit v1.2.3-54-g00ecf From 9ec6d449101251ada24cb0155cbf2b371a6d81ba Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 6 Feb 2023 19:13:13 +1300 Subject: lint: consider-using-augmented-assign Not a huge fan of this suggestion. I don't think it adds anything apart from a reliance on a language feature that isn't used much in this codebase. I don't want to have to explain to inexperienced devs that they have to play a bit of code golf instead of focussing on what actually matters. --- qutebrowser/config/configtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 70337b848..12a21aaeb 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1106,7 +1106,7 @@ class QtColor(BaseType): mult = 359.0 if kind == 'h' else 255.0 if val.endswith('%'): val = val[:-1] - mult = mult / 100 + mult /= 100 try: return int(float(val) * mult) -- cgit v1.2.3-54-g00ecf From ce134c96621fa23974e6ea1f2baa08b9bf48e6f8 Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 6 Feb 2023 19:20:50 +1300 Subject: lint: superfluous-parens and useless-suppression Unnecessary parens after '=' keyword --- qutebrowser/browser/browsertab.py | 2 +- tests/end2end/test_invocations.py | 6 +++--- tests/unit/browser/webengine/test_spell.py | 2 +- tests/unit/misc/test_sessions.py | 2 +- tests/unit/utils/test_standarddir.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 81915e11c..86c373a9a 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -490,7 +490,7 @@ class AbstractZoom(QObject): raise ValueError("Can't zoom to factor {}!".format(factor)) default_zoom_factor = float(config.val.zoom.default) / 100 - self._default_zoom_changed = (factor != default_zoom_factor) + self._default_zoom_changed = factor != default_zoom_factor self._zoom_factor = factor self._set_factor_internal(factor) diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index f3fdbbfba..042089859 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -204,9 +204,9 @@ def test_misconfigured_user_dirs(request, server, temp_basedir_env, home = tmp_path / 'home' home.mkdir() temp_basedir_env['HOME'] = str(home) - config_userdir_dir = (tmp_path / 'config') + config_userdir_dir = tmp_path / 'config' config_userdir_dir.mkdir(parents=True) - config_userdir_file = (tmp_path / 'config' / 'user-dirs.dirs') + config_userdir_file = tmp_path / 'config' / 'user-dirs.dirs' config_userdir_file.touch() assert temp_basedir_env['XDG_CONFIG_HOME'] == str(tmp_path / 'config') @@ -307,7 +307,7 @@ def test_webengine_download_suffix(request, quteproc_new, tmp_path): (tmp_path / 'user-dirs.dirs').write_text( 'XDG_DOWNLOAD_DIR={}'.format(download_dir)) env = {'XDG_CONFIG_HOME': str(tmp_path)} - args = (['--temp-basedir'] + _base_args(request.config)) + args = ['--temp-basedir'] + _base_args(request.config) quteproc_new.start(args, env=env) quteproc_new.set_setting('downloads.location.prompt', 'false') diff --git a/tests/unit/browser/webengine/test_spell.py b/tests/unit/browser/webengine/test_spell.py index 2218b5c31..859f4209b 100644 --- a/tests/unit/browser/webengine/test_spell.py +++ b/tests/unit/browser/webengine/test_spell.py @@ -34,7 +34,7 @@ def test_version(message_mock, caplog): with caplog.at_level(logging.WARNING): assert spell.version('malformed_filename') is None msg = message_mock.getmsg(usertypes.MessageLevel.warning) - expected = ("Found a dictionary with a malformed name: malformed_filename") + expected = "Found a dictionary with a malformed name: malformed_filename" assert msg.text == expected diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py index f77982e5f..ecd04572a 100644 --- a/tests/unit/misc/test_sessions.py +++ b/tests/unit/misc/test_sessions.py @@ -286,7 +286,7 @@ class FakeWebView: def load_history(self, data): self.loaded_history = data if self.raise_error is not None: - raise self.raise_error # pylint: disable=raising-bad-type + raise self.raise_error @pytest.fixture diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py index 0ca635ae2..dcb863d1d 100644 --- a/tests/unit/utils/test_standarddir.py +++ b/tests/unit/utils/test_standarddir.py @@ -281,7 +281,7 @@ class TestArguments: def test_basedir_relative(self, tmpdir): """Test --basedir with a relative path.""" - basedir = (tmpdir / 'basedir') + basedir = tmpdir / 'basedir' basedir.ensure(dir=True) with tmpdir.as_cwd(): args = types.SimpleNamespace(basedir='basedir') -- cgit v1.2.3-54-g00ecf From 86f7554a7acc4beac6fbb5973e49454c010ebb81 Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 6 Feb 2023 19:28:10 +1300 Subject: lint: pointless-exception-statement It does actually raise an AssertionError as a side effect --- tests/unit/config/test_configexc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/config/test_configexc.py b/tests/unit/config/test_configexc.py index b289d3cc8..ad09338ea 100644 --- a/tests/unit/config/test_configexc.py +++ b/tests/unit/config/test_configexc.py @@ -59,7 +59,7 @@ def test_no_option_error(deleted, renamed, all_names, expected): def test_no_option_error_clash(): with pytest.raises(AssertionError): - configexc.NoOptionError('opt', deleted=True, renamed='foo') + _ = configexc.NoOptionError('opt', deleted=True, renamed='foo') def test_no_autoconfig_error(): -- cgit v1.2.3-54-g00ecf From 2c4f6625139424e36045f219626c18baef5a90da Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 6 Feb 2023 11:44:13 +0100 Subject: pylint: Enable new extensions See https://pylint.pycqa.org/en/latest/whatsnew/2/2.16/index.html#extensions --- .pylintrc | 2 ++ tests/unit/browser/webkit/test_mhtml.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 47d3a163d..225021f38 100644 --- a/.pylintrc +++ b/.pylintrc @@ -16,6 +16,8 @@ load-plugins=qute_pylint.config, pylint.extensions.typing, pylint.extensions.docparams, pylint.extensions.private_import, + pylint.extensions.dict_init_mutate, + pylint.extensions.dunder persistent=n py-version=3.7 diff --git a/tests/unit/browser/webkit/test_mhtml.py b/tests/unit/browser/webkit/test_mhtml.py index dabffeb78..2570850ea 100644 --- a/tests/unit/browser/webkit/test_mhtml.py +++ b/tests/unit/browser/webkit/test_mhtml.py @@ -94,8 +94,8 @@ def test_refuses_non_ascii_header_value(checker, header, value): 'root_content': b'', 'content_location': 'http://example.com', 'content_type': 'text/plain', + header: value, } - defaults[header] = value writer = mhtml.MHTMLWriter(**defaults) with pytest.raises(UnicodeEncodeError, match="'ascii' codec can't encode"): writer.write_to(checker.fp) -- cgit v1.2.3-54-g00ecf