check_untyped_defs in mypy for pylib

This commit is contained in:
Damien Elmes 2020-01-16 08:10:49 +10:00
parent 8cb980bacc
commit 6d9baaf052
6 changed files with 16 additions and 11 deletions

View File

@ -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 = (

View File

@ -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<hr id=answer>\n\n{{Front}}"
t["afmt"] = t["qfmt"] + "\n\n<hr id=answer>\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<hr id=answer>\n\n\
{{Pronunciation}}<br>\n{{Meaning}}<br>\n{{Notes}}"""
{{Pronunciation}}<br>\n{{Meaning}}<br>\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<hr id=answer>\n\n\
{{Expression}}<br>\n{{Pronunciation}}<br>\n{{Notes}}"""
{{Expression}}<br>\n{{Pronunciation}}<br>\n{{Notes}}""" # type: ignore
)
mm.addTemplate(m, t)
mm.add(m)

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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