Update PyTypeParser to use PyTypeUtil.toPositionalContainerType and PyTypeUtil.toKeywordContainerType while parsing PEP-484 function type comment

This commit is contained in:
Semyon Proshev
2016-11-25 19:02:43 +03:00
parent 45ec95d939
commit 82e63e7295
@@ -411,19 +411,16 @@ public class PyTypeParser {
return paramResult;
}
else if (starCount == 1) {
final PyClassType tupleType = PyTupleType.createHomogeneous(anchor, type);
if (tupleType != null) {
return paramResult.withType(tupleType);
final PyTupleType positionalType = PyTypeUtil.toPositionalContainerType(anchor, type);
if (positionalType != null) {
return paramResult.withType(positionalType);
}
return EMPTY_RESULT;
}
else if (starCount == 2) {
final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(anchor);
final PyClassType dictType = builtinCache.getDictType();
if (dictType != null) {
final PyClass pyClass = dictType.getPyClass();
return paramResult.withType(new PyCollectionTypeImpl(pyClass, false,
Arrays.asList(builtinCache.getStrType(), type)));
final PyCollectionType keywordType = PyTypeUtil.toKeywordContainerType(anchor, type);
if (keywordType != null) {
return paramResult.withType(keywordType);
}
return EMPTY_RESULT;
}