fixes for latest mypy

This commit is contained in:
Damien Elmes 2020-10-10 19:02:59 +10:00
parent c96784c0eb
commit 727ddd74b6
3 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,7 @@
import re
import time
from typing import cast
from anki.db import DB
from anki.importing.noteimp import ForeignCard, ForeignNote, NoteImporter
@ -160,17 +161,17 @@ acq_reps+ret_reps, lapses, card_type_id from cards"""
t = mm.newTemplate("Recognition")
t["qfmt"] = "{{Expression}}"
t["afmt"] = (
t["qfmt"]
cast(str, t["qfmt"])
+ """\n\n<hr id=answer>\n\n\
{{Pronunciation}}<br>\n{{Meaning}}<br>\n{{Notes}}""" # type: ignore
{{Pronunciation}}<br>\n{{Meaning}}<br>\n{{Notes}}"""
)
mm.addTemplate(m, t)
t = mm.newTemplate("Production")
t["qfmt"] = "{{Meaning}}"
t["afmt"] = (
t["qfmt"]
cast(str, t["qfmt"])
+ """\n\n<hr id=answer>\n\n\
{{Expression}}<br>\n{{Pronunciation}}<br>\n{{Notes}}""" # type: ignore
{{Expression}}<br>\n{{Pronunciation}}<br>\n{{Notes}}"""
)
mm.addTemplate(m, t)
mm.add(m)

View File

@ -39,7 +39,7 @@ class PaukerImporter(NoteImporter):
try:
f = gzip.open(self.file)
tree = ET.parse(f)
tree = ET.parse(f) # type: ignore
lesson = tree.getroot()
assert lesson.tag == "Lesson"
finally:

View File

@ -491,7 +491,7 @@ def _replaceWithApkg(mw, filename, backup):
with z.open(colname) as source, open(mw.pm.collectionPath(), "wb") as target:
# ignore appears related to https://github.com/python/typeshed/issues/4349
# see if can turn off once issue fix is merged in
shutil.copyfileobj(source, target) # type: ignore
shutil.copyfileobj(source, target)
d = os.path.join(mw.pm.profileFolder(), "collection.media")
for n, (cStr, file) in enumerate(