Skip to content

Commit c5c91dc

Browse files
committed
Accept additional arguments to fix monkey patch
1 parent f6dfc6c commit c5c91dc

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ This add-on is implemented as a monkey patch replacing
7878
`Collection.compare_answer` (Anki 2.1.56+) or `Reviewer.correct` (up to Anki
7979
2.1.54), which are responsible for generating the differences. Since it replaces
8080
these functions, it is not guaranteed to work in future updates. I have tested
81-
it in Anki 2.1.40 through Anki 23.12.1.
81+
it in Anki 2.1.40 through Anki 24.06.3.
8282

8383
The diffs between "given" and "correct" answer choices are rendered using a
8484
modified version of the [Longest Common Subsequence][LCS], with a preference for
@@ -96,6 +96,10 @@ next closest, and so on until there are no more pairs.
9696

9797
## Changelog
9898

99+
2024-10-05:
100+
101+
* Fix add-on to work with latest beta version of Anki.
102+
99103
2024-04-28:
100104

101105
* Use diff algorithm while matching answer choices to ensure best diff.

answerset/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ def get_config() -> Config:
4545
try:
4646
from aqt.reviewer import Reviewer
4747

48-
def correct(self: Reviewer, given: str, correct: str, **kwargs: Any) -> str:
48+
def correct(
49+
self: Reviewer,
50+
given: str,
51+
correct: str,
52+
*args: Any,
53+
**kwargs: Any,
54+
) -> str:
4955
return new_css + compare_answer_no_html(user_config, correct, given)
5056

5157
Reviewer.correct = correct # type: ignore
@@ -58,7 +64,14 @@ def correct(self: Reviewer, given: str, correct: str, **kwargs: Any) -> str:
5864
from anki.collection import Collection
5965
from anki.utils import html_to_text_line
6066

61-
def compare_answer(self: Collection, expected: str, provided: str) -> str:
67+
# TODO: handle "combining" argument
68+
def compare_answer(
69+
self: Collection,
70+
expected: str,
71+
provided: str,
72+
*args: Any,
73+
**kwargs: Any,
74+
) -> str:
6275
# Strip AV tags if possible
6376
try:
6477
if aqt.mw:

0 commit comments

Comments
 (0)