In an add-on, I am syncing cards from a different tool into Anki. Some of these cards will already have previous scheduling information, so for these, after adding the cards, I need to update the due date, interval, ease, and lapses to arbitrary values (as determined by the data source). The sample of doing this in the add-on writing guide appears to be completely out of date, so especially with large portions of this moving to Rust and the “set due date” function changing recently, I’m not sure what the best practices are for this.
I got the following test case working in the REPL:
import anki.consts
from anki.notes import Note
n = Note(mw.col, mw.col.models.by_name("Basic"))
n['Front'] = "my front"
n['Back'] = "my back"
deck = mw.col.decks.id("Default")
mw.col.add_note(n, deck)
cids = mw.col.find_cards(f"nid:{n.id}")
c = mw.col.get_card(cids[0])
c.ivl = 6 # days
c.queue = anki.consts.QUEUE_TYPE_REV
c.type = anki.consts.CARD_TYPE_REV
c.factor = 1600 #‰
c.lapses = 3
mw.col.update_card(c)
# in the real code, we'll calculate the next due date by subtracting today's date from the current due date (stored as a datetime), rather than hard-coding 150 days from today
mw.col.sched.set_due_date([c.id], "150")
Is this a sensible approach, or am I going to get myself in trouble by directly updating these attributes in Python?