From 431683aa5d4b1586996a044bfb7369ee1b8ed4c5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 2 Apr 2020 11:29:40 +1000 Subject: [PATCH] make sure None is returned in no-such-card case --- pylib/anki/rsbackend.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pylib/anki/rsbackend.py b/pylib/anki/rsbackend.py index 8d39ff70c..33e9290c3 100644 --- a/pylib/anki/rsbackend.py +++ b/pylib/anki/rsbackend.py @@ -485,7 +485,11 @@ class RustBackend: ).search_notes.note_ids def get_card(self, cid: int) -> Optional[pb.Card]: - return self._run_command(pb.BackendInput(get_card=cid)).get_card.card + output = self._run_command(pb.BackendInput(get_card=cid)).get_card + if output.HasField("card"): + return output.card + else: + return None def update_card(self, card: BackendCard) -> None: self._run_command(pb.BackendInput(update_card=card))