diff --git a/qt/aqt/gui_hooks.py b/qt/aqt/gui_hooks.py index f3397f90e..83ab69d9b 100644 --- a/qt/aqt/gui_hooks.py +++ b/qt/aqt/gui_hooks.py @@ -7,7 +7,7 @@ See pylib/anki/hooks.py from __future__ import annotations -from typing import Any, Callable, List, Optional, Tuple +from typing import Any, Callable, List, Optional, Tuple, Sequence import anki import aqt @@ -2177,6 +2177,7 @@ class _ReviewerWillInitAnswerButtonsFilter: _hooks: List[ Callable[ ["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card], + ["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card], Tuple[Tuple[int, str], ...], ] ] = [] @@ -2184,17 +2185,17 @@ class _ReviewerWillInitAnswerButtonsFilter: def append( self, cb: Callable[ - ["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card], + ["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card], Tuple[Tuple[int, str], ...], ], ) -> 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) def remove( self, cb: Callable[ - ["Optional[Tuple[Tuple[int, str], ...]]", "aqt.reviewer.Reviewer", Card], + ["Tuple[Tuple[int, str], ...]", "aqt.reviewer.Reviewer", Card], Tuple[Tuple[int, str], ...], ], ) -> None: @@ -2206,7 +2207,7 @@ class _ReviewerWillInitAnswerButtonsFilter: def __call__( self, - buttons_tuple: Optional[Tuple[Tuple[int, str], ...]], + buttons_tuple: Tuple[Tuple[int, str], ...], reviewer: aqt.reviewer.Reviewer, card: Card, ) -> Tuple[Tuple[int, str], ...]: diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index d30436de8..4560f51e5 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -621,10 +621,10 @@ time = %(time)d; else: 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) if button_count == 2: - buttons_tuple = ((1, _("Again")), (2, _("Good")),) + buttons_tuple: Tuple[Tuple[int, str], ...] = ((1, _("Again")), (2, _("Good")),) elif button_count == 3: buttons_tuple = ((1, _("Again")), (2, _("Good")), (3, _("Easy"))) else: diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index bf84ce664..32d840b82 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -61,19 +61,21 @@ hooks = [ Hook( name="reviewer_will_init_answer_buttons", args=[ - "buttons_tuple: Optional[Tuple[Tuple[int, str], ...]]", + "buttons_tuple: Tuple[Tuple[int, str], ...]", "reviewer: aqt.reviewer.Reviewer", "card: Card", ], return_type="Tuple[Tuple[int, str], ...]", doc="""Used to modify list of answer buttons - buttons_tuple is a tuple of buttons, with each button represented by a tuple - containing an int for the button's number and a string for the button's label. + buttons_tuple is a sequence of buttons, with each button represented + 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"), ...) - 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")), ...) """, ),