Add type hints for apt.dyndeckconf

* Add type hints for apt.dyndeckconf
* Turn on check_untyped_defs for apt.dyndeckconf
This commit is contained in:
Matt Krump 2020-07-23 16:04:46 -06:00
parent bb6124cfd5
commit 4bc98cd0ca
2 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,7 @@
# Copyright: Ankitects Pty Ltd and contributors # Copyright: Ankitects Pty Ltd and contributors
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from typing import List, Optional
import aqt import aqt
from anki.lang import _ from anki.lang import _
@ -139,14 +140,14 @@ it?"""
def listToUser(self, l): def listToUser(self, l):
return " ".join([str(x) for x in 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(" ") items = str(w.text()).split(" ")
ret = [] ret = []
for i in items: for item in items:
if not i: if not item:
continue continue
try: try:
i = float(i) i = float(item)
assert i > 0 assert i > 0
if i == int(i): if i == int(i):
i = int(i) i = int(i)
@ -154,8 +155,8 @@ it?"""
except: except:
# invalid, don't update # invalid, don't update
showWarning(_("Steps must be numbers.")) showWarning(_("Steps must be numbers."))
return return None
if len(ret) < minSize: if len(ret) < minSize:
showWarning(_("At least one step is required.")) showWarning(_("At least one step is required."))
return return None
return ret return ret

View file

@ -66,3 +66,5 @@ check_untyped_defs=true
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.deckchooser] [mypy-aqt.deckchooser]
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.dyndeckconf]
check_untyped_defs=true