anki/pylib
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
..
anki undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
rsbridge rework backend codegen to support multiple services; split out sched 2021-03-11 14:51:29 +10:00
tests undoable ops now return changes directly; add new *_ops.py files 2021-03-19 19:45:21 +10:00
tools update to latest mypy_protobuf 2021-02-03 13:31:52 +10:00
.gitignore symlink generated .py/.pyi into tree to fix Python code completion 2020-12-16 11:36:42 +10:00
.isort.cfg start work on more clearly defining backend/protobuf boundaries 2021-01-31 18:55:45 +10:00
.pylintrc Simplify note adding and the deck/notetype choosers 2021-03-10 11:53:27 +10:00
BUILD.bazel format_fix -> format; rename svelte-check for consistency 2020-11-12 20:19:32 +10:00
mypy.ini add more typing, and enable checks for missing types for most of pylib 2021-01-31 21:38:36 +10:00
orjson.bzl Make orjson optional again 2021-01-07 09:44:40 +10:00
protobuf.bzl update mypy and other Python deps 2021-02-01 15:50:04 +10:00
README.md minor doc updates 2020-12-11 22:37:12 +10:00

Anki's Python library code is in anki/.

The Rust/Python extension module is in rsbridge/; it references the library defined in ../rslib.