diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 81a50ae4e..ccb7d752c 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -10,8 +10,6 @@ from dataclasses import dataclass from operator import itemgetter from typing import List, Sequence, Tuple, cast -from markdown import markdown - import aqt import aqt.forms from anki.cards import Card @@ -64,6 +62,7 @@ from aqt.utils import ( saveSplitter, saveState, shortcut, + show_invalid_search_error, showInfo, showWarning, tooltip, @@ -91,14 +90,6 @@ class SearchContext: card_ids: Optional[Sequence[int]] = None -def show_invalid_search_error(err: Exception): - "Render search errors in markdown, then display a warning." - text = str(err) - if isinstance(err, InvalidInput): - text = markdown(text) - showWarning(text) - - # Data model ########################################################################## diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 0030dc462..74be71968 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -9,9 +9,11 @@ import subprocess import sys from typing import TYPE_CHECKING, Any, List, Optional, Union, cast +from markdown import markdown + import anki import aqt -from anki.rsbackend import TR # pylint: disable=unused-import +from anki.rsbackend import TR, InvalidInput # pylint: disable=unused-import from anki.utils import invalidFilename, isMac, isWin, noBundledLibs, versionWithBuild from aqt.qt import * from aqt.theme import theme_manager @@ -67,6 +69,14 @@ def showCritical(text, parent=None, help="", title="Anki", textFormat=None): return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat) +def show_invalid_search_error(err: Exception): + "Render search errors in markdown, then display a warning." + text = str(err) + if isinstance(err, InvalidInput): + text = markdown(text) + showWarning(text) + + def showInfo( text, parent=False,