From e80b3eeeef35f6f9095facb613e0e141578af946 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 29 Aug 2020 22:00:28 +1000 Subject: [PATCH] fix some lints --- qt/aqt/gui_hooks.py | 10 +++++----- qt/aqt/overview.py | 2 -- qt/aqt/webview.py | 6 +++++- qt/tools/genhooks_gui.py | 5 +++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/qt/aqt/gui_hooks.py b/qt/aqt/gui_hooks.py index 157bd3e80..2386341fc 100644 --- a/qt/aqt/gui_hooks.py +++ b/qt/aqt/gui_hooks.py @@ -2866,20 +2866,20 @@ def mytest(web: AnkiWebView): gui_hooks.webview_did_inject_style_into_page.append(mytest) ''' - _hooks: List[Callable[[AnkiWebView], None]] = [] + _hooks: List[Callable[["aqt.webview.AnkiWebView"], None]] = [] - def append(self, cb: Callable[[AnkiWebView], None]) -> None: - """(webview: AnkiWebView)""" + def append(self, cb: Callable[["aqt.webview.AnkiWebView"], None]) -> None: + """(webview: aqt.webview.AnkiWebView)""" self._hooks.append(cb) - def remove(self, cb: Callable[[AnkiWebView], None]) -> None: + def remove(self, cb: Callable[["aqt.webview.AnkiWebView"], None]) -> None: if cb in self._hooks: self._hooks.remove(cb) def count(self) -> int: return len(self._hooks) - def __call__(self, webview: AnkiWebView) -> None: + def __call__(self, webview: aqt.webview.AnkiWebView) -> None: for hook in self._hooks: try: hook(webview) diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index 0d5430008..58f49c005 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -10,9 +10,7 @@ from typing import Optional import aqt from anki.lang import _ from aqt import gui_hooks -from aqt.qt import QUrl from aqt.sound import av_player -from aqt.theme import theme_manager from aqt.toolbar import BottomBar from aqt.utils import askUserDialog, openLink, shortcut, tooltip diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index bf2933642..b81b24315 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -598,15 +598,19 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }} def inject_dynamic_style_and_show(self): "Add dynamic styling, and reveal." css = self.standard_css() + def after_style(arg): gui_hooks.webview_did_inject_style_into_page(self) self.show() + self.evalWithCallback( f""" const style = document.createElement('style'); style.innerHTML = `{css}`; document.head.appendChild(style); -""", after_style) +""", + after_style, + ) def load_ts_page(self, name: str) -> None: from aqt import mw diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index c422f5b33..4dde50e32 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -454,7 +454,7 @@ hooks = [ ), Hook( name="webview_did_inject_style_into_page", - args=["webview: AnkiWebView"], + args=["webview: aqt.webview.AnkiWebView"], doc='''Called after standard styling is injected into an external html file, such as when loading the new graphs. You can use this hook to mutate the DOM before the page is revealed. @@ -474,7 +474,8 @@ def mytest(web: AnkiWebView): ) gui_hooks.webview_did_inject_style_into_page.append(mytest) -'''), +''', + ), # Main ################### Hook(