diff --git a/pylib/anki/_backend.py b/pylib/anki/_backend.py index a0d8f8949..583eaa55d 100644 --- a/pylib/anki/_backend.py +++ b/pylib/anki/_backend.py @@ -164,7 +164,7 @@ class RustBackend(RustBackendGenerated): finally: elapsed = time.time() - start if current_thread() is main_thread() and elapsed > 0.2: - print(f"blocked main thread for {int(elapsed*1000)}ms:") + print(f"blocked main thread for {int(elapsed * 1000)}ms:") print("".join(traceback.format_stack())) err = backend_pb2.BackendError() diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 6cf38174c..c0192c782 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -867,7 +867,9 @@ class Collection(DeprecatedNamesMixin): return column return None - def browser_row_for_id(self, id_: int) -> tuple[ + def browser_row_for_id( + self, id_: int + ) -> tuple[ Generator[tuple[str, bool, BrowserRow.Cell.TextElideMode.V], None, None], BrowserRow.Color.V, str, diff --git a/pylib/anki/lang.py b/pylib/anki/lang.py index a0a6bf757..f20eddf3e 100644 --- a/pylib/anki/lang.py +++ b/pylib/anki/lang.py @@ -198,9 +198,7 @@ def get_def_lang(user_lang: str | None = None) -> tuple[int, str]: # getdefaultlocale() is deprecated since Python 3.11, but we need to keep using it as getlocale() behaves differently: https://bugs.python.org/issue38805 with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) - (sys_lang, enc) = ( - locale.getdefaultlocale() # pylint: disable=deprecated-method - ) + (sys_lang, enc) = locale.getdefaultlocale() # pylint: disable=deprecated-method except AttributeError: # this will return a different format on Windows (e.g. Italian_Italy), resulting in us falling back to en_US # further below diff --git a/pylib/anki/stats.py b/pylib/anki/stats.py index e6ca1cb97..14e8f050c 100644 --- a/pylib/anki/stats.py +++ b/pylib/anki/stats.py @@ -27,7 +27,7 @@ def _legacy_card_stats( col: anki.collection.Collection, card_id: anki.cards.CardId, include_revlog: bool ) -> str: "A quick hack to preserve compatibility with the old HTML string API." - random_id = f"cardinfo-{base62(random.randint(0, 2 ** 64 - 1))}" + random_id = f"cardinfo-{base62(random.randint(0, 2**64 - 1))}" varName = random_id.replace("-", "") return f"""
diff --git a/pylib/tests/test_find.py b/pylib/tests/test_find.py index d9c2c1f87..236096572 100644 --- a/pylib/tests/test_find.py +++ b/pylib/tests/test_find.py @@ -169,8 +169,7 @@ def test_find_cards(): # properties id = col.db.scalar("select id from cards limit 1") col.db.execute( - "update cards set queue=2, ivl=10, reps=20, due=30, factor=2200 " - "where id = ?", + "update cards set queue=2, ivl=10, reps=20, due=30, factor=2200 where id = ?", id, ) assert len(col.find_cards("prop:ivl>5")) == 1 diff --git a/pylib/tests/test_schedv3.py b/pylib/tests/test_schedv3.py index 0deff7bf9..6e6025372 100644 --- a/pylib/tests/test_schedv3.py +++ b/pylib/tests/test_schedv3.py @@ -554,9 +554,7 @@ def test_bury(): col.sched.bury_cards([c.id], manual=True) # pylint: disable=unexpected-keyword-arg c.load() assert c.queue == QUEUE_TYPE_MANUALLY_BURIED - col.sched.bury_cards( - [c2.id], manual=False - ) # pylint: disable=unexpected-keyword-arg + col.sched.bury_cards([c2.id], manual=False) # pylint: disable=unexpected-keyword-arg c2.load() assert c2.queue == QUEUE_TYPE_SIBLING_BURIED diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index 7f375560e..172ec2a2c 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -286,7 +286,6 @@ class NativeEventFilter(QAbstractNativeEventFilter): def nativeEventFilter( self, eventType: Any, message: Any ) -> tuple[bool, Any | None]: - if eventType == "windows_generic_MSG": import ctypes.wintypes diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index c48154112..a940fb208 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -1456,7 +1456,9 @@ class ChooseAddonsToUpdateDialog(QDialog): layout.addWidget(addons_list_widget) self.addons_list_widget = addons_list_widget - button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) # type: ignore + button_box = QDialogButtonBox( + QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel + ) # type: ignore qconnect( button_box.button(QDialogButtonBox.StandardButton.Ok).clicked, self.accept ) diff --git a/qt/aqt/ankihub.py b/qt/aqt/ankihub.py index 4d3b00c8a..0ea9b6dac 100644 --- a/qt/aqt/ankihub.py +++ b/qt/aqt/ankihub.py @@ -36,7 +36,6 @@ def ankihub_login( username: str = "", password: str = "", ) -> None: - def on_future_done(fut: Future[str], username: str, password: str) -> None: try: token = fut.result() @@ -73,7 +72,6 @@ def ankihub_logout( on_success: Callable[[], None], token: str, ) -> None: - def logout() -> None: mw.pm.set_ankihub_username(None) mw.pm.set_ankihub_token(None) diff --git a/qt/aqt/clayout.py b/qt/aqt/clayout.py index 388ae46c0..3daa5352a 100644 --- a/qt/aqt/clayout.py +++ b/qt/aqt/clayout.py @@ -221,7 +221,7 @@ class CardLayout(QDialog): ) for i in range(min(len(self.cloze_numbers), 9)): QShortcut( # type: ignore - QKeySequence(f"Alt+{i+1}"), + QKeySequence(f"Alt+{i + 1}"), self, activated=lambda n=i: self.pform.cloze_number_combo.setCurrentIndex(n), ) diff --git a/qt/aqt/deckbrowser.py b/qt/aqt/deckbrowser.py index 77bd84220..5dc688155 100644 --- a/qt/aqt/deckbrowser.py +++ b/qt/aqt/deckbrowser.py @@ -386,9 +386,7 @@ class DeckBrowser: if b[0]: b[0] = tr.actions_shortcut_key(val=shortcut(b[0])) buf += """ -""" % tuple( - b - ) +""" % tuple(b) self.bottom.draw( buf=buf, link_handler=self._linkHandler, diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 03be93ac2..82432a18b 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -450,7 +450,6 @@ class AnkiQt(QMainWindow): self.loadProfile() def onOpenBackup(self) -> None: - def do_open(path: str) -> None: if not askUser( tr.qt_misc_replace_your_collection_with_an_earlier2( diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 69ef054ec..c6e53f997 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -230,7 +230,11 @@ def _handle_local_file_request(request: LocalFileRequest) -> Response: else: max_age = 60 * 60 return flask.send_file( - fullpath, mimetype=mimetype, conditional=True, max_age=max_age, download_name="foo" # type: ignore[call-arg] + fullpath, + mimetype=mimetype, + conditional=True, + max_age=max_age, + download_name="foo", # type: ignore[call-arg] ) else: print(f"Not found: {path}") diff --git a/qt/aqt/mpv.py b/qt/aqt/mpv.py index e86675e41..389d37cbf 100644 --- a/qt/aqt/mpv.py +++ b/qt/aqt/mpv.py @@ -138,9 +138,9 @@ class MPVBase: extended_info = win32job.QueryInformationJobObject( self._job, win32job.JobObjectExtendedLimitInformation ) - extended_info["BasicLimitInformation"][ - "LimitFlags" - ] = win32job.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE + extended_info["BasicLimitInformation"]["LimitFlags"] = ( + win32job.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE + ) win32job.SetInformationJobObject( self._job, win32job.JobObjectExtendedLimitInformation, @@ -193,7 +193,10 @@ class MPVBase: None, ) win32pipe.SetNamedPipeHandleState( - self._sock, 1, None, None # PIPE_NOWAIT + self._sock, + 1, + None, + None, # PIPE_NOWAIT ) except pywintypes.error as err: if err.args[0] == winerror.ERROR_FILE_NOT_FOUND: diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index 68dc0de96..bbdbde3a6 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -307,9 +307,7 @@ class Overview: if b[0]: b[0] = tr.actions_shortcut_key(val=shortcut(b[0])) buf += """ -""" % tuple( - b - ) +""" % tuple(b) self.bottom.draw( buf=buf, link_handler=link_handler, diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index aba7b4f04..9ceeb713c 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -483,7 +483,11 @@ create table if not exists profiles code = obj[1] name = obj[0] r = QMessageBox.question( - None, "Anki", tr.profiles_confirm_lang_choice(lang=name), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, QMessageBox.StandardButton.No # type: ignore + None, + "Anki", + tr.profiles_confirm_lang_choice(lang=name), + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, # type: ignore ) if r != QMessageBox.StandardButton.Yes: return self.setDefaultLang(f.lang.currentRow()) diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index 6e34a7931..c35e9b1ca 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -597,10 +597,9 @@ class Reviewer: def _shortcutKeys( self, ) -> Sequence[tuple[str, Callable] | tuple[Qt.Key, Callable]]: - - def generate_default_answer_keys() -> ( - Generator[tuple[str, partial], None, None] - ): + def generate_default_answer_keys() -> Generator[ + tuple[str, partial], None, None + ]: for ease in aqt.mw.pm.default_answer_keys: key = aqt.mw.pm.get_answer_key(ease) if not key: diff --git a/qt/aqt/stylesheets.py b/qt/aqt/stylesheets.py index 0721e76d2..a262e18b9 100644 --- a/qt/aqt/stylesheets.py +++ b/qt/aqt/stylesheets.py @@ -208,7 +208,7 @@ class CustomStyles: button_pressed_gradient( tm.var(colors.BUTTON_GRADIENT_START), tm.var(colors.BUTTON_GRADIENT_END), - tm.var(colors.SHADOW) + tm.var(colors.SHADOW), ) }; }} @@ -340,7 +340,7 @@ class CustomStyles: }} QTabBar::tab:selected:hover {{ background: { - button_gradient( + button_gradient( tm.var(colors.BUTTON_PRIMARY_GRADIENT_START), tm.var(colors.BUTTON_PRIMARY_GRADIENT_END), ) @@ -391,7 +391,7 @@ class CustomStyles: button_pressed_gradient( tm.var(colors.BUTTON_GRADIENT_START), tm.var(colors.BUTTON_GRADIENT_END), - tm.var(colors.SHADOW) + tm.var(colors.SHADOW), ) } }} @@ -647,10 +647,12 @@ class CustomStyles: margin: -7px 0; }} QSlider::handle:hover {{ - background: {button_gradient( - tm.var(colors.BUTTON_GRADIENT_START), - tm.var(colors.BUTTON_GRADIENT_END), - )} + background: { + button_gradient( + tm.var(colors.BUTTON_GRADIENT_START), + tm.var(colors.BUTTON_GRADIENT_END), + ) + } }} """ diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 5a4d5fd4c..c562a235d 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -302,7 +302,6 @@ def sync_login( username: str = "", password: str = "", ) -> None: - def on_future_done(fut: Future[SyncAuth], username: str, password: str) -> None: try: auth = fut.result() @@ -374,7 +373,9 @@ def get_id_and_pass_from_user( g.addWidget(passwd, 1, 1) l2.setBuddy(passwd) vbox.addLayout(g) - bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) # type: ignore + bb = QDialogButtonBox( + QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel + ) # type: ignore ok_button = bb.button(QDialogButtonBox.StandardButton.Ok) assert ok_button is not None ok_button.setAutoDefault(True) diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index 967f4f28c..48fa00ab8 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -187,7 +187,7 @@ class ThemeManager: self, card_ord: int, night_mode: bool | None = None ) -> str: "Returns body classes used when showing a card." - return f"card card{card_ord+1} {self.body_class(night_mode, reviewer=True)}" + return f"card card{card_ord + 1} {self.body_class(night_mode, reviewer=True)}" def var(self, vars: dict[str, str]) -> str: """Given day/night colors/props, return the correct one for the current theme.""" diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 966d3de5a..95d84c00e 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -980,7 +980,6 @@ def _create_ankiwebview_subclass( /, **fixed_kwargs: Unpack[_AnkiWebViewKwargs], ) -> Type[AnkiWebView]: - def __init__(self, *args: Any, **kwargs: _AnkiWebViewKwargs) -> None: # user‑supplied kwargs override fixed kwargs merged = cast(_AnkiWebViewKwargs, {**fixed_kwargs, **kwargs})