From 4bc98cd0ca8ed469cf708c49f86f4793f26b4292 Mon Sep 17 00:00:00 2001 From: Matt Krump Date: Thu, 23 Jul 2020 16:04:46 -0600 Subject: [PATCH] Add type hints for apt.dyndeckconf * Add type hints for apt.dyndeckconf * Turn on check_untyped_defs for apt.dyndeckconf --- qt/aqt/dyndeckconf.py | 13 +++++++------ qt/mypy.ini | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/qt/aqt/dyndeckconf.py b/qt/aqt/dyndeckconf.py index 1c656aafd..91c5d89e6 100644 --- a/qt/aqt/dyndeckconf.py +++ b/qt/aqt/dyndeckconf.py @@ -1,6 +1,7 @@ # Copyright: Ankitects Pty Ltd and contributors # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +from typing import List, Optional import aqt from anki.lang import _ @@ -139,14 +140,14 @@ it?""" def listToUser(self, l): return " ".join([str(x) for x in l]) - def userToList(self, w, minSize=1): + def userToList(self, w, minSize=1) -> Optional[List[Union[float, int]]]: items = str(w.text()).split(" ") ret = [] - for i in items: - if not i: + for item in items: + if not item: continue try: - i = float(i) + i = float(item) assert i > 0 if i == int(i): i = int(i) @@ -154,8 +155,8 @@ it?""" except: # invalid, don't update showWarning(_("Steps must be numbers.")) - return + return None if len(ret) < minSize: showWarning(_("At least one step is required.")) - return + return None return ret diff --git a/qt/mypy.ini b/qt/mypy.ini index d3a957818..063e7abc8 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -66,3 +66,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.deckchooser] check_untyped_defs=true +[mypy-aqt.dyndeckconf] +check_untyped_defs=true