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

Update PyNamedParameterImpl to return collection types with unknown elements instead of tuple and dict.
This commit is contained in:
Semyon Proshev
2016-11-25 19:02:42 +03:00
parent 45e473cac8
commit f8b0121a48
2 changed files with 10 additions and 2 deletions
@@ -223,10 +223,10 @@ public class PyNamedParameterImpl extends PyBaseElementImpl<PyNamedParameterStub
}
}
if (isKeywordContainer()) {
return PyBuiltinCache.getInstance(this).getDictType();
return PyTypeUtil.toKeywordContainerType(this, null);
}
if (isPositionalContainer()) {
return PyBuiltinCache.getInstance(this).getTupleType();
return PyTypeUtil.toPositionalContainerType(this, null);
}
if (context.maySwitchToAST(this)) {
final PyExpression defaultValue = getDefaultValue();
@@ -1448,6 +1448,14 @@ public class PyTypeTest extends PyTestCase {
" expr = kwargs");
}
// PY-19723
public void testIterateOverKeywordArgs() {
doTest("str",
"def foo(**kwargs):\n" +
" for expr in kwargs:\n" +
" pass");
}
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());