From e96ebbe88f428775aa4dd16cbc9e7c3ee850e44d Mon Sep 17 00:00:00 2001 From: Tarcisio Eduardo Moreira Crocomo Date: Sat, 16 Jun 2018 15:43:56 -0300 Subject: [PATCH] Add tests for DefaultDict support. --- test/completion/pep0484_typing.py | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/completion/pep0484_typing.py b/test/completion/pep0484_typing.py index 7bee1e64..123e6438 100644 --- a/test/completion/pep0484_typing.py +++ b/test/completion/pep0484_typing.py @@ -129,11 +129,12 @@ class Key: class Value: pass -def mapping(p, q, d, r, s, t): +def mapping(p, q, d, dd, r, s, t): """ :type p: typing.Mapping[Key, Value] :type q: typing.MutableMapping[Key, Value] :type d: typing.Dict[Key, Value] + :type dd: typing.DefaultDict[Key, Value] :type r: typing.KeysView[Key] :type s: typing.ValuesView[Value] :type t: typing.ItemsView[Key, Value] @@ -144,6 +145,8 @@ def mapping(p, q, d, r, s, t): q.setd #? ["setdefault"] d.setd + #? ["setdefault"] + dd.setd #? Value() p[1] for key in p: @@ -241,6 +244,36 @@ for value in x.values(): #? int() value # python >= 3.2 + +class TestDefaultDict(typing.DefaultDict[str, int]): + def setdud(self): + pass + +def testdict(x): + """ + :type x: TestDefaultDict + """ + #? ["setdud", "setdefault"] + x.setd + for key in x.keys(): + #? str() + key + for value in x.values(): + #? int() + value + +x = TestDefaultDict() +#? ["setdud", "setdefault"] +x.setd +for key in x.keys(): + #? str() + key +for value in x.values(): + #? int() + value +# python >= 3.2 + + """ docstrings have some auto-import, annotations can use all of Python's import logic