add type check to textFormat arg
This commit is contained in:
parent
322788133b
commit
a03da5ce89
@ -8,7 +8,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import TYPE_CHECKING, Any, List, Optional, Union, cast
|
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union, cast
|
||||||
|
|
||||||
from markdown import markdown
|
from markdown import markdown
|
||||||
|
|
||||||
@ -22,6 +22,8 @@ from aqt.theme import theme_manager
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from anki.rsbackend import TRValue
|
from anki.rsbackend import TRValue
|
||||||
|
|
||||||
|
TextFormat = Union[Literal["plain", "rich"]]
|
||||||
|
|
||||||
|
|
||||||
def aqt_data_folder() -> str:
|
def aqt_data_folder() -> str:
|
||||||
# running in place?
|
# running in place?
|
||||||
@ -90,12 +92,16 @@ def openLink(link):
|
|||||||
QDesktopServices.openUrl(QUrl(link))
|
QDesktopServices.openUrl(QUrl(link))
|
||||||
|
|
||||||
|
|
||||||
def showWarning(text, parent=None, help="", title="Anki", textFormat=None):
|
def showWarning(
|
||||||
|
text, parent=None, help="", title="Anki", textFormat: Optional[TextFormat] = None
|
||||||
|
):
|
||||||
"Show a small warning with an OK button."
|
"Show a small warning with an OK button."
|
||||||
return showInfo(text, parent, help, "warning", title=title, textFormat=textFormat)
|
return showInfo(text, parent, help, "warning", title=title, textFormat=textFormat)
|
||||||
|
|
||||||
|
|
||||||
def showCritical(text, parent=None, help="", title="Anki", textFormat=None):
|
def showCritical(
|
||||||
|
text, parent=None, help="", title="Anki", textFormat: Optional[TextFormat] = None
|
||||||
|
):
|
||||||
"Show a small critical error with an OK button."
|
"Show a small critical error with an OK button."
|
||||||
return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat)
|
return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat)
|
||||||
|
|
||||||
@ -114,9 +120,9 @@ def showInfo(
|
|||||||
help="",
|
help="",
|
||||||
type="info",
|
type="info",
|
||||||
title="Anki",
|
title="Anki",
|
||||||
textFormat=None,
|
textFormat: Optional[TextFormat] = None,
|
||||||
customBtns=None,
|
customBtns=None,
|
||||||
):
|
) -> int:
|
||||||
"Show a small info window with an OK button."
|
"Show a small info window with an OK button."
|
||||||
if parent is False:
|
if parent is False:
|
||||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||||
|
Loading…
Reference in New Issue
Block a user