diff --git a/pylib/anki/decks.py b/pylib/anki/decks.py index 0f50d310b..af402b778 100644 --- a/pylib/anki/decks.py +++ b/pylib/anki/decks.py @@ -33,8 +33,8 @@ DeckConfigDict = Dict[str, Any] DeckID = NewType("DeckID", int) DeckConfID = NewType("DeckConfID", int) -default_deck_id = DeckID(1) -default_deck_conf_id = DeckConfID(1) +DEFAULT_DECK_ID = DeckID(1) +DEFAULT_DECK_CONF_ID = DeckConfID(1) class DecksDictProxy: @@ -252,7 +252,7 @@ class DeckManager: def get(self, did: Union[DeckID, str], default: bool = True) -> Optional[DeckDict]: if not did: if default: - return self.get_legacy(default_deck_id) + return self.get_legacy(DEFAULT_DECK_ID) else: return None id = DeckID(int(did)) @@ -260,7 +260,7 @@ class DeckManager: if deck: return deck elif default: - return self.get_legacy(default_deck_id) + return self.get_legacy(DEFAULT_DECK_ID) else: return None @@ -324,7 +324,7 @@ class DeckManager: conf = self.get_config(dcid) if not conf: # fall back on default - conf = self.get_config(default_deck_conf_id) + conf = self.get_config(DEFAULT_DECK_CONF_ID) conf["dyn"] = False return conf # dynamic decks have embedded conf @@ -586,7 +586,7 @@ class DeckManager: def new_filtered(self, name: str) -> DeckID: "Return a new dynamic deck and set it as the current deck." - did = self.id(name, type=default_deck_conf_id) + did = self.id(name, type=DEFAULT_DECK_CONF_ID) self.select(did) return did diff --git a/pylib/anki/notes.py b/pylib/anki/notes.py index 00de732f8..060458909 100644 --- a/pylib/anki/notes.py +++ b/pylib/anki/notes.py @@ -98,7 +98,7 @@ class Note: ) -> anki.cards.Card: card = anki.cards.Card(self.col) card.ord = ord - card.did = anki.decks.default_deck_id + card.did = anki.decks.DEFAULT_DECK_ID model = custom_note_type or self.model() template = copy.copy( diff --git a/qt/aqt/deckchooser.py b/qt/aqt/deckchooser.py index 81ddc5ba8..7837f38e5 100644 --- a/qt/aqt/deckchooser.py +++ b/qt/aqt/deckchooser.py @@ -3,7 +3,7 @@ from typing import Optional -from anki.decks import DeckID, default_deck_id +from anki.decks import DEFAULT_DECK_ID, DeckID from aqt import AnkiQt from aqt.qt import * from aqt.utils import TR, HelpPage, shortcut, tr @@ -71,7 +71,7 @@ class DeckChooser(QHBoxLayout): def _ensure_selected_deck_valid(self) -> None: if not self.mw.col.decks.get(self._selected_deck_id, default=False): - self.selected_deck_id = default_deck_id + self.selected_deck_id = DEFAULT_DECK_ID def _update_button_label(self) -> None: self.deck.setText(self.selected_deck_name().replace("&", "&&"))