I've corrected some obvious issues, and we can fix others over time.
Mypy tests are currently broken, as adding the type hints has increased
mypy's testing surface.
This reverts commit 9955048aec.
This commit broke collections that had children under each of the
the duplicate names - it renames one of the decks, but the children
of the renamed deck are left without a parent, causing an error like
line 235, in deckDueList nlim = min(nlim, lims[p][0])\n\nKeyError('..)
Rather than a more complicated approach, I think it's safer just to
leave the case or normalization-differing decks around for now, and
we can normalize things properly in a future schema upgrade.
This reverts commit 0ffb308004, reversing
changes made to fed2f2fa3d.
This approach is flawed. Any minor change to the note type will set usn
to -1, causing the schema not to be modified when it should be.
Same logic than in last commit. Actually, there is no change of model
which need a full sync until the model is uploaded. After all, even if
a change in model imply that some card will change, those cards and
notes have not been uploaded either
This commit solves a problem that I had many time in the past. When I
create a new model, I usually want to edit it. Clone of existing
models present no interest by themselves. And as soon as I edit it, I
need to do a full sync.
As far as I understand ankiweb (which is sadly closed source), the
full sync is required because ankiweb needs to know that the model
associated to note type on the server did change. But since the model
is new, it has no note type associated to on the server, so there is
no need to do a full sync immediatly. Since the model is new, it also
means there is no risk of the inconsistency with a change made in
another computer/smartphone.
Thus, when a field/template is added, I check that the model is not
new by checking both whether it's id is not null, and also that it's
usn is not -1. (I set usn early in the model's life)
If it does not make into anki, then it'll be an add-on. But it's worth
a try first.
Some strings are missing in French at least. And some are quite
complex to understand. Especially without context, without knowledge
of Python. I tried to copy the only indication I found and add more
indication, hoping I did it correctly.
There is currently what I believe to be a small bug in anki. You can
clone a note type without doing a full sync, but you can't create
forwardReverse and forwardOptionalReverse note type without doing a
full sync. On the other hand you can clone, and even create any other
basic type without doing a full sync.
This commit simply wants to correct this.
The main trouble is that the method to create a copy of forwardReverse
and forwardOptionalReverse use a copy of the basic model, and add this
copy in the model manager BEFORE adding yet another template. This
commit corrects it by ensuring that the model is added only after all
templates are added, so that anki does not detect any change of a
template in the schema.
In order to do this, I created a method newBasicModel which creates
the basic model without adding it.
By the way, addBasicTypingModel could also use newBasicModel, and then
only change afmt. I didn't do it here because I believe that you want
the change to be minimal, and this correction would not add any
feature, only factorize the code.