@zzzen/pyright-internal 1.2.0-dev.20230716 → 1.2.0-dev.20230730
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +2 -2
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +0 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +15 -45
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +17 -10
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +36 -12
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +11 -1
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +36 -14
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/namedTuples.js +1 -0
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/patternMatching.js +24 -0
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +4 -2
- package/dist/analyzer/program.js +31 -25
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +5 -0
- package/dist/analyzer/sourceFile.js +11 -5
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.d.ts +7 -2
- package/dist/analyzer/typeCacheUtils.js +11 -7
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +858 -639
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -2
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +43 -8
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +4 -2
- package/dist/analyzer/typeUtils.js +65 -13
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +4 -4
- package/dist/analyzer/types.js +20 -5
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +4 -4
- package/dist/backgroundAnalysisBase.js +6 -6
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +1 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +5 -1
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +7 -10
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +10 -4
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +5 -2
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +7 -4
- package/dist/localization/localize.js +17 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +6 -6
- package/dist/localization/package.nls.de.json +6 -6
- package/dist/localization/package.nls.en-us.json +6 -6
- package/dist/localization/package.nls.es.json +6 -6
- package/dist/localization/package.nls.fr.json +6 -6
- package/dist/localization/package.nls.it.json +6 -6
- package/dist/localization/package.nls.ja.json +6 -6
- package/dist/localization/package.nls.ko.json +6 -6
- package/dist/localization/package.nls.pl.json +6 -6
- package/dist/localization/package.nls.pt-br.json +6 -6
- package/dist/localization/package.nls.qps-ploc.json +6 -6
- package/dist/localization/package.nls.ru.json +6 -6
- package/dist/localization/package.nls.tr.json +6 -6
- package/dist/localization/package.nls.zh-cn.json +6 -6
- package/dist/localization/package.nls.zh-tw.json +6 -6
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/completions.test.js +40 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +12 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.overriddenFunction.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.overriddenFunction.fourslash.js +40 -0
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.overriddenFunction.fourslash.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.js +17 -1
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +24 -2
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +14 -4
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +9 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +8 -4
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/package.json +7 -6
package/dist/analyzer/checker.js
CHANGED
@@ -387,7 +387,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
387
387
|
}
|
388
388
|
// Verify common dunder signatures.
|
389
389
|
this._validateDunderSignatures(node, functionTypeResult.functionType, containingClassNode !== undefined);
|
390
|
-
// Verify TypeGuard
|
390
|
+
// Verify TypeGuard functions.
|
391
391
|
this._validateTypeGuardFunction(node, functionTypeResult.functionType, containingClassNode !== undefined);
|
392
392
|
this._validateFunctionTypeVarUsage(node, functionTypeResult);
|
393
393
|
}
|
@@ -2973,7 +2973,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2973
2973
|
});
|
2974
2974
|
}
|
2975
2975
|
_validateTypeGuardFunction(node, functionType, isMethod) {
|
2976
|
-
var _a;
|
2977
2976
|
const returnType = functionType.details.declaredReturnType;
|
2978
2977
|
if (!returnType) {
|
2979
2978
|
return;
|
@@ -2981,9 +2980,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2981
2980
|
if (!(0, types_1.isClassInstance)(returnType) || !returnType.typeArguments || returnType.typeArguments.length < 1) {
|
2982
2981
|
return;
|
2983
2982
|
}
|
2984
|
-
|
2985
|
-
const isStrictTypeGuard = types_1.ClassType.isBuiltIn(returnType, 'StrictTypeGuard');
|
2986
|
-
if (!isNormalTypeGuard && !isStrictTypeGuard) {
|
2983
|
+
if (!types_1.ClassType.isBuiltIn(returnType, 'TypeGuard')) {
|
2987
2984
|
return;
|
2988
2985
|
}
|
2989
2986
|
// Make sure there's at least one input parameter provided.
|
@@ -2998,25 +2995,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2998
2995
|
if (paramCount < 1) {
|
2999
2996
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeGuardParamCount(), node.name);
|
3000
2997
|
}
|
3001
|
-
if (isStrictTypeGuard) {
|
3002
|
-
const typeGuardType = returnType.typeArguments[0];
|
3003
|
-
// Determine the type of the first parameter.
|
3004
|
-
const paramIndex = isMethod && !types_1.FunctionType.isStaticMethod(functionType) ? 1 : 0;
|
3005
|
-
if (paramIndex >= functionType.details.parameters.length) {
|
3006
|
-
return;
|
3007
|
-
}
|
3008
|
-
const paramType = types_1.FunctionType.getEffectiveParameterType(functionType, paramIndex);
|
3009
|
-
// Verify that the typeGuardType is a narrower type than the paramType.
|
3010
|
-
if (!this._evaluator.assignType(paramType, typeGuardType)) {
|
3011
|
-
const returnAnnotation = node.returnTypeAnnotation || ((_a = node.functionAnnotationComment) === null || _a === void 0 ? void 0 : _a.returnTypeAnnotation);
|
3012
|
-
if (returnAnnotation) {
|
3013
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.strictTypeGuardReturnType().format({
|
3014
|
-
type: this._evaluator.printType(paramType),
|
3015
|
-
returnType: this._evaluator.printType(typeGuardType),
|
3016
|
-
}), returnAnnotation);
|
3017
|
-
}
|
3018
|
-
}
|
3019
|
-
}
|
3020
2998
|
}
|
3021
2999
|
_validateDunderSignatures(node, functionType, isMethod) {
|
3022
3000
|
var _a;
|
@@ -3053,21 +3031,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3053
3031
|
const implicitlyReturnsNone = this._evaluator.isAfterNodeReachable(node.suite);
|
3054
3032
|
let declaredReturnType = functionType.details.declaredReturnType;
|
3055
3033
|
if (declaredReturnType) {
|
3056
|
-
|
3057
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.declaredReturnTypeUnknown(), returnAnnotation);
|
3058
|
-
}
|
3059
|
-
else if ((0, typeUtils_1.isPartlyUnknown)(declaredReturnType)) {
|
3060
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.declaredReturnTypePartiallyUnknown().format({
|
3061
|
-
returnType: this._evaluator.printType(declaredReturnType, { expandTypeAlias: true }),
|
3062
|
-
}), returnAnnotation);
|
3063
|
-
}
|
3064
|
-
const diag = new diagnostic_1.DiagnosticAddendum();
|
3034
|
+
this._reportUnknownReturnResult(node, declaredReturnType);
|
3065
3035
|
if ((0, types_1.isTypeVar)(declaredReturnType) &&
|
3066
3036
|
declaredReturnType.details.declaredVariance === 4 /* Contravariant */) {
|
3067
|
-
|
3068
|
-
name: types_1.TypeVarType.getReadableName(declaredReturnType),
|
3069
|
-
}));
|
3070
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnTypeContravariant() + diag.getString(), returnAnnotation);
|
3037
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnTypeContravariant(), returnAnnotation);
|
3071
3038
|
}
|
3072
3039
|
}
|
3073
3040
|
// Wrap the declared type in a generator type if the function is a generator.
|
@@ -3106,14 +3073,17 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3106
3073
|
}
|
3107
3074
|
else {
|
3108
3075
|
const inferredReturnType = this._evaluator.getFunctionInferredReturnType(functionType);
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3076
|
+
this._reportUnknownReturnResult(node, inferredReturnType);
|
3077
|
+
}
|
3078
|
+
}
|
3079
|
+
_reportUnknownReturnResult(node, returnType) {
|
3080
|
+
if ((0, types_1.isUnknown)(returnType)) {
|
3081
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypeUnknown(), node.name);
|
3082
|
+
}
|
3083
|
+
else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
|
3084
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypePartiallyUnknown().format({
|
3085
|
+
returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
|
3086
|
+
}), node.name);
|
3117
3087
|
}
|
3118
3088
|
}
|
3119
3089
|
// Validates that any overridden member variables are not marked
|