mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-13 09:34:44 +03:00
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:
parent
57175e8d3a
commit
3158a22b58
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user