mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Enable strict_optional for aqt/mediacheck, theme, toolbar (#3569)
* Enable strict_optional for mediacheck * Fix mypy errors * Enable strict_optional for theme * Fix mypy errors * Enable strict_optional for toolbar * Fix mypy errors
This commit is contained in:
parent
763712c696
commit
db7f128b83
4 changed files with 16 additions and 3 deletions
|
@ -86,6 +86,12 @@ strict_optional = True
|
||||||
strict_optional = True
|
strict_optional = True
|
||||||
[mypy-aqt.flags]
|
[mypy-aqt.flags]
|
||||||
strict_optional = True
|
strict_optional = True
|
||||||
|
[mypy-aqt.mediacheck]
|
||||||
|
strict_optional = True
|
||||||
|
[mypy-aqt.theme]
|
||||||
|
strict_optional = True
|
||||||
|
[mypy-aqt.toolbar]
|
||||||
|
strict_optional = True
|
||||||
[mypy-anki.scheduler.base]
|
[mypy-anki.scheduler.base]
|
||||||
strict_optional = True
|
strict_optional = True
|
||||||
[mypy-anki._backend.rsbridge]
|
[mypy-anki._backend.rsbridge]
|
||||||
|
|
|
@ -80,6 +80,7 @@ class MediaChecker:
|
||||||
label = progress.media_check
|
label = progress.media_check
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
assert self.progress_dialog is not None
|
||||||
if self.progress_dialog.wantCancel:
|
if self.progress_dialog.wantCancel:
|
||||||
self.mw.col.set_wants_abort()
|
self.mw.col.set_wants_abort()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -165,6 +166,7 @@ class MediaChecker:
|
||||||
|
|
||||||
def _on_render_latex(self) -> None:
|
def _on_render_latex(self) -> None:
|
||||||
self.progress_dialog = self.mw.progress.start()
|
self.progress_dialog = self.mw.progress.start()
|
||||||
|
assert self.progress_dialog is not None
|
||||||
try:
|
try:
|
||||||
out = self.mw.col.media.render_all_latex(self._on_render_latex_progress)
|
out = self.mw.col.media.render_all_latex(self._on_render_latex_progress)
|
||||||
if self.progress_dialog.wantCancel:
|
if self.progress_dialog.wantCancel:
|
||||||
|
@ -181,6 +183,7 @@ class MediaChecker:
|
||||||
tooltip(tr.media_check_all_latex_rendered())
|
tooltip(tr.media_check_all_latex_rendered())
|
||||||
|
|
||||||
def _on_render_latex_progress(self, count: int) -> bool:
|
def _on_render_latex_progress(self, count: int) -> bool:
|
||||||
|
assert self.progress_dialog is not None
|
||||||
if self.progress_dialog.wantCancel:
|
if self.progress_dialog.wantCancel:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,9 @@ class ThemeManager:
|
||||||
self._current_widget_style = new_widget_style
|
self._current_widget_style = new_widget_style
|
||||||
app = aqt.mw.app
|
app = aqt.mw.app
|
||||||
if not self._default_style:
|
if not self._default_style:
|
||||||
self._default_style = app.style().objectName()
|
style = app.style()
|
||||||
|
assert style is not None
|
||||||
|
self._default_style = style.objectName()
|
||||||
self._apply_palette(app)
|
self._apply_palette(app)
|
||||||
self._apply_style(app)
|
self._apply_style(app)
|
||||||
gui_hooks.theme_did_change()
|
gui_hooks.theme_did_change()
|
||||||
|
|
|
@ -37,7 +37,9 @@ class BottomToolbar:
|
||||||
class ToolbarWebView(AnkiWebView):
|
class ToolbarWebView(AnkiWebView):
|
||||||
hide_condition: Callable[..., bool]
|
hide_condition: Callable[..., bool]
|
||||||
|
|
||||||
def __init__(self, mw: aqt.AnkiQt, kind: AnkiWebViewKind | None = None) -> None:
|
def __init__(
|
||||||
|
self, mw: aqt.AnkiQt, kind: AnkiWebViewKind = AnkiWebViewKind.DEFAULT
|
||||||
|
) -> None:
|
||||||
AnkiWebView.__init__(self, mw, kind=kind)
|
AnkiWebView.__init__(self, mw, kind=kind)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.setFocusPolicy(Qt.FocusPolicy.WheelFocus)
|
self.setFocusPolicy(Qt.FocusPolicy.WheelFocus)
|
||||||
|
@ -172,7 +174,7 @@ class TopWebView(ToolbarWebView):
|
||||||
self.eval("""document.body.style.setProperty("min-height", "0px"); """)
|
self.eval("""document.body.style.setProperty("min-height", "0px"); """)
|
||||||
self.evalWithCallback("document.documentElement.offsetHeight", self._onHeight)
|
self.evalWithCallback("document.documentElement.offsetHeight", self._onHeight)
|
||||||
|
|
||||||
def resizeEvent(self, event: QResizeEvent) -> None:
|
def resizeEvent(self, event: QResizeEvent | None) -> None:
|
||||||
super().resizeEvent(event)
|
super().resizeEvent(event)
|
||||||
|
|
||||||
self.mw.web.evalWithCallback(
|
self.mw.web.evalWithCallback(
|
||||||
|
|
Loading…
Reference in a new issue