From 9ffbe04d699d7f78c1a3fa18e77baf2ee5ebe747 Mon Sep 17 00:00:00 2001 From: Mohammad Date: Mon, 16 Jun 2025 17:26:35 +0200 Subject: [PATCH] Fix: add None check for editor.note to satisfy mypy --- qt/aqt/editor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 3d0fe5803..4a6fb4355 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -1797,13 +1797,17 @@ def add_flip_button(buttons, editor: Editor): editor.saveNow(lambda: flip_fields(editor)) def flip_fields(editor: Editor): - front_text = editor.note["Front"] - back_text = editor.note["Back"] - editor.note["Front"] = back_text - editor.note["Back"] = front_text + note = editor.note + if note is None: + return + + front_text = note["Front"] + back_text = note["Back"] + note["Front"] = back_text + note["Back"] = front_text editor.loadNote() if not editor.addMode: - editor.note.flush() + note.flush() tooltip("Fields flipped successfully.") btn = editor.addButton(