mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-14 06:27:41 +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();
|
||||
|
||||
let typeResult: TypeResult | undefined;
|
||||
let reportExpectingTypeErrors = (flags & EvaluatorFlags.ExpectingType) !== 0;
|
||||
|
||||
switch (node.nodeType) {
|
||||
case ParseNodeType.Name: {
|
||||
@ -769,6 +770,10 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
||||
);
|
||||
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 {
|
||||
// Evaluate the format string expressions in this context.
|
||||
node.strings.forEach((str) => {
|
||||
@ -941,7 +946,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
|
||||
fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`);
|
||||
}
|
||||
|
||||
if (flags & EvaluatorFlags.ExpectingType) {
|
||||
if (reportExpectingTypeErrors) {
|
||||
const resultType = transformTypeObjectToClass(typeResult.type);
|
||||
if (!TypeBase.isInstantiable(resultType)) {
|
||||
const isEmptyTuple =
|
||||
|
Loading…
Reference in New Issue
Block a user