@zzzen/pyright-internal 1.2.0-dev.20230604 → 1.2.0-dev.20230618
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 +53 -32
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +17 -11
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +3 -2
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +1 -1
- package/dist/analyzer/dataClasses.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/program.d.ts +2 -2
- package/dist/analyzer/program.js +12 -33
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +1 -1
- package/dist/analyzer/protocols.js +225 -205
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.d.ts +2 -2
- package/dist/analyzer/service.js +15 -7
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +272 -137
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -2
- package/dist/analyzer/typeEvaluatorTypes.js +2 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +1 -1
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +20 -21
- package/dist/analyzer/typeUtils.js +162 -107
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +2 -0
- package/dist/analyzer/types.js +7 -3
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +1 -1
- 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/extensibility.d.ts +6 -2
- package/dist/common/extensibility.js.map +1 -1
- 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/common/workspaceEditUtils.d.ts +3 -3
- package/dist/common/workspaceEditUtils.js +23 -13
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +51 -3
- package/dist/languageServerBase.js +5 -5
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.js +2 -0
- package/dist/languageService/completionProvider.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 +7 -6
- package/dist/localization/localize.js +3 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +3 -3
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parser.js +5 -2
- package/dist/parser/parser.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/pyright.js +1 -1
- package/dist/pyright.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/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 +17 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +10 -2
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/workspaceEditUtils.test.js +2 -3
- package/dist/tests/workspaceEditUtils.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;
|
@@ -3737,7 +3738,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3737
3738
|
}
|
3738
3739
|
}
|
3739
3740
|
if (overrideFunction) {
|
3740
|
-
if (!this._evaluator.validateOverrideMethod(overriddenType, overrideFunction,
|
3741
|
+
if (!this._evaluator.validateOverrideMethod(overriddenType, overrideFunction,
|
3742
|
+
/* baseClass */ undefined, diagAddendum,
|
3741
3743
|
/* enforceParamNameMatch */ true)) {
|
3742
3744
|
const decl = overrideFunction.details.declaration;
|
3743
3745
|
if (decl && decl.type === 5 /* Function */) {
|
@@ -3825,6 +3827,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3825
3827
|
if (!mroBaseClass) {
|
3826
3828
|
continue;
|
3827
3829
|
}
|
3830
|
+
(0, debug_1.assert)((0, types_1.isClass)(mroBaseClass));
|
3828
3831
|
const baseClassAndSymbol = (0, typeUtils_1.lookUpClassMember)(mroBaseClass, name, 0 /* Default */);
|
3829
3832
|
if (!baseClassAndSymbol) {
|
3830
3833
|
continue;
|
@@ -3944,7 +3947,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3944
3947
|
// Don't check certain magic functions or private symbols.
|
3945
3948
|
if (!exemptMethods.some((exempt) => exempt === memberName) &&
|
3946
3949
|
!SymbolNameUtils.isPrivateName(memberName)) {
|
3947
|
-
if (!this._evaluator.validateOverrideMethod(baseType, overrideType, diagAddendum, enforceParamNameMatch)) {
|
3950
|
+
if (!this._evaluator.validateOverrideMethod(baseType, overrideType, childClassType, diagAddendum, enforceParamNameMatch)) {
|
3948
3951
|
const decl = (0, types_1.isFunction)(overrideType) && overrideType.details.declaration
|
3949
3952
|
? overrideType.details.declaration
|
3950
3953
|
: (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
|
@@ -4041,7 +4044,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4041
4044
|
else {
|
4042
4045
|
const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(this._evaluator.getEffectiveTypeOfSymbol(subclassPropMethod), childClassType);
|
4043
4046
|
if ((0, types_1.isFunction)(subclassMethodType)) {
|
4044
|
-
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, diagAddendum.createAddendum())) {
|
4047
|
+
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
|
4045
4048
|
diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodIncompatible().format({
|
4046
4049
|
name: methodName,
|
4047
4050
|
}));
|
@@ -4330,6 +4333,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4330
4333
|
if ((0, types_1.isClassInstance)(paramType) && types_1.ClassType.isProtocolClass(paramType)) {
|
4331
4334
|
return;
|
4332
4335
|
}
|
4336
|
+
// If the method starts with a `*args: P.args`, skip the check.
|
4337
|
+
if (paramInfo.category === 1 /* ArgsList */ &&
|
4338
|
+
(0, types_1.isParamSpec)(paramInfo.type) &&
|
4339
|
+
paramInfo.type.paramSpecAccess === 'args') {
|
4340
|
+
return;
|
4341
|
+
}
|
4333
4342
|
// Don't enforce this for an overloaded method because the "self" param
|
4334
4343
|
// annotation can be used as a filter for the overload. This differs from
|
4335
4344
|
// mypy, which enforces this check for overloads, but there are legitimate
|
@@ -4355,38 +4364,50 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4355
4364
|
}
|
4356
4365
|
}
|
4357
4366
|
}
|
4367
|
+
// Determines whether a yield or yield from node is compatible with the
|
4368
|
+
// return type annotation of the containing function.
|
4358
4369
|
_validateYieldType(node, yieldType) {
|
4359
|
-
|
4360
|
-
let declaredYieldType;
|
4370
|
+
var _a;
|
4361
4371
|
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
|
-
}
|
4372
|
+
if (!enclosingFunctionNode || !enclosingFunctionNode.returnTypeAnnotation) {
|
4373
|
+
return;
|
4376
4374
|
}
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4375
|
+
const functionTypeResult = this._evaluator.getTypeOfFunction(enclosingFunctionNode);
|
4376
|
+
if (!functionTypeResult) {
|
4377
|
+
return;
|
4378
|
+
}
|
4379
|
+
const declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionTypeResult.functionType);
|
4380
|
+
if (!declaredReturnType) {
|
4381
|
+
return;
|
4382
|
+
}
|
4383
|
+
let generatorType;
|
4384
|
+
if (!enclosingFunctionNode.isAsync &&
|
4385
|
+
(0, types_1.isClassInstance)(declaredReturnType) &&
|
4386
|
+
types_1.ClassType.isBuiltIn(declaredReturnType, 'AwaitableGenerator')) {
|
4387
|
+
// Handle the old-style (pre-await) generator case
|
4388
|
+
// if the return type explicitly uses AwaitableGenerator.
|
4389
|
+
generatorType = this._evaluator.getTypingType(node, 'AwaitableGenerator');
|
4390
|
+
}
|
4391
|
+
else {
|
4392
|
+
generatorType = this._evaluator.getTypingType(node, enclosingFunctionNode.isAsync ? 'AsyncGenerator' : 'Generator');
|
4393
|
+
}
|
4394
|
+
if (!generatorType || !(0, types_1.isInstantiableClass)(generatorType)) {
|
4395
|
+
return;
|
4396
|
+
}
|
4397
|
+
if (!this._evaluator.isNodeReachable(node, /* sourceNode */ undefined)) {
|
4398
|
+
return;
|
4399
|
+
}
|
4400
|
+
if ((0, types_1.isNever)(declaredReturnType)) {
|
4401
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnContainsYield(), node);
|
4402
|
+
return;
|
4403
|
+
}
|
4404
|
+
const specializedGenerator = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(generatorType, [yieldType], /* isTypeArgumentExplicit */ true));
|
4405
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4406
|
+
if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
|
4407
|
+
const errorMessage = enclosingFunctionNode.isAsync
|
4408
|
+
? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
|
4409
|
+
: localize_1.Localizer.Diagnostic.generatorSyncReturnType();
|
4410
|
+
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
4411
|
}
|
4391
4412
|
}
|
4392
4413
|
// Determines whether any of the except statements are unreachable because
|