Gui_hooks.reviewer_did_answer_card is giving me a third argument and doesn't run my function

I’m passing 2 arguments to the reviewer_did_answer_card hook, (self and _old), however, if I try to run this function, Anki passes a third argument to it and doesn’t run my function. It says 'it expected 2 arguments but 3 were given (even if i’m only passing 2). Does anyone know how to solve this?

This is my hook:


This is my function

def ColdTurkey(self, _old):
    ret = _old(self)
    # code
    return ret

And this is the error log Anki is giving me:

Caught exception:
Traceback (most recent call last):
  File "aqt\", line 36, in cmd
  File "aqt\", line 135, in _onCmd
  File "aqt\", line 580, in _onBridgeCmd
  File "aqt\", line 343, in _linkHandler
  File "aqt\", line 271, in _answerCard
  File "aqt\", line 2279, in __call__
TypeError: ColdTurkey() takes 2 positional arguments but 3 were given

I think you’re confusing hooks with so-called monkey patching done using the anki.hooks.wrap function.

reviewer_did_answer_card is a hook, so it doesn’t take the (self, _old) arguments. Instead, it expects (reviewer, card, ease) as specified here.


My function takes 2 arguments and this hook was making anki pass me a third. But I solved it by checking the source code of an addon that had this same hook.

This is the final code:

from aqt.reviewer import Reviewer
from typing import Callable

def myfunction(reviewer: Reviewer, ease: int, _old: Callable)