mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 14:03:55 -05:00
Fix: add None check for editor.note to satisfy mypy
This commit is contained in:
parent
f74f583b7b
commit
9ffbe04d69
1 changed files with 9 additions and 5 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue