mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-14 16:20:11 +03:00
Fixed bug that caused duplicate diagnostics to be reported for quoted type annotations in some cases.
This commit is contained in:
parent
51fd428596
commit
fdca53a939
@ -702,6 +702,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
|||||||
checkForCancellation();
|
checkForCancellation();
|
||||||
|
|
||||||
let typeResult: TypeResult | undefined;
|
let typeResult: TypeResult | undefined;
|
||||||
|
let reportExpectingTypeErrors = (flags & EvaluatorFlags.ExpectingType) !== 0;
|
||||||
|
|
||||||
switch (node.nodeType) {
|
switch (node.nodeType) {
|
||||||
case ParseNodeType.Name: {
|
case ParseNodeType.Name: {
|
||||||
@ -769,6 +770,10 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
|||||||
);
|
);
|
||||||
typeResult = { node, type: UnknownType.create() };
|
typeResult = { node, type: UnknownType.create() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't report expecting type errors again. We will have already
|
||||||
|
// reported them when analyzing the contents of the string.
|
||||||
|
reportExpectingTypeErrors = false;
|
||||||
} else {
|
} else {
|
||||||
// Evaluate the format string expressions in this context.
|
// Evaluate the format string expressions in this context.
|
||||||
node.strings.forEach((str) => {
|
node.strings.forEach((str) => {
|
||||||
@ -941,7 +946,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
|||||||
fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`);
|
fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & EvaluatorFlags.ExpectingType) {
|
if (reportExpectingTypeErrors) {
|
||||||
const resultType = transformTypeObjectToClass(typeResult.type);
|
const resultType = transformTypeObjectToClass(typeResult.type);
|
||||||
if (!TypeBase.isInstantiable(resultType)) {
|
if (!TypeBase.isInstantiable(resultType)) {
|
||||||
const isEmptyTuple =
|
const isEmptyTuple =
|
||||||
|
Loading…
Reference in New Issue
Block a user