6941bccde4
Protobuf 3.15 introduced support for marking scalar fields like uint32 as optional, and all of our tooling appears to support it now. This allows us to use simple optional/null checks in our Rust/ TypeScript code, without having to resort to an inner message. I had to apply a minor patch to protobufjs to get this working with the json-module output; this has also been submitted upstream: https://github.com/protobufjs/protobuf.js/pull/1693 I've modified CardStatsResponse as an example of the new syntax. One thing to note: while the Rust and TypeScript bindings use optional/ null fields, as that is the norm in those languages, Google's Python bindings are not very Pythonic. Referencing an optional field that is missing will yield the default value, and a separate HasField() call is required, eg: ``` >>> from anki.stats_pb2 import CardStatsResponse as R ... msg = R.FromString(b"") ... print(msg.first_review) ... print(msg.HasField("first_review")) 0 False ``` |
||
---|---|---|
.buildkite | ||
.github/ISSUE_TEMPLATE | ||
.vscode | ||
cargo | ||
docs | ||
ftl | ||
platforms | ||
proto | ||
pylib | ||
python | ||
qt | ||
rslib | ||
sass | ||
tools | ||
ts | ||
.bazelignore | ||
.bazelrc | ||
.bazelversion | ||
.gitattributes | ||
.gitignore | ||
.prettierignore | ||
.prettierrc | ||
.user.bazelrc | ||
BUILD.bazel | ||
Cargo.lock | ||
Cargo.toml | ||
CONTRIBUTORS | ||
defs.bzl | ||
late_deps.bzl | ||
LICENSE | ||
package.json | ||
pkgkey.asc | ||
pyrightconfig.json | ||
README.md | ||
repos.bzl | ||
run | ||
run.bat | ||
SECURITY.md | ||
WORKSPACE | ||
yarn.lock |
Anki
This repo contains the source code for the computer version of Anki.
If you'd like to try development builds of Anki but don't feel comfortable building the code, please see https://betas.ankiweb.net/
For more information on building, please see Development.