PY-19723 Fixed: Type hinting of arbitrary argument lists and default argument values

Update PyDocStringTypeProvider to correctly handle `:type args: T1` and `:type kwargs: T2`, and wrap their types to `Tuple[T1, ...]` and `Dict[str, T2]`.
This commit is contained in:
Semyon Proshev
2016-11-25 19:02:42 +03:00
parent 5e214c4b4a
commit 45e473cac8
4 changed files with 36 additions and 9 deletions
@@ -1428,6 +1428,26 @@ public class PyTypeTest extends PyTestCase {
"expr = raw_input()");
}
// PY-19723
public void testPositionalArgs() {
doTest("Tuple[int, ...]",
"def foo(*args):\n" +
" \"\"\"\n" +
" :type args: int\n" +
" \"\"\"\n" +
" expr = args");
}
// PY-19723
public void testKeywordArgs() {
doTest("Dict[str, int]",
"def foo(**kwargs):\n" +
" \"\"\"\n" +
" :type kwargs: int\n" +
" \"\"\"\n" +
" expr = kwargs");
}
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());