From cc0572a3854de9a6fb4429bb8686c6838d5e49f6 Mon Sep 17 00:00:00 2001 From: k12ish Date: Sat, 19 Dec 2020 18:12:58 +0000 Subject: [PATCH] Added type hints, renamed kwarg --- pylib/anki/collection.py | 6 +++--- qt/aqt/deckbrowser.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 28a67ab6f..1b47dbc10 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -379,9 +379,9 @@ class Collection: def cardCount(self) -> Any: return self.db.scalar("select count() from cards") - def card_count_from_did(self, did, recursive=False): - dids = [did] - if recursive: + def card_count_from_did(self, did: int, count_subdecks: bool = False) -> Any: + dids: List[int] = [did] + if count_subdecks: dids += [r[1] for r in self.decks.children(did)] count = self.db.scalar( "select count() from cards where did in {0} or " diff --git a/qt/aqt/deckbrowser.py b/qt/aqt/deckbrowser.py index 11946be0f..eb3a3adcf 100644 --- a/qt/aqt/deckbrowser.py +++ b/qt/aqt/deckbrowser.py @@ -265,7 +265,7 @@ class DeckBrowser: node.collapsed = not node.collapsed self._renderPage(reuse=True) - def _dragDeckOnto(self, draggedDeckDid, ontoDeckDid): + def _dragDeckOnto(self, draggedDeckDid: int, ontoDeckDid: int): try: self.mw.col.decks.renameForDragAndDrop(draggedDeckDid, ontoDeckDid) gui_hooks.sidebar_should_refresh_decks() @@ -274,11 +274,11 @@ class DeckBrowser: self.show() - def _delete(self, did): + def _delete(self, did: int): self.mw.checkpoint(tr(TR.DECKS_DELETE_DECK)) deck = self.mw.col.decks.get(did) if not deck["dyn"]: - count = self.mw.col.card_count_from_did(did, recursive=True) + count = self.mw.col.card_count_from_did(did, count_subdecks=True) if count: extra = tr(TR.DECKS_IT_HAS_CARD, count=count) else: