Fix: add None check for editor.note to satisfy mypy

This commit is contained in:
Mohammad 2025-06-16 17:26:35 +02:00
parent f74f583b7b
commit 9ffbe04d69

View file

@ -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(