diff --git a/pylib/anki/importing/__init__.py b/pylib/anki/importing/__init__.py index 98dbbfb31..3bb25c19b 100644 --- a/pylib/anki/importing/__init__.py +++ b/pylib/anki/importing/__init__.py @@ -6,7 +6,7 @@ from anki.importing.apkg import AnkiPackageImporter from anki.importing.csvfile import TextImporter from anki.importing.mnemo import MnemosyneImporter from anki.importing.pauker import PaukerImporter -from anki.importing.supermemo_xml import SupermemoXmlImporter +from anki.importing.supermemo_xml import SupermemoXmlImporter # type: ignore from anki.lang import _ Importers = ( diff --git a/pylib/anki/importing/mnemo.py b/pylib/anki/importing/mnemo.py index dfd25d8eb..dd0984923 100644 --- a/pylib/anki/importing/mnemo.py +++ b/pylib/anki/importing/mnemo.py @@ -148,7 +148,7 @@ acq_reps+ret_reps, lapses, card_type_id from cards""" mm = self.col.models t = mm.newTemplate("Back") t["qfmt"] = "{{Back}}" - t["afmt"] = t["qfmt"] + "\n\n
\n\n{{Front}}" + t["afmt"] = t["qfmt"] + "\n\n
\n\n{{Front}}" # type: ignore mm.addTemplate(m, t) self._addFronts(notes, m) @@ -163,7 +163,7 @@ acq_reps+ret_reps, lapses, card_type_id from cards""" t["afmt"] = ( t["qfmt"] + """\n\n
\n\n\ -{{Pronunciation}}
\n{{Meaning}}
\n{{Notes}}""" +{{Pronunciation}}
\n{{Meaning}}
\n{{Notes}}""" # type: ignore ) mm.addTemplate(m, t) t = mm.newTemplate("Production") @@ -171,7 +171,7 @@ acq_reps+ret_reps, lapses, card_type_id from cards""" t["afmt"] = ( t["qfmt"] + """\n\n
\n\n\ -{{Expression}}
\n{{Pronunciation}}
\n{{Notes}}""" +{{Expression}}
\n{{Pronunciation}}
\n{{Notes}}""" # type: ignore ) mm.addTemplate(m, t) mm.add(m) diff --git a/pylib/anki/importing/supermemo_xml.py b/pylib/anki/importing/supermemo_xml.py index 20c873295..07ddb1c4c 100644 --- a/pylib/anki/importing/supermemo_xml.py +++ b/pylib/anki/importing/supermemo_xml.py @@ -1,6 +1,7 @@ # Copyright: petr.michalec@gmail.com # License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # pytype: disable=attribute-error +# type: ignore import re import sys diff --git a/pylib/anki/models.py b/pylib/anki/models.py index d5ec5c0ea..741d6d922 100644 --- a/pylib/anki/models.py +++ b/pylib/anki/models.py @@ -591,7 +591,7 @@ select id from notes where mid = ?)""" def renderWithFields(fields): return self.col._renderQA( - (1, 1, m["id"], 1, t["ord"], "", joinFields(fields), 0) + (1, 1, m["id"], 1, t["ord"], "", joinFields(fields), 0) # type: ignore )["q"] full = renderWithFields(a) diff --git a/pylib/anki/sched.py b/pylib/anki/sched.py index c6b09f735..4405773ae 100644 --- a/pylib/anki/sched.py +++ b/pylib/anki/sched.py @@ -6,12 +6,12 @@ import random import time from heapq import * from operator import itemgetter +from typing import List, Set from anki import hooks from anki.consts import * from anki.lang import _ -# from anki.cards import Card from anki.utils import fmtTimeSpan, ids2str, intTime # queue types: 0=new/cram, 1=lrn, 2=rev, 3=day lrn, -1=suspended, -2=buried @@ -30,6 +30,9 @@ class Scheduler: self.queueLimit = 50 self.reportLimit = 1000 self.reps = 0 + self.lrnCount = 0 + self.revCount = 0 + self.newCount = 0 self.today = None self._haveQueues = False self._updateCutoff() @@ -191,7 +194,7 @@ order by due""" def _walkingCount(self, limFn=None, cntFn=None): tot = 0 - pcounts = {} + pcounts: Dict[int, int] = {} # for each of the active decks nameMap = self.col.decks.nameMap() for did in self.col.decks.active(): @@ -229,7 +232,7 @@ order by due""" self.col.decks.checkIntegrity() decks = self.col.decks.all() decks.sort(key=itemgetter("name")) - lims = {} + lims: Dict[str, List[int]] = {} data = [] def parent(name): @@ -278,7 +281,7 @@ order by due""" return grp[0][0] for (head, tail) in itertools.groupby(grps, key=key): - tail = list(tail) + tail = list(tail) # type: ignore did = None rev = 0 new = 0 @@ -1529,7 +1532,7 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""", scids = ids2str(cids) now = intTime() nids = [] - nidsSet = set() + nidsSet: Set[int] = set() for id in cids: nid = self.col.db.scalar("select nid from cards where id = ?", id) if nid not in nidsSet: diff --git a/pylib/mypy.ini b/pylib/mypy.ini index 6e14f597c..936704c56 100644 --- a/pylib/mypy.ini +++ b/pylib/mypy.ini @@ -1,8 +1,9 @@ [mypy] python_version = 3.7 -pretty = true +pretty = false no_strict_optional = true show_error_codes = true +check_untyped_defs = true [mypy-win32file] ignore_missing_imports = True