Anki/pylib/anki
Damien Elmes 6b0fe4b381 undoable ops now return changes directly; add new *_ops.py files
- Introduced a new transact() method that wraps the return value
in a separate struct that describes the changes that were made.
- Changes are now gathered from the undo log, so we don't need to
guess at what was changed - eg if update_note() is called with identical
note contents, no changes are returned. Card changes will only be set
if cards were actually generated by the update_note() call, and tag
will only be set if a new tag was added.
- mw.perform_op() has been updated to expect the op to return the changes,
or a structure with the changes in it, and it will use them to fire the
change hook, instead of fetching the changes from undo_status(), so there
is no risk of race conditions.
- the various calls to mw.perform_op() have been split into separate
files like card_ops.py. Aside from making the code cleaner, this works
around a rather annoying issue with mypy. Because we run it with
no_strict_optional, mypy is happy to accept an operation that returns None,
despite the type signature saying it requires changes to be returned.
Turning no_strict_optional on for the whole codebase is not practical
at the moment, but we can enable it for individual files.

Still todo:
- The cursor keeps moving back to the start of a field when typing -
we need to ignore the refresh hook when we are the initiator.
- The busy cursor icon should probably be delayed a few hundreds ms.
- Still need to think about a nicer way of handling saveNow()
- op_made_changes(), op_affects_study_queue() might be better embedded
as properties in the object instead
2021-03-19 19:45:21 +10:00
..
_backend split out remaining rpc methods 2021-03-11 17:04:32 +10:00
importing normalize first field before comparing with local DB 2021-03-17 22:22:58 +10:00
scheduler undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
syncserver update to latest mypy_protobuf 2021-02-03 13:31:52 +10:00
__init__.py minor code cleanups with pyupgrade 2021-02-11 09:43:40 +10:00
BUILD.bazel fix _backend files not getting format checked 2021-01-31 18:56:16 +10:00
buildinfo.py fix some warnings on startup 2020-12-16 15:38:24 +10:00
cards.py more reset refactoring 2021-03-19 19:45:21 +10:00
collection.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
config.py 'set due date' now undoable 2021-03-12 14:50:31 +10:00
consts.py add some typehints, and remove some unused code 2021-01-31 20:56:21 +10:00
db.py add some typehints, and remove some unused code 2021-01-31 20:56:21 +10:00
dbproxy.py commit immediately when there's no active checkpoint 2021-03-10 11:47:53 +10:00
decks.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
errors.py Add filtered deck error localisation on backend 2021-02-26 11:32:26 +01:00
exporting.py remove unnecessary setMod() calls 2021-03-10 11:47:53 +10:00
find.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
hooks.py add more typing, and enable checks for missing types for most of pylib 2021-01-31 21:38:36 +10:00
hooks_gen.py symlink generated .py/.pyi into tree to fix Python code completion 2020-12-16 11:36:42 +10:00
httpclient.py minor code cleanups with pyupgrade 2021-02-11 09:43:40 +10:00
lang.py fix rsbackend compat issues 2021-02-08 09:51:51 +10:00
latex.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
media.py convert some pylib strings to f-strings with flynt 2021-02-11 09:51:09 +10:00
models.py remove unnecessary setMod() calls 2021-03-10 11:47:53 +10:00
notes.py Simplify note adding and the deck/notetype choosers 2021-03-10 11:53:27 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
rsbackend.py fix rsbackend compat issues 2021-02-08 09:51:51 +10:00
sound.py support speed control in tts tags 2020-01-26 14:31:07 +10:00
stats.py use top level defs for protobuf enum cases 2021-02-05 19:26:13 +10:00
statsbg.py tweaking the folder names again 2020-01-03 07:48:38 +10:00
stdmodels.py update to latest mypy_protobuf 2021-02-03 13:31:52 +10:00
storage.py storage->collection 2020-05-20 17:58:28 +10:00
sync.py start work on more clearly defining backend/protobuf boundaries 2021-01-31 18:55:45 +10:00
tags.py undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
template.py make flag changes in the reviewer undoable 2021-03-10 11:53:27 +10:00
types.py move remaining Filter button items into sidebar 2021-02-05 18:58:22 +10:00
utils.py Revert "ensure fields normalized before checksumming" 2021-03-17 22:21:13 +10:00
wheel_description.txt move aqt_data into source folder; implement wheel building 2020-11-04 12:14:03 +10:00