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)) editor.saveNow(lambda: flip_fields(editor))
def flip_fields(editor: Editor): def flip_fields(editor: Editor):
front_text = editor.note["Front"] note = editor.note
back_text = editor.note["Back"] if note is None:
editor.note["Front"] = back_text return
editor.note["Back"] = front_text
front_text = note["Front"]
back_text = note["Back"]
note["Front"] = back_text
note["Back"] = front_text
editor.loadNote() editor.loadNote()
if not editor.addMode: if not editor.addMode:
editor.note.flush() note.flush()
tooltip("Fields flipped successfully.") tooltip("Fields flipped successfully.")
btn = editor.addButton( btn = editor.addButton(