Merge pull request #702 from mkrump/help-wanted-4-add-type-hints

Add type hints for apt.dyndeckconf
This commit is contained in:
Damien Elmes 2020-07-24 09:01:07 +10:00 committed by GitHub
commit ad628d0f36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -43,6 +43,7 @@ Nickolay Yudin <kelciour@gmail.com>
neitrinoweb <github.com/neitrinoweb/>
Andreas Reis <github.com/rathsky>
Alexander Presnyakov <flagist0@gmail.com>
Matt Krump <github.com/mkrump>
********************
The text of the 3 clause BSD license follows:

View file

@ -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

View file

@ -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