mirror of
https://github.com/ankitects/anki.git
synced 2025-12-20 10:22:57 -05:00
Fixing type hints
Matched all type hints, changed the original Sequence[] type hint for _answerButtonList() in reviewer.py on mypy's recommendation.
This commit is contained in:
parent
649142e5b3
commit
897ec72608
3 changed files with 14 additions and 11 deletions
|
|
@ -7,7 +7,7 @@ See pylib/anki/hooks.py
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Callable, List, Optional, Tuple
|
from typing import Any, Callable, List, Optional, Tuple, Sequence
|
||||||
|
|
||||||
import anki
|
import anki
|
||||||
import aqt
|
import aqt
|
||||||
|
|
@ -2177,6 +2177,7 @@ class _ReviewerWillInitAnswerButtonsFilter:
|
||||||
_hooks: List[
|
_hooks: List[
|
||||||
Callable[
|
Callable[
|
||||||
["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card],
|
["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card],
|
||||||
|
["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card],
|
||||||
Tuple[Tuple[int, str], ...],
|
Tuple[Tuple[int, str], ...],
|
||||||
]
|
]
|
||||||
] = []
|
] = []
|
||||||
|
|
@ -2184,17 +2185,17 @@ class _ReviewerWillInitAnswerButtonsFilter:
|
||||||
def append(
|
def append(
|
||||||
self,
|
self,
|
||||||
cb: Callable[
|
cb: Callable[
|
||||||
["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card],
|
["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card],
|
||||||
Tuple[Tuple[int, str], ...],
|
Tuple[Tuple[int, str], ...],
|
||||||
],
|
],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""(buttons_tuple: Optional[Tuple[Tuple[int, str], ...]], reviewer: aqt.reviewer.Reviewer, card: Card)"""
|
"""(buttons_tuple: Tuple[Tuple[int, str], ...], reviewer: aqt.reviewer.Reviewer, card: Card)"""
|
||||||
self._hooks.append(cb)
|
self._hooks.append(cb)
|
||||||
|
|
||||||
def remove(
|
def remove(
|
||||||
self,
|
self,
|
||||||
cb: Callable[
|
cb: Callable[
|
||||||
["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card],
|
["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card],
|
||||||
Tuple[Tuple[int, str], ...],
|
Tuple[Tuple[int, str], ...],
|
||||||
],
|
],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -2206,7 +2207,7 @@ class _ReviewerWillInitAnswerButtonsFilter:
|
||||||
|
|
||||||
def __call__(
|
def __call__(
|
||||||
self,
|
self,
|
||||||
buttons_tuple: Optional[Tuple[Tuple[int, str], ...]],
|
buttons_tuple: Tuple[Tuple[int, str], ...],
|
||||||
reviewer: aqt.reviewer.Reviewer,
|
reviewer: aqt.reviewer.Reviewer,
|
||||||
card: Card,
|
card: Card,
|
||||||
) -> Tuple[Tuple[int, str], ...]:
|
) -> Tuple[Tuple[int, str], ...]:
|
||||||
|
|
|
||||||
|
|
@ -621,10 +621,10 @@ time = %(time)d;
|
||||||
else:
|
else:
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def _answerButtonList(self) -> Sequence[Tuple[int, str], ...]:
|
def _answerButtonList(self) -> Tuple[Tuple[int, str], ...]:
|
||||||
button_count = self.mw.col.sched.answerButtons(self.card)
|
button_count = self.mw.col.sched.answerButtons(self.card)
|
||||||
if button_count == 2:
|
if button_count == 2:
|
||||||
buttons_tuple = ((1, _("Again")), (2, _("Good")),)
|
buttons_tuple: Tuple[Tuple[int, str], ...] = ((1, _("Again")), (2, _("Good")),)
|
||||||
elif button_count == 3:
|
elif button_count == 3:
|
||||||
buttons_tuple = ((1, _("Again")), (2, _("Good")), (3, _("Easy")))
|
buttons_tuple = ((1, _("Again")), (2, _("Good")), (3, _("Easy")))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -61,19 +61,21 @@ hooks = [
|
||||||
Hook(
|
Hook(
|
||||||
name="reviewer_will_init_answer_buttons",
|
name="reviewer_will_init_answer_buttons",
|
||||||
args=[
|
args=[
|
||||||
"buttons_tuple: Optional[Tuple[Tuple[int, str], ...]]",
|
"buttons_tuple: Tuple[Tuple[int, str], ...]",
|
||||||
"reviewer: aqt.reviewer.Reviewer",
|
"reviewer: aqt.reviewer.Reviewer",
|
||||||
"card: Card",
|
"card: Card",
|
||||||
],
|
],
|
||||||
return_type="Tuple[Tuple[int, str], ...]",
|
return_type="Tuple[Tuple[int, str], ...]",
|
||||||
doc="""Used to modify list of answer buttons
|
doc="""Used to modify list of answer buttons
|
||||||
|
|
||||||
buttons_tuple is a tuple of buttons, with each button represented by a tuple
|
buttons_tuple is a sequence of buttons, with each button represented
|
||||||
containing an int for the button's number and a string for the button's label.
|
by a tuple containing an int for the button's number and a string for
|
||||||
|
the button's label.
|
||||||
|
|
||||||
Return a tuple of the form ((1, "Label1"), (2, "Label2"), ...)
|
Return a tuple of the form ((1, "Label1"), (2, "Label2"), ...)
|
||||||
|
|
||||||
Note: import _ from anki.lang to support automatic translation, using, e.g.,
|
Note: import _ from anki.lang to support automatic translation, using,
|
||||||
|
e.g.,
|
||||||
((1, _("Label1")), ...)
|
((1, _("Label1")), ...)
|
||||||
""",
|
""",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue