question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: chosen model (note type) does not override last active model.

See original GitHub issue

I realized that there is apparently still a problem with the selection of the note type. Let’s say, I open anki desktop and add a card of note type “A” to a deck and close it. Then I try to add a new card with apy add or apy add-from-file of a different note type “B”. Here, if the note types have a different number of fields, the following error will occur (if they have the same number of fields, still the old note type “A” will be chosen and populated with the chosen field values):

Traceback (most recent call last):
  File "/home/skervim/anaconda3/envs/rl/bin/apy", line 11, in <module>
    load_entry_point('apy', 'console_scripts', 'apy')()
  File "/home/skervim/anaconda3/envs/rl/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/skervim/anaconda3/envs/rl/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/skervim/anaconda3/envs/rl/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/skervim/anaconda3/envs/rl/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/skervim/anaconda3/envs/rl/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/skervim/apy/apy/cli.py", line 63, in add
    notes = a.add_notes_with_editor(tags, model, deck)
  File "/home/skervim/apy/apy/anki.py", line 322, in add_notes_with_editor
    return self.add_notes_from_file(tf.name)
  File "/home/skervim/apy/apy/anki.py", line 328, in add_notes_from_file
    tags)
  File "/home/skervim/apy/apy/anki.py", line 356, in add_notes_from_list
    note.get('deck')))
  File "/home/skervim/apy/apy/anki.py", line 389, in _add_note
    return Note(self, note)
  File "/home/skervim/apy/apy/note.py", line 11, in __init__
    self.fields = [x for x, y in self.n.items()]
  File "/home/skervim/anki/anki/notes.py", line 89, in items
    for ord, f in sorted(self._fmap.values())]
  File "/home/skervim/anki/anki/notes.py", line 89, in <listcomp>
    for ord, f in sorted(self._fmap.values())]
IndexError: list index out of range

Unfortunately, I couldn’t find in the code why this happens, but I assume that chosen note type doesn’t successfully override the last active note type and so apy tries to populate the last note type instead of the chosen one.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lervagcommented, Nov 17, 2019

Ok, I think I might have fixed it. Let me know if you still experience the issue!

0reactions
lervagcommented, Nov 18, 2019

Great, happy to hear it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class is not Abstract and does not Override error in Java
The remedy to use depends on what the best model is to represent the problem being represented. The error is there to urge...
Read more >
Base class type hints incorrectly override subclass attribute type
Model.objects is designed to be overridden with a manager that defines custom methods for the model class overriding it. Not providing ...
Read more >
Creating forms from models - Django documentation
Finally, note that you can override the form field used for a given model field. See Overriding the default fields below.
Read more >
Apply overrides to instances - Components - Figma Help Center
You can only push overrides if the main component is in the same file as the instance. It's not possible to push overrides...
Read more >
Managing Import Profiles - Ex Libris Knowledge Center
Do not override /merge record with an older version (Repository type, for Upon match selections Merge and Overlay only) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found