From bb29ce88f322542589a9f60730d668ed3481a5c5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 11 Feb 2021 09:37:38 +1000 Subject: [PATCH] minor code cleanups with pyupgrade - pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format - third-party mpv and winpaths excluded --- pylib/anki/__init__.py | 1 - pylib/anki/_backend/genbackend.py | 2 +- pylib/anki/decks.py | 2 +- pylib/anki/exporting.py | 2 +- pylib/anki/httpclient.py | 2 +- pylib/anki/importing/anki2.py | 4 ++-- pylib/anki/importing/csvfile.py | 2 +- pylib/anki/importing/supermemo_xml.py | 17 ++++++----------- pylib/anki/models.py | 2 +- pylib/anki/utils.py | 2 +- qt/aqt/about.py | 1 - qt/aqt/addcards.py | 1 - qt/aqt/addons.py | 9 +++------ qt/aqt/browser.py | 3 +-- qt/aqt/customstudy.py | 1 - qt/aqt/deckbrowser.py | 1 - qt/aqt/deckchooser.py | 1 - qt/aqt/deckconf.py | 1 - qt/aqt/dyndeckconf.py | 1 - qt/aqt/editcurrent.py | 1 - qt/aqt/editor.py | 7 +++---- qt/aqt/errors.py | 1 - qt/aqt/exporting.py | 4 ++-- qt/aqt/importing.py | 1 - qt/aqt/legacy.py | 1 - qt/aqt/main.py | 5 ++--- qt/aqt/mediasrv.py | 1 - qt/aqt/modelchooser.py | 1 - qt/aqt/overview.py | 1 - qt/aqt/preferences.py | 1 - qt/aqt/progress.py | 1 - qt/aqt/reviewer.py | 1 - qt/aqt/sidebar.py | 1 - qt/aqt/stats.py | 1 - qt/aqt/studydeck.py | 1 - qt/aqt/theme.py | 1 - qt/aqt/toolbar.py | 1 - qt/aqt/tts.py | 4 +++- qt/aqt/utils.py | 3 +-- qt/aqt/webview.py | 3 +-- 40 files changed, 31 insertions(+), 65 deletions(-) diff --git a/pylib/anki/__init__.py b/pylib/anki/__init__.py index eeb1538dd..d958c513c 100644 --- a/pylib/anki/__init__.py +++ b/pylib/anki/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html diff --git a/pylib/anki/_backend/genbackend.py b/pylib/anki/_backend/genbackend.py index f8d60ee51..808c31689 100755 --- a/pylib/anki/_backend/genbackend.py +++ b/pylib/anki/_backend/genbackend.py @@ -77,7 +77,7 @@ def fullname(fullname): def fix_snakecase(name): for fix in "a_v", "i_d": name = re.sub( - f"(\w)({fix})(\w)", + fr"(\w)({fix})(\w)", lambda m: m.group(1) + m.group(2).replace("_", "") + m.group(3), name, ) diff --git a/pylib/anki/decks.py b/pylib/anki/decks.py index 5242b23ab..fdbe4d892 100644 --- a/pylib/anki/decks.py +++ b/pylib/anki/decks.py @@ -547,7 +547,7 @@ class DeckManager: return parents def nameMap(self) -> Dict[str, Deck]: - return dict((d["name"], d) for d in self.all()) + return {d["name"]: d for d in self.all()} # Dynamic decks ########################################################################## diff --git a/pylib/anki/exporting.py b/pylib/anki/exporting.py index 13c66cdda..269839a14 100644 --- a/pylib/anki/exporting.py +++ b/pylib/anki/exporting.py @@ -199,7 +199,7 @@ class AnkiExporter(Exporter): # create a new collection at the target try: os.unlink(path) - except (IOError, OSError): + except OSError: pass self.dst = Collection(path) self.src = self.col diff --git a/pylib/anki/httpclient.py b/pylib/anki/httpclient.py index b169fc2d2..55ca971b6 100644 --- a/pylib/anki/httpclient.py +++ b/pylib/anki/httpclient.py @@ -78,7 +78,7 @@ class HttpClient: def _agentName(self) -> str: from anki import version - return "Anki {}".format(version) + return f"Anki {version}" # allow user to accept invalid certs in work/school settings diff --git a/pylib/anki/importing/anki2.py b/pylib/anki/importing/anki2.py index f66c90d87..c0de3e3a0 100644 --- a/pylib/anki/importing/anki2.py +++ b/pylib/anki/importing/anki2.py @@ -409,7 +409,7 @@ insert or ignore into revlog values (?,?,?,?,?,?,?,?,?)""", try: with open(path, "rb") as f: return f.read() - except (IOError, OSError): + except OSError: return b"" def _srcMediaData(self, fname: str) -> bytes: @@ -425,7 +425,7 @@ insert or ignore into revlog values (?,?,?,?,?,?,?,?,?)""", try: with open(path, "wb") as f: f.write(data) - except (OSError, IOError): + except OSError: # the user likely used subdirectories pass diff --git a/pylib/anki/importing/csvfile.py b/pylib/anki/importing/csvfile.py index 081553f18..bcf3b5fe9 100644 --- a/pylib/anki/importing/csvfile.py +++ b/pylib/anki/importing/csvfile.py @@ -71,7 +71,7 @@ class TextImporter(NoteImporter): def openFile(self) -> None: self.dialect = None - self.fileobj = open(self.file, "r", encoding="utf-8-sig") + self.fileobj = open(self.file, encoding="utf-8-sig") self.data = self.fileobj.read() def sub(s): diff --git a/pylib/anki/importing/supermemo_xml.py b/pylib/anki/importing/supermemo_xml.py index 48fc4021d..0e71a3711 100644 --- a/pylib/anki/importing/supermemo_xml.py +++ b/pylib/anki/importing/supermemo_xml.py @@ -258,16 +258,11 @@ class SupermemoXmlImporter(NoteImporter): # clean whitespaces # set Capital letters for first char of the word tmp = list( - set( - [ - re.sub(r"(\[[0-9]+\])", " ", i).replace("_", " ") - for i in item.lTitle - ] - ) + {re.sub(r"(\[[0-9]+\])", " ", i).replace("_", " ") for i in item.lTitle} ) - tmp = list(set([re.sub(r"(\W)", " ", i) for i in tmp])) - tmp = list(set([re.sub("^[0-9 ]+$", "", i) for i in tmp])) - tmp = list(set([capwords(i).replace(" ", "") for i in tmp])) + tmp = list({re.sub(r"(\W)", " ", i) for i in tmp}) + tmp = list({re.sub("^[0-9 ]+$", "", i) for i in tmp}) + tmp = list({capwords(i).replace(" ", "") for i in tmp}) tags = [j[0].lower() + j[1:] for j in tmp if j.strip() != ""] note.tags += tags @@ -310,13 +305,13 @@ class SupermemoXmlImporter(NoteImporter): try: return urllib.request.urlopen(source) - except (IOError, OSError): + except OSError: pass # try to open with native open function (if source is pathname) try: return open(source) - except (IOError, OSError): + except OSError: pass # treat source as string diff --git a/pylib/anki/models.py b/pylib/anki/models.py index 363d12cc1..e85641032 100644 --- a/pylib/anki/models.py +++ b/pylib/anki/models.py @@ -287,7 +287,7 @@ class ModelManager: def fieldMap(self, m: NoteType) -> Dict[str, Tuple[int, Field]]: "Mapping of field name -> (ord, field)." - return dict((f["name"], (f["ord"], f)) for f in m["flds"]) + return {f["name"]: (f["ord"], f) for f in m["flds"]} def fieldNames(self, m: NoteType) -> List[str]: return [f["name"] for f in m["flds"]] diff --git a/pylib/anki/utils.py b/pylib/anki/utils.py index 3e7e5feda..69853de7b 100644 --- a/pylib/anki/utils.py +++ b/pylib/anki/utils.py @@ -243,7 +243,7 @@ def namedtmp(name: str, rm: bool = True) -> str: if rm: try: os.unlink(path) - except (OSError, IOError): + except OSError: pass return path diff --git a/qt/aqt/about.py b/qt/aqt/about.py index 871e186dc..0948f4473 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import platform import time diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index 20263e315..546e5f739 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from typing import Any, Callable, List, Optional diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index 8b319bf72..bb208bb85 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations @@ -819,7 +818,7 @@ class AddonsDialog(QDialog): if not addon: return if re.match(r"^\d+$", addon): - openLink(aqt.appShared + "info/{}".format(addon)) + openLink(aqt.appShared + f"info/{addon}") else: showWarning(tr(TR.ADDONS_ADDON_WAS_NOT_DOWNLOADED_FROM_ANKIWEB)) @@ -865,7 +864,7 @@ class AddonsDialog(QDialog): def onInstallFiles(self, paths: Optional[List[str]] = None) -> Optional[bool]: if not paths: - key = tr(TR.ADDONS_PACKAGED_ANKI_ADDON) + " (*{})".format(self.mgr.ext) + key = tr(TR.ADDONS_PACKAGED_ANKI_ADDON) + f" (*{self.mgr.ext})" paths_ = getFile( self, tr(TR.ADDONS_INSTALL_ADDONS), None, key, key="addons", multi=True ) @@ -1158,9 +1157,7 @@ def _fetch_update_info_batch( if resp.status_code == 200: return resp.json() else: - raise Exception( - "Unexpected response code from AnkiWeb: {}".format(resp.status_code) - ) + raise Exception(f"Unexpected response code from AnkiWeb: {resp.status_code}") def check_and_prompt_for_updates( diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index cc0564681..b293c44f1 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations @@ -222,7 +221,7 @@ class DataModel(QAbstractTableModel): def saveSelection(self) -> None: cards = self.browser.selectedCards() - self.selectedCards = dict([(id, True) for id in cards]) + self.selectedCards = {id: True for id in cards} if getattr(self.browser, "card", None): self.focusedCard = self.browser.card.id else: diff --git a/qt/aqt/customstudy.py b/qt/aqt/customstudy.py index 94468cb8b..8dade1388 100644 --- a/qt/aqt/customstudy.py +++ b/qt/aqt/customstudy.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import aqt diff --git a/qt/aqt/deckbrowser.py b/qt/aqt/deckbrowser.py index 5e5e13da1..4cb0ae697 100644 --- a/qt/aqt/deckbrowser.py +++ b/qt/aqt/deckbrowser.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/deckchooser.py b/qt/aqt/deckchooser.py index d1097981e..d7f806c4a 100644 --- a/qt/aqt/deckchooser.py +++ b/qt/aqt/deckchooser.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from typing import Any diff --git a/qt/aqt/deckconf.py b/qt/aqt/deckconf.py index 1441b68c0..449886017 100644 --- a/qt/aqt/deckconf.py +++ b/qt/aqt/deckconf.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from operator import itemgetter from typing import Any, Dict, List, Optional diff --git a/qt/aqt/dyndeckconf.py b/qt/aqt/dyndeckconf.py index d1df7eaf7..0904f58ca 100644 --- a/qt/aqt/dyndeckconf.py +++ b/qt/aqt/dyndeckconf.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from typing import Callable, List, Optional diff --git a/qt/aqt/editcurrent.py b/qt/aqt/editcurrent.py index 5af66f972..2c3832663 100644 --- a/qt/aqt/editcurrent.py +++ b/qt/aqt/editcurrent.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import aqt.editor from aqt import gui_hooks diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 2f59286bf..cd37a25ed 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import base64 @@ -310,8 +309,8 @@ class Editor: elif os.path.isabs(icon): iconstr = self.resourceToData(icon) else: - iconstr = "/_anki/imgs/{}.png".format(icon) - imgelm = """""".format(iconstr) + iconstr = f"/_anki/imgs/{icon}.png" + imgelm = f"""""" else: imgelm = "" if label or not imgelm: @@ -319,7 +318,7 @@ class Editor: else: labelelm = "" if id: - idstr = "id={}".format(id) + idstr = f"id={id}" else: idstr = "" if toggleable: diff --git a/qt/aqt/errors.py b/qt/aqt/errors.py index 7baa7cbb8..fc40eaa3e 100644 --- a/qt/aqt/errors.py +++ b/qt/aqt/errors.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import html import re diff --git a/qt/aqt/exporting.py b/qt/aqt/exporting.py index deddc153d..e1990f789 100644 --- a/qt/aqt/exporting.py +++ b/qt/aqt/exporting.py @@ -121,7 +121,7 @@ class ExportDialog(QDialog): deck_name = self.decks[self.frm.deck.currentIndex()] deck_name = re.sub('[\\\\/?<>:*|"^]', "_", deck_name) - filename = "{0}{1}".format(deck_name, self.exporter.ext) + filename = f"{deck_name}{self.exporter.ext}" if callable(self.exporter.key): key_str = self.exporter.key(self.col) else: @@ -149,7 +149,7 @@ class ExportDialog(QDialog): try: f = open(file, "wb") f.close() - except (OSError, IOError) as e: + except OSError as e: showWarning(tr(TR.EXPORTING_COULDNT_SAVE_FILE, val=str(e))) else: os.unlink(file) diff --git a/qt/aqt/importing.py b/qt/aqt/importing.py index f10873824..99db0bda7 100644 --- a/qt/aqt/importing.py +++ b/qt/aqt/importing.py @@ -1,4 +1,3 @@ -# coding=utf-8 # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import json diff --git a/qt/aqt/legacy.py b/qt/aqt/legacy.py index b4de60809..8be89c6c0 100644 --- a/qt/aqt/legacy.py +++ b/qt/aqt/legacy.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html """ diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 5f54d7610..a774b1064 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations @@ -446,7 +445,7 @@ class AnkiQt(QMainWindow): if getattr(w, "silentlyClose", None): w.close() else: - print("Window should have been closed: {}".format(w)) + print(f"Window should have been closed: {w}") def unloadProfileAndExit(self) -> None: self.unloadProfile(self.cleanupAndExit) @@ -1447,7 +1446,7 @@ title="%s" %s>%s""" % ( line = cursor.selectedText() pfx, sfx = "pp(", ")" if not line.startswith(pfx): - line = "{}{}{}".format(pfx, line, sfx) + line = f"{pfx}{line}{sfx}" cursor.insertText(line) cursor.setPosition(position + len(pfx)) frm.text.setTextCursor(cursor) diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 8b9e9602c..923200062 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/modelchooser.py b/qt/aqt/modelchooser.py index 8a9bcf84b..cf86deb0e 100644 --- a/qt/aqt/modelchooser.py +++ b/qt/aqt/modelchooser.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from typing import List, Optional diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index eb6c4925a..949c2e8c1 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index b958d47b8..062e92e62 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import anki.lang diff --git a/qt/aqt/progress.py b/qt/aqt/progress.py index 94f99a408..098f64d85 100644 --- a/qt/aqt/progress.py +++ b/qt/aqt/progress.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index 253503e36..69b692eb7 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/sidebar.py b/qt/aqt/sidebar.py index bd7443cb3..da4fed791 100644 --- a/qt/aqt/sidebar.py +++ b/qt/aqt/sidebar.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html diff --git a/qt/aqt/stats.py b/qt/aqt/stats.py index c375beea5..094f293fd 100644 --- a/qt/aqt/stats.py +++ b/qt/aqt/stats.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/studydeck.py b/qt/aqt/studydeck.py index 277465071..4d3327768 100644 --- a/qt/aqt/studydeck.py +++ b/qt/aqt/studydeck.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from typing import List, Optional diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index c5047f52c..7362f6b7c 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html diff --git a/qt/aqt/toolbar.py b/qt/aqt/toolbar.py index 8bc71904d..5e3c7505b 100644 --- a/qt/aqt/toolbar.py +++ b/qt/aqt/toolbar.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations diff --git a/qt/aqt/tts.py b/qt/aqt/tts.py index 7b1bd4f0f..5f5afe74f 100644 --- a/qt/aqt/tts.py +++ b/qt/aqt/tts.py @@ -570,7 +570,9 @@ if isWin: ret.result() except RuntimeError: # fixme: i18n if this turns out to happen frequently - tooltip("TTS failed to play. Please check available languages in system settings.") + tooltip( + "TTS failed to play. Please check available languages in system settings." + ) return # inject file into the top of the audio queue diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index a0d31ca8d..7eba24109 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations @@ -531,7 +530,7 @@ def getSaveFile( parent, title, path, - "{0} (*{1})".format(key, ext), + f"{key} (*{ext})", options=QFileDialog.DontConfirmOverwrite, )[0] if file: diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index e64fe4050..e905e10a1 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -1,5 +1,4 @@ # Copyright: Ankitects Pty Ltd and contributors -# -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import dataclasses import json @@ -543,7 +542,7 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }} elif name == "setHtml": self._setHtml(*args) else: - raise Exception("unknown action: {}".format(name)) + raise Exception(f"unknown action: {name}") def _openLinksExternally(self, url: str) -> None: openLink(url)