@zzzen/pyright-internal 1.2.0-dev.20230528 → 1.2.0-dev.20230611
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/checker.js +42 -29
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +1 -1
- package/dist/analyzer/constraintSolver.js +31 -16
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +35 -10
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +2 -0
- package/dist/analyzer/importResolver.js +57 -35
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/operations.js +2 -0
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/patternMatching.js +2 -1
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +19 -12
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +182 -183
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.js +13 -0
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +3 -2
- package/dist/analyzer/sourceFile.js +204 -194
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +128 -70
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +2 -0
- package/dist/analyzer/typeGuards.js +1 -1
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +13 -14
- package/dist/analyzer/typeUtils.js +126 -100
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.js +12 -1
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.d.ts +22 -0
- package/dist/analyzer/typeWalker.js +164 -0
- package/dist/analyzer/typeWalker.js.map +1 -0
- package/dist/analyzer/types.d.ts +3 -2
- package/dist/analyzer/types.js +19 -12
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +5 -3
- package/dist/backgroundAnalysisBase.js +2 -2
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +12 -9
- package/dist/backgroundThreadBase.js +28 -20
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/charCodes.d.ts +147 -0
- package/dist/common/charCodes.js +164 -0
- package/dist/common/charCodes.js.map +1 -0
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +3 -0
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -3
- package/dist/languageServerBase.js +2 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +2 -0
- package/dist/languageService/definitionProvider.js +82 -74
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +16 -8
- package/dist/languageService/hoverProvider.js +53 -53
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +10 -6
- package/dist/localization/localize.js +4 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +4 -3
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js +10 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -0
- package/dist/pyrightFileSystem.js +3 -0
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +1 -0
- package/dist/readonlyAugmentedFileSystem.js +3 -0
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/tests/checker.test.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +1 -0
- package/dist/tests/harness/fourslash/testLanguageService.js +3 -0
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +2 -2
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +12 -1
- package/dist/tests/harness/vfs/filesystem.js +33 -6
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/service.test.js +10 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +13 -2
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +5 -1
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +9 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +21 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +2 -0
- package/dist/workspaceFactory.js +11 -2
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -2
package/dist/analyzer/checker.js
CHANGED
@@ -225,6 +225,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
225
225
|
if (types_1.ClassType.isEnumClass(classTypeResult.classType)) {
|
226
226
|
this._validateEnumClassOverride(node, classTypeResult.classType);
|
227
227
|
}
|
228
|
+
this._evaluator.validateInitSubclassArgs(node, classTypeResult.classType);
|
228
229
|
}
|
229
230
|
this._scopedNodes.push(node);
|
230
231
|
return false;
|
@@ -4355,38 +4356,50 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4355
4356
|
}
|
4356
4357
|
}
|
4357
4358
|
}
|
4359
|
+
// Determines whether a yield or yield from node is compatible with the
|
4360
|
+
// return type annotation of the containing function.
|
4358
4361
|
_validateYieldType(node, yieldType) {
|
4359
|
-
|
4360
|
-
let declaredYieldType;
|
4362
|
+
var _a;
|
4361
4363
|
const enclosingFunctionNode = ParseTreeUtils.getEnclosingFunction(node);
|
4362
|
-
if (enclosingFunctionNode) {
|
4363
|
-
|
4364
|
-
if (functionTypeResult) {
|
4365
|
-
(0, debug_1.assert)((0, types_1.isFunction)(functionTypeResult.functionType));
|
4366
|
-
declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionTypeResult.functionType);
|
4367
|
-
if (declaredReturnType) {
|
4368
|
-
declaredYieldType = (0, typeUtils_1.getGeneratorYieldType)(declaredReturnType, !!enclosingFunctionNode.isAsync);
|
4369
|
-
}
|
4370
|
-
if (declaredReturnType && !declaredYieldType && enclosingFunctionNode.returnTypeAnnotation) {
|
4371
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, enclosingFunctionNode.isAsync
|
4372
|
-
? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
|
4373
|
-
: localize_1.Localizer.Diagnostic.generatorSyncReturnType(), enclosingFunctionNode.returnTypeAnnotation);
|
4374
|
-
}
|
4375
|
-
}
|
4364
|
+
if (!enclosingFunctionNode || !enclosingFunctionNode.returnTypeAnnotation) {
|
4365
|
+
return;
|
4376
4366
|
}
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4367
|
+
const functionTypeResult = this._evaluator.getTypeOfFunction(enclosingFunctionNode);
|
4368
|
+
if (!functionTypeResult) {
|
4369
|
+
return;
|
4370
|
+
}
|
4371
|
+
const declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionTypeResult.functionType);
|
4372
|
+
if (!declaredReturnType) {
|
4373
|
+
return;
|
4374
|
+
}
|
4375
|
+
let generatorType;
|
4376
|
+
if (!enclosingFunctionNode.isAsync &&
|
4377
|
+
(0, types_1.isClassInstance)(declaredReturnType) &&
|
4378
|
+
types_1.ClassType.isBuiltIn(declaredReturnType, 'AwaitableGenerator')) {
|
4379
|
+
// Handle the old-style (pre-await) generator case
|
4380
|
+
// if the return type explicitly uses AwaitableGenerator.
|
4381
|
+
generatorType = this._evaluator.getTypingType(node, 'AwaitableGenerator');
|
4382
|
+
}
|
4383
|
+
else {
|
4384
|
+
generatorType = this._evaluator.getTypingType(node, enclosingFunctionNode.isAsync ? 'AsyncGenerator' : 'Generator');
|
4385
|
+
}
|
4386
|
+
if (!generatorType || !(0, types_1.isInstantiableClass)(generatorType)) {
|
4387
|
+
return;
|
4388
|
+
}
|
4389
|
+
if (!this._evaluator.isNodeReachable(node, /* sourceNode */ undefined)) {
|
4390
|
+
return;
|
4391
|
+
}
|
4392
|
+
if ((0, types_1.isNever)(declaredReturnType)) {
|
4393
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnContainsYield(), node);
|
4394
|
+
return;
|
4395
|
+
}
|
4396
|
+
const specializedGenerator = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(generatorType, [yieldType], /* isTypeArgumentExplicit */ true));
|
4397
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4398
|
+
if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
|
4399
|
+
const errorMessage = enclosingFunctionNode.isAsync
|
4400
|
+
? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
|
4401
|
+
: localize_1.Localizer.Diagnostic.generatorSyncReturnType();
|
4402
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) + diagAddendum.getString(), (_a = node.expression) !== null && _a !== void 0 ? _a : node);
|
4390
4403
|
}
|
4391
4404
|
}
|
4392
4405
|
// Determines whether any of the except statements are unreachable because
|