Add type hints to importing

* Add type hints to importing
* Turn on type checking for aqt.importing
This commit is contained in:
Matt Krump 2020-07-24 12:38:34 -06:00
parent 186f1c7720
commit a844a8b0c5
2 changed files with 7 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import traceback
import unicodedata import unicodedata
import zipfile import zipfile
from concurrent.futures import Future from concurrent.futures import Future
from typing import Optional
import anki.importing as importing import anki.importing as importing
import aqt.deckchooser import aqt.deckchooser
@ -55,7 +56,7 @@ class ChangeMap(QDialog):
self.frm.fields.setCurrentRow(n) self.frm.fields.setCurrentRow(n)
else: else:
self.frm.fields.setCurrentRow(n + 1) self.frm.fields.setCurrentRow(n + 1)
self.field = None self.field: Optional[str] = None
def getField(self): def getField(self):
self.exec_() self.exec_()
@ -488,7 +489,9 @@ def _replaceWithApkg(mw, filename, backup):
colname = "collection.anki2" colname = "collection.anki2"
with z.open(colname) as source, open(mw.pm.collectionPath(), "wb") as target: with z.open(colname) as source, open(mw.pm.collectionPath(), "wb") as target:
shutil.copyfileobj(source, 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
d = os.path.join(mw.pm.profileFolder(), "collection.media") d = os.path.join(mw.pm.profileFolder(), "collection.media")
for n, (cStr, file) in enumerate( for n, (cStr, file) in enumerate(

View file

@ -72,3 +72,5 @@ check_untyped_defs=true
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.errors] [mypy-aqt.errors]
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.importing]
check_untyped_defs=true