Fixed bug where float and complex values were being inferred as Literal types when PEP 586 clearly states that complex and float values are not supported for Literal.

This commit is contained in:
Eric Traut 2020-10-03 00:19:39 -07:00
parent 57175e8d3a
commit 3158a22b58

View File

@ -909,13 +909,13 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
case ParseNodeType.Number: {
let builtInType = 'float';
if (node.isImaginary) {
builtInType = 'complex';
typeResult = { node, type: getBuiltInObject(node, 'complex') };
} else if (node.isInteger) {
builtInType = 'int';
typeResult = { node, type: cloneBuiltinObjectWithLiteral(node, 'int', node.value) };
} else {
typeResult = { node, type: getBuiltInObject(node, 'float') };
}
typeResult = { node, type: cloneBuiltinObjectWithLiteral(node, builtInType, node.value) };
break;
}