type hints

This commit is contained in:
Damien Elmes 2020-01-16 09:14:50 +10:00
parent cc9a36c11a
commit 69a7ee430d
3 changed files with 7 additions and 5 deletions

View file

@ -29,7 +29,8 @@ class Card:
_qa: Optional[Dict[str, Union[str, int]]] _qa: Optional[Dict[str, Union[str, int]]]
_note: Optional[Note] _note: Optional[Note]
timerStarted: Optional[float] timerStarted: Optional[float]
lastIvl: Optional[int] lastIvl: int
ord: int
def __init__( def __init__(
self, col: anki.collection._Collection, id: Optional[int] = None self, col: anki.collection._Collection, id: Optional[int] = None

View file

@ -116,7 +116,7 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""",
def joinedFields(self) -> str: def joinedFields(self) -> str:
return joinFields(self.fields) return joinFields(self.fields)
def cards(self) -> List: def cards(self) -> List[anki.cards.Card]:
return [ return [
self.col.getCard(id) self.col.getCard(id)
for id in self.col.db.list( for id in self.col.db.list(

View file

@ -6,12 +6,12 @@ import random
import time import time
from heapq import * from heapq import *
from operator import itemgetter from operator import itemgetter
from typing import List, Set from typing import List, Optional, Set
from anki import hooks from anki import hooks
from anki.cards import Card
from anki.consts import * from anki.consts import *
from anki.lang import _ from anki.lang import _
from anki.utils import fmtTimeSpan, ids2str, intTime from anki.utils import fmtTimeSpan, ids2str, intTime
# queue types: 0=new/cram, 1=lrn, 2=rev, 3=day lrn, -1=suspended, -2=buried # queue types: 0=new/cram, 1=lrn, 2=rev, 3=day lrn, -1=suspended, -2=buried
@ -37,7 +37,7 @@ class Scheduler:
self._haveQueues = False self._haveQueues = False
self._updateCutoff() self._updateCutoff()
def getCard(self): def getCard(self) -> Optional[Card]:
"Pop the next card from the queue. None if finished." "Pop the next card from the queue. None if finished."
self._checkDay() self._checkDay()
if not self._haveQueues: if not self._haveQueues:
@ -50,6 +50,7 @@ class Scheduler:
self.reps += 1 self.reps += 1
card.startTimer() card.startTimer()
return card return card
return None
def reset(self): def reset(self):
self._updateCutoff() self._updateCutoff()