From a844a8b0c505079dcff62b0785a449378b5078e8 Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Fri, 24 Jul 2020 12:38:34 -0600 Subject: [PATCH] Add type hints to importing * Add type hints to importing * Turn on type checking for aqt.importing --- qt/aqt/importing.py | 7 +++++-- qt/mypy.ini | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qt/aqt/importing.py b/qt/aqt/importing.py index ce217287a..257fd4bfe 100644 --- a/qt/aqt/importing.py +++ b/qt/aqt/importing.py @@ -10,6 +10,7 @@ import traceback import unicodedata import zipfile from concurrent.futures import Future +from typing import Optional import anki.importing as importing import aqt.deckchooser @@ -55,7 +56,7 @@ class ChangeMap(QDialog): self.frm.fields.setCurrentRow(n) else: self.frm.fields.setCurrentRow(n + 1) - self.field = None + self.field: Optional[str] = None def getField(self): self.exec_() @@ -488,7 +489,9 @@ def _replaceWithApkg(mw, filename, backup): colname = "collection.anki2" 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") for n, (cStr, file) in enumerate( diff --git a/qt/mypy.ini b/qt/mypy.ini index b6203b753..44468f7aa 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -72,3 +72,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.errors] check_untyped_defs=true +[mypy-aqt.importing] +check_untyped_defs=true