From 8b8f117e70571ca890356b04737de715406edcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 28 Jul 2024 23:29:11 +0800 Subject: [PATCH] or --- LunaTranslator/LunaTranslator/LunaTranslator.py | 4 +--- LunaTranslator/LunaTranslator/gui/textbrowser.py | 2 +- LunaTranslator/LunaTranslator/gui/usefulwidget.py | 2 +- LunaTranslator/LunaTranslator/myutils/config.py | 2 +- LunaTranslator/LunaTranslator/requests.py | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 97f47315..e3e7b5f8 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -1085,9 +1085,7 @@ class MAINUI: == Qt.WindowType.FramelessWindowHint ): return - if isinstance(widget, QMenu): - return - if isinstance(widget, QFrame): + if isinstance(widget, (QMenu, QFrame)): return if ( isinstance(widget, QWidget) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index deca5bbe..393450e0 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -37,7 +37,7 @@ class Textbrowser(QLabel): "错误", "can't find Webview2 runtime!", ) - elif isinstance(e, ImportError) or isinstance(e, ModuleNotFoundError): + elif isinstance(e, (ImportError, ModuleNotFoundError)): getQMessageBox( None, "错误", diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 1e5f51ac..7beb231c 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -1392,7 +1392,7 @@ def makeforms(lay: LFormLayout, lis, args): name, wid = None, line[0] else: name, wid = line - if isinstance(wid, tuple) or isinstance(wid, list): + if isinstance(wid, (tuple, list)): hb = QHBoxLayout() hb.setContentsMargins(0, 0, 0, 0) if Stretch: diff --git a/LunaTranslator/LunaTranslator/myutils/config.py b/LunaTranslator/LunaTranslator/myutils/config.py index 95263af8..b94c10d4 100644 --- a/LunaTranslator/LunaTranslator/myutils/config.py +++ b/LunaTranslator/LunaTranslator/myutils/config.py @@ -220,7 +220,7 @@ for uid in savehook_new_data: for k in _dfsavehook: if k not in savehook_new_data[uid]: __v = _dfsavehook[k] - if isinstance(_dfsavehook[k], list) or isinstance(_dfsavehook[k], dict): + if isinstance(_dfsavehook[k], (list, dict)): __v = __v.copy() savehook_new_data[uid][k] = __v diff --git a/LunaTranslator/LunaTranslator/requests.py b/LunaTranslator/LunaTranslator/requests.py index 6432ec2f..5049ee18 100644 --- a/LunaTranslator/LunaTranslator/requests.py +++ b/LunaTranslator/LunaTranslator/requests.py @@ -321,7 +321,7 @@ class Requester_common: disposition = b'Content-Disposition: form-data; name="' disposition += name.encode("utf8") disposition += b'"' - if isinstance(data, tuple) or isinstance(data, list): + if isinstance(data, (tuple, list)): if len(data) == 3: filename, data, type_ = data elif len(data) == 2: