mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 16:06:39 +03:00
Added new diagnostic rule reportCallIssue
that covers issues relating to call expressions and arguments. This partially addresses #6973. (#7076)
This commit is contained in:
parent
63637459ca
commit
6ac1a7eebf
@ -96,6 +96,8 @@ The following settings control pyright’s diagnostic output (warnings or errors
|
|||||||
|
|
||||||
<a name="reportAttributeAccessIssue"></a> **reportAttributeAccessIssue** [boolean or string, optional]: Generate or suppress diagnostics related to attribute accesses. The default value for this setting is `"error"`.
|
<a name="reportAttributeAccessIssue"></a> **reportAttributeAccessIssue** [boolean or string, optional]: Generate or suppress diagnostics related to attribute accesses. The default value for this setting is `"error"`.
|
||||||
|
|
||||||
|
<a name="reportCallIssue"></a> **reportCallIssue** [boolean or string, optional]: Generate or suppress diagnostics related to call expressions and arguments passed to a call target. The default value for this setting is `"error"`.
|
||||||
|
|
||||||
<a name="reportInconsistentOverload"></a> **reportInconsistentOverload** [boolean or string, optional]: Generate or suppress diagnostics for an overloaded function that has overload signatures that are inconsistent with each other or with the implementation. The default value for this setting is `"error"`.
|
<a name="reportInconsistentOverload"></a> **reportInconsistentOverload** [boolean or string, optional]: Generate or suppress diagnostics for an overloaded function that has overload signatures that are inconsistent with each other or with the implementation. The default value for this setting is `"error"`.
|
||||||
|
|
||||||
<a name="reportIndexIssue"></a> **reportIndexIssue** [boolean or string, optional]: Generate or suppress diagnostics related to index operations and expressions. The default value for this setting is `"error"`.
|
<a name="reportIndexIssue"></a> **reportIndexIssue** [boolean or string, optional]: Generate or suppress diagnostics related to index operations and expressions. The default value for this setting is `"error"`.
|
||||||
@ -348,6 +350,7 @@ The following table lists the default severity levels for each diagnostic rule w
|
|||||||
| reportAbstractUsage | "none" | "error" | "error" | "error" |
|
| reportAbstractUsage | "none" | "error" | "error" | "error" |
|
||||||
| reportAssertTypeFailure | "none" | "error" | "error" | "error" |
|
| reportAssertTypeFailure | "none" | "error" | "error" | "error" |
|
||||||
| reportAttributeAccessIssue | "none" | "error" | "error" | "error" |
|
| reportAttributeAccessIssue | "none" | "error" | "error" | "error" |
|
||||||
|
| reportCallIssue | "none" | "error" | "error" | "error" |
|
||||||
| reportGeneralTypeIssues | "none" | "error" | "error" | "error" |
|
| reportGeneralTypeIssues | "none" | "error" | "error" | "error" |
|
||||||
| reportInconsistentOverload | "none" | "error" | "error" | "error" |
|
| reportInconsistentOverload | "none" | "error" | "error" | "error" |
|
||||||
| reportIndexIssue | "none" | "error" | "error" | "error" |
|
| reportIndexIssue | "none" | "error" | "error" | "error" |
|
||||||
|
@ -170,7 +170,7 @@ function applyPartialTransform(
|
|||||||
if (applicableOverloads.length === 0) {
|
if (applicableOverloads.length === 0) {
|
||||||
if (sawArgErrors) {
|
if (sawArgErrors) {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.noOverload().format({
|
LocMessage.noOverload().format({
|
||||||
name: origFunctionType.overloads[0].details.name,
|
name: origFunctionType.overloads[0].details.name,
|
||||||
}),
|
}),
|
||||||
@ -275,7 +275,7 @@ function applyPartialTransformToFunction(
|
|||||||
if (!reportedPositionalError) {
|
if (!reportedPositionalError) {
|
||||||
if (errorNode) {
|
if (errorNode) {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
paramListDetails.positionParamCount === 1
|
paramListDetails.positionParamCount === 1
|
||||||
? LocMessage.argPositionalExpectedOne()
|
? LocMessage.argPositionalExpectedOne()
|
||||||
: LocMessage.argPositionalExpectedCount().format({
|
: LocMessage.argPositionalExpectedCount().format({
|
||||||
@ -331,7 +331,7 @@ function applyPartialTransformToFunction(
|
|||||||
if (paramListDetails.kwargsIndex === undefined) {
|
if (paramListDetails.kwargsIndex === undefined) {
|
||||||
if (errorNode) {
|
if (errorNode) {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramNameMissing().format({ name: arg.name.value }),
|
LocMessage.paramNameMissing().format({ name: arg.name.value }),
|
||||||
arg.name
|
arg.name
|
||||||
);
|
);
|
||||||
@ -374,7 +374,7 @@ function applyPartialTransformToFunction(
|
|||||||
if (paramMap.has(paramName)) {
|
if (paramMap.has(paramName)) {
|
||||||
if (errorNode) {
|
if (errorNode) {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramAlreadyAssigned().format({ name: arg.name.value }),
|
LocMessage.paramAlreadyAssigned().format({ name: arg.name.value }),
|
||||||
arg.name
|
arg.name
|
||||||
);
|
);
|
||||||
|
@ -1020,7 +1020,7 @@ export function validateDataClassTransformDecorator(
|
|||||||
node.arguments.forEach((arg) => {
|
node.arguments.forEach((arg) => {
|
||||||
if (!arg.name || arg.argumentCategory !== ArgumentCategory.Simple) {
|
if (!arg.name || arg.argumentCategory !== ArgumentCategory.Simple) {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.dataClassTransformPositionalParam(),
|
LocMessage.dataClassTransformPositionalParam(),
|
||||||
arg
|
arg
|
||||||
);
|
);
|
||||||
|
@ -82,7 +82,7 @@ export function createNamedTupleType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argList.length === 0) {
|
if (argList.length === 0) {
|
||||||
evaluator.addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.namedTupleFirstArg(), errorNode);
|
evaluator.addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.namedTupleFirstArg(), errorNode);
|
||||||
} else {
|
} else {
|
||||||
const nameArg = argList[0];
|
const nameArg = argList[0];
|
||||||
if (nameArg.argumentCategory !== ArgumentCategory.Simple) {
|
if (nameArg.argumentCategory !== ArgumentCategory.Simple) {
|
||||||
@ -162,7 +162,7 @@ export function createNamedTupleType(
|
|||||||
const entryTypes: Type[] = [];
|
const entryTypes: Type[] = [];
|
||||||
|
|
||||||
if (argList.length < 2) {
|
if (argList.length < 2) {
|
||||||
evaluator.addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.namedTupleSecondArg(), errorNode);
|
evaluator.addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.namedTupleSecondArg(), errorNode);
|
||||||
addGenericGetAttribute = true;
|
addGenericGetAttribute = true;
|
||||||
} else {
|
} else {
|
||||||
const entriesArg = argList[1];
|
const entriesArg = argList[1];
|
||||||
|
@ -8898,7 +8898,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
|
|
||||||
diagAddendum.addMessage(LocAddendum.argumentTypes().format({ types: argTypes.join(', ') }));
|
diagAddendum.addMessage(LocAddendum.argumentTypes().format({ types: argTypes.join(', ') }));
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.noOverload().format({ name: functionName }) + diagAddendum.getString(),
|
LocMessage.noOverload().format({ name: functionName }) + diagAddendum.getString(),
|
||||||
errorNode
|
errorNode
|
||||||
);
|
);
|
||||||
@ -8925,7 +8925,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (emitNoOverloadFoundError) {
|
if (emitNoOverloadFoundError) {
|
||||||
const functionName = bestMatch.overload.details.name || '<anonymous function>';
|
const functionName = bestMatch.overload.details.name || '<anonymous function>';
|
||||||
const diagnostic = addDiagnostic(
|
const diagnostic = addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.noOverload().format({ name: functionName }),
|
LocMessage.noOverload().format({ name: functionName }),
|
||||||
errorNode
|
errorNode
|
||||||
);
|
);
|
||||||
@ -9116,7 +9116,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (callTypeResult.type.specialForm) {
|
if (callTypeResult.type.specialForm) {
|
||||||
const exprNode = errorNode.nodeType === ParseNodeType.Call ? errorNode.leftExpression : errorNode;
|
const exprNode = errorNode.nodeType === ParseNodeType.Call ? errorNode.leftExpression : errorNode;
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.objectNotCallable().format({
|
LocMessage.objectNotCallable().format({
|
||||||
type: printType(callTypeResult.type, { expandTypeAlias: true }),
|
type: printType(callTypeResult.type, { expandTypeAlias: true }),
|
||||||
}),
|
}),
|
||||||
@ -9284,7 +9284,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TypeCategory.Module: {
|
case TypeCategory.Module: {
|
||||||
addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.moduleNotCallable(), errorNode);
|
addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.moduleNotCallable(), errorNode);
|
||||||
|
|
||||||
return { argumentErrors: true };
|
return { argumentErrors: true };
|
||||||
}
|
}
|
||||||
@ -9304,7 +9304,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
): CallResult {
|
): CallResult {
|
||||||
if (TypeBase.isInstantiable(expandedCallType)) {
|
if (TypeBase.isInstantiable(expandedCallType)) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.callableNotInstantiable().format({
|
LocMessage.callableNotInstantiable().format({
|
||||||
type: printType(expandedCallType),
|
type: printType(expandedCallType),
|
||||||
}),
|
}),
|
||||||
@ -9544,7 +9544,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
inferenceContext: InferenceContext | undefined
|
inferenceContext: InferenceContext | undefined
|
||||||
): CallResult {
|
): CallResult {
|
||||||
if (expandedCallType.literalValue !== undefined) {
|
if (expandedCallType.literalValue !== undefined) {
|
||||||
addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.literalNotCallable(), errorNode);
|
addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.literalNotCallable(), errorNode);
|
||||||
|
|
||||||
return { returnType: UnknownType.create(), argumentErrors: true };
|
return { returnType: UnknownType.create(), argumentErrors: true };
|
||||||
}
|
}
|
||||||
@ -9556,7 +9556,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (isInstantiableMetaclass(expandedCallType)) {
|
if (isInstantiableMetaclass(expandedCallType)) {
|
||||||
if (expandedCallType.typeArguments && expandedCallType.isTypeArgumentExplicit) {
|
if (expandedCallType.typeArguments && expandedCallType.isTypeArgumentExplicit) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.objectNotCallable().format({
|
LocMessage.objectNotCallable().format({
|
||||||
type: printType(expandedCallType),
|
type: printType(expandedCallType),
|
||||||
}),
|
}),
|
||||||
@ -9666,7 +9666,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
|
|
||||||
if (ClassType.isSpecialFormClass(expandedCallType)) {
|
if (ClassType.isSpecialFormClass(expandedCallType)) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.typeNotIntantiable().format({ type: className }),
|
LocMessage.typeNotIntantiable().format({ type: className }),
|
||||||
errorNode
|
errorNode
|
||||||
);
|
);
|
||||||
@ -9837,7 +9837,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
|
|
||||||
if (!callMethodType) {
|
if (!callMethodType) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.objectNotCallable().format({
|
LocMessage.objectNotCallable().format({
|
||||||
type: printType(expandedCallType),
|
type: printType(expandedCallType),
|
||||||
}),
|
}),
|
||||||
@ -10102,7 +10102,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (argIndex < positionalOnlyLimitIndex && argList[argIndex].name) {
|
if (argIndex < positionalOnlyLimitIndex && argList[argIndex].name) {
|
||||||
const nameNode = argList[argIndex].name;
|
const nameNode = argList[argIndex].name;
|
||||||
if (nameNode) {
|
if (nameNode) {
|
||||||
addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.argPositional(), nameNode);
|
addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.argPositional(), nameNode);
|
||||||
reportedArgError = true;
|
reportedArgError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10142,7 +10142,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (tooManyPositionals) {
|
if (tooManyPositionals) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
positionParamLimitIndex === 1
|
positionParamLimitIndex === 1
|
||||||
? LocMessage.argPositionalExpectedOne()
|
? LocMessage.argPositionalExpectedOne()
|
||||||
: LocMessage.argPositionalExpectedCount().format({
|
: LocMessage.argPositionalExpectedCount().format({
|
||||||
@ -10187,7 +10187,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
) {
|
) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
positionParamLimitIndex === 1
|
positionParamLimitIndex === 1
|
||||||
? LocMessage.argPositionalExpectedOne()
|
? LocMessage.argPositionalExpectedOne()
|
||||||
: LocMessage.argPositionalExpectedCount().format({
|
: LocMessage.argPositionalExpectedCount().format({
|
||||||
@ -10266,7 +10266,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (isParamVariadic && !isArgCompatibleWithVariadic) {
|
if (isParamVariadic && !isArgCompatibleWithVariadic) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.unpackedArgWithVariadicParam(),
|
LocMessage.unpackedArgWithVariadicParam(),
|
||||||
argList[argIndex].valueExpression || errorNode
|
argList[argIndex].valueExpression || errorNode
|
||||||
);
|
);
|
||||||
@ -10340,7 +10340,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
// Have we run out of arguments and still have parameters left to fill?
|
// Have we run out of arguments and still have parameters left to fill?
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
remainingArgCount === 1
|
remainingArgCount === 1
|
||||||
? LocMessage.argMorePositionalExpectedOne()
|
? LocMessage.argMorePositionalExpectedOne()
|
||||||
: LocMessage.argMorePositionalExpectedCount().format({
|
: LocMessage.argMorePositionalExpectedCount().format({
|
||||||
@ -10441,7 +10441,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (argsRemainingCount > 0) {
|
if (argsRemainingCount > 0) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
argsRemainingCount === 1
|
argsRemainingCount === 1
|
||||||
? LocMessage.argMorePositionalExpectedOne()
|
? LocMessage.argMorePositionalExpectedOne()
|
||||||
: LocMessage.argMorePositionalExpectedCount().format({
|
: LocMessage.argMorePositionalExpectedCount().format({
|
||||||
@ -10536,7 +10536,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (!diag.isEmpty()) {
|
if (!diag.isEmpty()) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.unpackedTypedDictArgument() + diag.getString(),
|
LocMessage.unpackedTypedDictArgument() + diag.getString(),
|
||||||
argList[argIndex].valueExpression || errorNode
|
argList[argIndex].valueExpression || errorNode
|
||||||
);
|
);
|
||||||
@ -10615,7 +10615,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (!isValidMappingType) {
|
if (!isValidMappingType) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.unpackedDictArgumentNotMapping(),
|
LocMessage.unpackedDictArgumentNotMapping(),
|
||||||
argList[argIndex].valueExpression || errorNode
|
argList[argIndex].valueExpression || errorNode
|
||||||
);
|
);
|
||||||
@ -10640,7 +10640,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (paramEntry.argsReceived > 0) {
|
if (paramEntry.argsReceived > 0) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }),
|
LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }),
|
||||||
paramName
|
paramName
|
||||||
);
|
);
|
||||||
@ -10692,7 +10692,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
} else {
|
} else {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramNameMissing().format({ name: paramName.value }),
|
LocMessage.paramNameMissing().format({ name: paramName.value }),
|
||||||
paramName
|
paramName
|
||||||
);
|
);
|
||||||
@ -10705,7 +10705,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
} else {
|
} else {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
positionParamLimitIndex === 1
|
positionParamLimitIndex === 1
|
||||||
? LocMessage.argPositionalExpectedOne()
|
? LocMessage.argPositionalExpectedOne()
|
||||||
: LocMessage.argPositionalExpectedCount().format({
|
: LocMessage.argPositionalExpectedCount().format({
|
||||||
@ -10795,7 +10795,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
|
const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
unassignedParams.length === 1
|
unassignedParams.length === 1
|
||||||
? LocMessage.argMissingForParam().format({ name: missingParamNames })
|
? LocMessage.argMissingForParam().format({ name: missingParamNames })
|
||||||
: LocMessage.argMissingForParams().format({ names: missingParamNames }),
|
: LocMessage.argMissingForParams().format({ names: missingParamNames }),
|
||||||
@ -10882,7 +10882,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
) {
|
) {
|
||||||
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.typeVarTupleMustBeUnpacked(),
|
LocMessage.typeVarTupleMustBeUnpacked(),
|
||||||
argParam.argument.valueExpression ?? errorNode
|
argParam.argument.valueExpression ?? errorNode
|
||||||
);
|
);
|
||||||
@ -11365,7 +11365,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
if (!sawParamSpecArgs || !sawParamSpecKwargs) {
|
if (!sawParamSpecArgs || !sawParamSpecKwargs) {
|
||||||
if (!isTypeIncomplete) {
|
if (!isTypeIncomplete) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramSpecArgsMissing().format({ type: printType(type.details.paramSpec) }),
|
LocMessage.paramSpecArgsMissing().format({ type: printType(type.details.paramSpec) }),
|
||||||
errorNode
|
errorNode
|
||||||
);
|
);
|
||||||
@ -11760,7 +11760,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
|
|
||||||
if (argumentErrors) {
|
if (argumentErrors) {
|
||||||
addDiagnostic(
|
addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.paramSpecArgsMissing().format({
|
LocMessage.paramSpecArgsMissing().format({
|
||||||
type: printType(functionType.details.paramSpec),
|
type: printType(functionType.details.paramSpec),
|
||||||
}),
|
}),
|
||||||
@ -12646,7 +12646,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
|||||||
let className = '';
|
let className = '';
|
||||||
|
|
||||||
if (argList.length !== 2) {
|
if (argList.length !== 2) {
|
||||||
addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.newTypeParamCount(), errorNode);
|
addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.newTypeParamCount(), errorNode);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export function createTypedDictType(
|
|||||||
// Point2D = TypedDict('Point2D', x=int, y=int, label=str)
|
// Point2D = TypedDict('Point2D', x=int, y=int, label=str)
|
||||||
let className: string | undefined;
|
let className: string | undefined;
|
||||||
if (argList.length === 0) {
|
if (argList.length === 0) {
|
||||||
evaluator.addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.typedDictFirstArg(), errorNode);
|
evaluator.addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.typedDictFirstArg(), errorNode);
|
||||||
} else {
|
} else {
|
||||||
const nameArg = argList[0];
|
const nameArg = argList[0];
|
||||||
if (
|
if (
|
||||||
@ -119,7 +119,7 @@ export function createTypedDictType(
|
|||||||
|
|
||||||
let usingDictSyntax = false;
|
let usingDictSyntax = false;
|
||||||
if (argList.length < 2) {
|
if (argList.length < 2) {
|
||||||
evaluator.addDiagnostic(DiagnosticRule.reportGeneralTypeIssues, LocMessage.typedDictSecondArgDict(), errorNode);
|
evaluator.addDiagnostic(DiagnosticRule.reportCallIssue, LocMessage.typedDictSecondArgDict(), errorNode);
|
||||||
} else {
|
} else {
|
||||||
const entriesArg = argList[1];
|
const entriesArg = argList[1];
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ export function createTypedDictType(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
evaluator.addDiagnostic(
|
evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportCallIssue,
|
||||||
LocMessage.typedDictExtraArgs(),
|
LocMessage.typedDictExtraArgs(),
|
||||||
arg.valueExpression || errorNode
|
arg.valueExpression || errorNode
|
||||||
);
|
);
|
||||||
|
@ -168,6 +168,9 @@ export interface DiagnosticRuleSet {
|
|||||||
// Report issues related to attribute access expressions?
|
// Report issues related to attribute access expressions?
|
||||||
reportAttributeAccessIssue: DiagnosticLevel;
|
reportAttributeAccessIssue: DiagnosticLevel;
|
||||||
|
|
||||||
|
// Report issues related to call expressions?
|
||||||
|
reportCallIssue: DiagnosticLevel;
|
||||||
|
|
||||||
// Report inconsistencies with function overload signatures?
|
// Report inconsistencies with function overload signatures?
|
||||||
reportInconsistentOverload: DiagnosticLevel;
|
reportInconsistentOverload: DiagnosticLevel;
|
||||||
|
|
||||||
@ -411,6 +414,7 @@ export function getDiagLevelDiagnosticRules() {
|
|||||||
DiagnosticRule.reportAbstractUsage,
|
DiagnosticRule.reportAbstractUsage,
|
||||||
DiagnosticRule.reportAssertTypeFailure,
|
DiagnosticRule.reportAssertTypeFailure,
|
||||||
DiagnosticRule.reportAttributeAccessIssue,
|
DiagnosticRule.reportAttributeAccessIssue,
|
||||||
|
DiagnosticRule.reportCallIssue,
|
||||||
DiagnosticRule.reportInconsistentOverload,
|
DiagnosticRule.reportInconsistentOverload,
|
||||||
DiagnosticRule.reportIndexIssue,
|
DiagnosticRule.reportIndexIssue,
|
||||||
DiagnosticRule.reportInvalidTypeArguments,
|
DiagnosticRule.reportInvalidTypeArguments,
|
||||||
@ -512,6 +516,7 @@ export function getOffDiagnosticRuleSet(): DiagnosticRuleSet {
|
|||||||
reportAbstractUsage: 'none',
|
reportAbstractUsage: 'none',
|
||||||
reportAssertTypeFailure: 'none',
|
reportAssertTypeFailure: 'none',
|
||||||
reportAttributeAccessIssue: 'none',
|
reportAttributeAccessIssue: 'none',
|
||||||
|
reportCallIssue: 'none',
|
||||||
reportInconsistentOverload: 'none',
|
reportInconsistentOverload: 'none',
|
||||||
reportIndexIssue: 'none',
|
reportIndexIssue: 'none',
|
||||||
reportInvalidTypeArguments: 'none',
|
reportInvalidTypeArguments: 'none',
|
||||||
@ -609,6 +614,7 @@ export function getBasicDiagnosticRuleSet(): DiagnosticRuleSet {
|
|||||||
reportAbstractUsage: 'error',
|
reportAbstractUsage: 'error',
|
||||||
reportAssertTypeFailure: 'error',
|
reportAssertTypeFailure: 'error',
|
||||||
reportAttributeAccessIssue: 'error',
|
reportAttributeAccessIssue: 'error',
|
||||||
|
reportCallIssue: 'error',
|
||||||
reportInconsistentOverload: 'error',
|
reportInconsistentOverload: 'error',
|
||||||
reportIndexIssue: 'error',
|
reportIndexIssue: 'error',
|
||||||
reportInvalidTypeArguments: 'error',
|
reportInvalidTypeArguments: 'error',
|
||||||
@ -706,6 +712,7 @@ export function getStandardDiagnosticRuleSet(): DiagnosticRuleSet {
|
|||||||
reportAbstractUsage: 'error',
|
reportAbstractUsage: 'error',
|
||||||
reportAssertTypeFailure: 'error',
|
reportAssertTypeFailure: 'error',
|
||||||
reportAttributeAccessIssue: 'error',
|
reportAttributeAccessIssue: 'error',
|
||||||
|
reportCallIssue: 'error',
|
||||||
reportInconsistentOverload: 'error',
|
reportInconsistentOverload: 'error',
|
||||||
reportIndexIssue: 'error',
|
reportIndexIssue: 'error',
|
||||||
reportInvalidTypeArguments: 'error',
|
reportInvalidTypeArguments: 'error',
|
||||||
@ -803,6 +810,7 @@ export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet {
|
|||||||
reportAbstractUsage: 'error',
|
reportAbstractUsage: 'error',
|
||||||
reportAssertTypeFailure: 'error',
|
reportAssertTypeFailure: 'error',
|
||||||
reportAttributeAccessIssue: 'error',
|
reportAttributeAccessIssue: 'error',
|
||||||
|
reportCallIssue: 'error',
|
||||||
reportInconsistentOverload: 'error',
|
reportInconsistentOverload: 'error',
|
||||||
reportIndexIssue: 'error',
|
reportIndexIssue: 'error',
|
||||||
reportInvalidTypeArguments: 'error',
|
reportInvalidTypeArguments: 'error',
|
||||||
|
@ -38,6 +38,7 @@ export enum DiagnosticRule {
|
|||||||
reportAbstractUsage = 'reportAbstractUsage',
|
reportAbstractUsage = 'reportAbstractUsage',
|
||||||
reportAssertTypeFailure = 'reportAssertTypeFailure',
|
reportAssertTypeFailure = 'reportAssertTypeFailure',
|
||||||
reportAttributeAccessIssue = 'reportAttributeAccessIssue',
|
reportAttributeAccessIssue = 'reportAttributeAccessIssue',
|
||||||
|
reportCallIssue = 'reportCallIssue',
|
||||||
reportInconsistentOverload = 'reportInconsistentOverload',
|
reportInconsistentOverload = 'reportInconsistentOverload',
|
||||||
reportIndexIssue = 'reportIndexIssue',
|
reportIndexIssue = 'reportIndexIssue',
|
||||||
reportInvalidTypeArguments = 'reportInvalidTypeArguments',
|
reportInvalidTypeArguments = 'reportInvalidTypeArguments',
|
||||||
|
@ -463,6 +463,22 @@
|
|||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"reportCallIssue": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"boolean"
|
||||||
|
],
|
||||||
|
"description": "Diagnostics for issues involving call expressions and arguments.",
|
||||||
|
"default": "error",
|
||||||
|
"enum": [
|
||||||
|
"none",
|
||||||
|
"information",
|
||||||
|
"warning",
|
||||||
|
"error",
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
"reportInconsistentOverload": {
|
"reportInconsistentOverload": {
|
||||||
"type": [
|
"type": [
|
||||||
"string",
|
"string",
|
||||||
|
@ -269,6 +269,12 @@
|
|||||||
"title": "Controls reporting of issues related to attribute accesses",
|
"title": "Controls reporting of issues related to attribute accesses",
|
||||||
"default": "error"
|
"default": "error"
|
||||||
},
|
},
|
||||||
|
"reportCallIssue": {
|
||||||
|
"$id": "#/properties/reportCallIssue",
|
||||||
|
"$ref": "#/definitions/diagnostic",
|
||||||
|
"title": "Controls reporting of issues related to call expressions and arguments",
|
||||||
|
"default": "error"
|
||||||
|
},
|
||||||
"reportInconsistentOverload": {
|
"reportInconsistentOverload": {
|
||||||
"$id": "#/properties/reportInconsistentOverload",
|
"$id": "#/properties/reportInconsistentOverload",
|
||||||
"$ref": "#/definitions/diagnostic",
|
"$ref": "#/definitions/diagnostic",
|
||||||
|
Loading…
Reference in New Issue
Block a user