@zzzen/pyright-internal 1.2.0-dev.20230730 → 1.2.0-dev.20230806
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/binder.js +3 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +3 -1
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +6 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +9 -5
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/enums.js +1 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.js +15 -14
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -1
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/service.js +7 -7
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +41 -44
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +4 -6
- package/dist/analyzer/typeUtils.js +29 -4
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +6 -3
- package/dist/analyzer/types.js +2 -7
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +2 -1
- package/dist/backgroundThreadBase.js +1 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +0 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.d.ts +1 -1
- package/dist/common/extensibility.d.ts +3 -12
- package/dist/common/extensibility.js +5 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -14
- package/dist/common/fileSystem.js +1 -31
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fileWatcher.d.ts +15 -0
- package/dist/common/fileWatcher.js +34 -0
- package/dist/common/fileWatcher.js.map +1 -0
- package/dist/common/realFileSystem.d.ts +2 -1
- package/dist/common/realFileSystem.js +2 -2
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/languageServerBase.d.ts +9 -6
- package/dist/languageServerBase.js +19 -11
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/hoverProvider.js +1 -6
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +7 -1
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -0
- package/dist/localization/package.nls.de.json +1 -0
- package/dist/localization/package.nls.en-us.json +2 -2
- package/dist/localization/package.nls.es.json +1 -0
- package/dist/localization/package.nls.fr.json +1 -0
- package/dist/localization/package.nls.it.json +1 -0
- package/dist/localization/package.nls.ja.json +1 -0
- package/dist/localization/package.nls.ko.json +1 -0
- package/dist/localization/package.nls.pl.json +1 -0
- package/dist/localization/package.nls.pt-br.json +1 -0
- package/dist/localization/package.nls.qps-ploc.json +1 -0
- package/dist/localization/package.nls.ru.json +1 -0
- package/dist/localization/package.nls.tr.json +1 -0
- package/dist/localization/package.nls.zh-cn.json +1 -0
- package/dist/localization/package.nls.zh-tw.json +1 -0
- package/dist/pyright.js +2 -0
- package/dist/pyright.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +2 -1
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +94 -0
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.d.ts +0 -0
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importPytyped.fourslash.d.ts +0 -0
- package/dist/tests/fourslash/completions.importPytyped.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.importPytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.d.ts +0 -0
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.async.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.async.fourslash.js +12 -0
- package/dist/tests/fourslash/hover.async.fourslash.js.map +1 -0
- package/dist/tests/harness/vfs/filesystem.d.ts +2 -1
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/package.json +1 -1
@@ -772,6 +772,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
772
772
|
};
|
773
773
|
typeResult = {
|
774
774
|
type: iteratorTypeResult.type,
|
775
|
+
typeErrors: iterTypeResult.typeErrors,
|
775
776
|
unpackedType: iterType,
|
776
777
|
isIncomplete: iteratorTypeResult.isIncomplete,
|
777
778
|
};
|
@@ -2967,10 +2968,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2967
2968
|
if (decl.type === 2 /* Parameter */) {
|
2968
2969
|
return true;
|
2969
2970
|
}
|
2970
|
-
// Assume alias declarations are also always safe to narrow.
|
2971
|
-
if (decl.type === 8 /* Alias */) {
|
2972
|
-
return true;
|
2973
|
-
}
|
2974
2971
|
const declCodeFlowNode = AnalyzerNodeInfo.getFlowNode(decl.node);
|
2975
2972
|
if (!declCodeFlowNode) {
|
2976
2973
|
return false;
|
@@ -3704,7 +3701,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3704
3701
|
// to leave the Self type generic (not specialized). We'll also
|
3705
3702
|
// skip this for __new__ methods because they are not bound
|
3706
3703
|
// to the class but rather assume the type of the cls argument.
|
3707
|
-
const selfClass = bindToType || memberName === '__new__' ? undefined : classType;
|
3704
|
+
const selfClass = !!bindToType || memberName === '__new__' ? undefined : classType;
|
3708
3705
|
const typeResult = getTypeOfMemberInternal(memberInfo, selfClass);
|
3709
3706
|
if (typeResult) {
|
3710
3707
|
type = typeResult.type;
|
@@ -7487,13 +7484,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7487
7484
|
}
|
7488
7485
|
if ((0, types_1.isClassInstance)(effectiveExpectedType) && !(0, types_1.isTypeSame)(effectiveReturnType, effectiveExpectedType)) {
|
7489
7486
|
const tempTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(effectiveReturnType));
|
7490
|
-
(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, effectiveReturnType, effectiveExpectedType, tempTypeVarContext, liveTypeVarScopes, errorNode.start)
|
7491
|
-
|
7492
|
-
|
7493
|
-
|
7494
|
-
|
7495
|
-
|
7496
|
-
|
7487
|
+
if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, effectiveReturnType, effectiveExpectedType, tempTypeVarContext, liveTypeVarScopes, errorNode.start)) {
|
7488
|
+
const genericReturnType = types_1.ClassType.cloneForSpecialization(effectiveReturnType,
|
7489
|
+
/* typeArguments */ undefined,
|
7490
|
+
/* isTypeArgumentExplicit */ false);
|
7491
|
+
effectiveExpectedType = (0, typeUtils_1.applySolvedTypeVars)(genericReturnType, tempTypeVarContext, {
|
7492
|
+
unknownIfNotFound: true,
|
7493
|
+
});
|
7494
|
+
}
|
7497
7495
|
}
|
7498
7496
|
}
|
7499
7497
|
else if ((0, types_1.isFunction)(effectiveReturnType)) {
|
@@ -7708,8 +7706,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7708
7706
|
eliminateUnsolvedInUnions = false;
|
7709
7707
|
}
|
7710
7708
|
// We'll leave TypeVars unsolved if the call is a recursive
|
7711
|
-
// call to a generic function
|
7712
|
-
|
7709
|
+
// call to a generic function or if this isn't a callable
|
7710
|
+
// return with type parameters that are rescoped from the original
|
7711
|
+
// function to the returned callable.
|
7712
|
+
const unknownIfNotFound = !ParseTreeUtils.getTypeVarScopesForNode(errorNode).some((typeVarScope) => typeVarContext.hasSolveForScope(typeVarScope)) && !type.details.rescopedTypeParameters;
|
7713
7713
|
let specializedReturnType = (0, typeUtils_1.applySolvedTypeVars)(returnType, typeVarContext, {
|
7714
7714
|
unknownIfNotFound,
|
7715
7715
|
unknownExemptTypeVars: getUnknownExemptTypeVarsForReturnType(type, returnType),
|
@@ -7775,7 +7775,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7775
7775
|
specializedReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForTypeGuard(boolClassType, typeGuardType, useStrictTypeGuardSemantics));
|
7776
7776
|
}
|
7777
7777
|
}
|
7778
|
-
specializedReturnType = adjustCallableReturnType(specializedReturnType);
|
7778
|
+
specializedReturnType = adjustCallableReturnType(specializedReturnType, signatureTracker.getTrackedSignatures());
|
7779
7779
|
if (specializedInitSelfType) {
|
7780
7780
|
specializedInitSelfType = (0, typeUtils_1.applySolvedTypeVars)(specializedInitSelfType, typeVarContext);
|
7781
7781
|
}
|
@@ -7817,19 +7817,24 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7817
7817
|
}
|
7818
7818
|
return [];
|
7819
7819
|
}
|
7820
|
-
|
7821
|
-
|
7822
|
-
|
7823
|
-
|
7824
|
-
|
7825
|
-
|
7820
|
+
// If the return type includes a generic Callable type, set the type var
|
7821
|
+
// scope to a wildcard to allow these type vars to be solved. This won't
|
7822
|
+
// work with overloads or unions of callables. It's intended for a
|
7823
|
+
// specific use case. We may need to make this more sophisticated in
|
7824
|
+
// the future.
|
7825
|
+
// The trackedSignatures parameter supplies a list of function signatures
|
7826
|
+
// that were used for the function and the arguments passed to it. This is
|
7827
|
+
// important because the callable return value may be called again with
|
7828
|
+
// one of these signatures, so we may need to "uniquify" the type parameters
|
7829
|
+
// to avoid conflicts.
|
7830
|
+
function adjustCallableReturnType(returnType, trackedSignatures) {
|
7826
7831
|
if ((0, types_1.isFunction)(returnType) && !returnType.details.name) {
|
7827
7832
|
const typeVarsInReturnType = (0, typeUtils_1.getTypeVarArgumentsRecursive)(returnType);
|
7828
7833
|
// If there are no unsolved type variables, we're done. If there are
|
7829
7834
|
// unsolved type parameters, treat them as though they are rescoped
|
7830
7835
|
// to the callable.
|
7831
7836
|
if (typeVarsInReturnType.length > 0) {
|
7832
|
-
return types_1.FunctionType.cloneWithNewTypeVarScopeId(returnType, types_1.WildcardTypeVarScopeId, typeVarsInReturnType);
|
7837
|
+
return types_1.FunctionType.cloneWithNewTypeVarScopeId(returnType, types_1.WildcardTypeVarScopeId, typeVarsInReturnType, trackedSignatures);
|
7833
7838
|
}
|
7834
7839
|
}
|
7835
7840
|
return returnType;
|
@@ -8807,7 +8812,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8807
8812
|
if ((0, types_1.isClassInstance)(concreteSubtype)) {
|
8808
8813
|
magicMethodType = (_a = getTypeOfObjectMember(errorNode, concreteSubtype, magicMethodName,
|
8809
8814
|
/* usage */ undefined,
|
8810
|
-
/* diag */ undefined, 64 /* SkipAttributeAccessOverride */ | 1 /* AccessClassMembersOnly
|
8815
|
+
/* diag */ undefined, 64 /* SkipAttributeAccessOverride */ | 1 /* AccessClassMembersOnly */)) === null || _a === void 0 ? void 0 : _a.type;
|
8811
8816
|
}
|
8812
8817
|
else if ((0, types_1.isInstantiableClass)(concreteSubtype)) {
|
8813
8818
|
magicMethodType = (_b = getTypeOfClassMember(errorNode, concreteSubtype, magicMethodName,
|
@@ -12147,7 +12152,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
12147
12152
|
(0, typeUtils_1.addTypeVarsToListIfUnique)(typeParametersSeen, typeVarsInReturnType);
|
12148
12153
|
// Note that the type parameters have been rescoped so they are not
|
12149
12154
|
// considered valid for the body of this function.
|
12150
|
-
|
12155
|
+
if (rescopedTypeVars.length > 0) {
|
12156
|
+
functionType.details.rescopedTypeParameters = rescopedTypeVars;
|
12157
|
+
}
|
12151
12158
|
}
|
12152
12159
|
function adjustParameterAnnotatedType(param, type) {
|
12153
12160
|
var _a;
|
@@ -12292,16 +12299,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
12292
12299
|
}
|
12293
12300
|
}
|
12294
12301
|
function createAsyncFunction(node, functionType) {
|
12302
|
+
(0, debug_1.assert)(types_1.FunctionType.isAsync(functionType));
|
12295
12303
|
// Clone the original function and replace its return type with an
|
12296
|
-
// Awaitable[<returnType>].
|
12297
|
-
const awaitableFunctionType = types_1.FunctionType.
|
12304
|
+
// Awaitable[<returnType>]. Mark the new function as no longer async.
|
12305
|
+
const awaitableFunctionType = types_1.FunctionType.cloneWithNewFlags(functionType, functionType.details.flags & ~512 /* Async */);
|
12298
12306
|
if (functionType.details.declaredReturnType) {
|
12299
12307
|
awaitableFunctionType.details.declaredReturnType = createAwaitableReturnType(node, functionType.details.declaredReturnType, types_1.FunctionType.isGenerator(functionType));
|
12300
12308
|
}
|
12301
|
-
|
12302
|
-
|
12303
|
-
|
12304
|
-
awaitableFunctionType.details.flags |= 1024 /* WrapReturnTypeInAwait */;
|
12309
|
+
else {
|
12310
|
+
awaitableFunctionType.inferredReturnType = createAwaitableReturnType(node, getFunctionInferredReturnType(functionType), types_1.FunctionType.isGenerator(functionType));
|
12311
|
+
}
|
12305
12312
|
return awaitableFunctionType;
|
12306
12313
|
}
|
12307
12314
|
function createAwaitableReturnType(node, returnType, isGenerator) {
|
@@ -14957,7 +14964,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14957
14964
|
function getFunctionEffectiveReturnType(type, args, inferTypeIfNeeded = true) {
|
14958
14965
|
const specializedReturnType = types_1.FunctionType.getSpecializedReturnType(type);
|
14959
14966
|
if (specializedReturnType) {
|
14960
|
-
return adjustCallableReturnType(specializedReturnType);
|
14967
|
+
return adjustCallableReturnType(specializedReturnType, /* trackedSignatures */ undefined);
|
14961
14968
|
}
|
14962
14969
|
if (inferTypeIfNeeded) {
|
14963
14970
|
return getFunctionInferredReturnType(type, args);
|
@@ -14965,7 +14972,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14965
14972
|
return types_1.UnknownType.create();
|
14966
14973
|
}
|
14967
14974
|
function getFunctionInferredReturnType(type, args) {
|
14968
|
-
var _a;
|
14969
14975
|
let returnType;
|
14970
14976
|
let isIncomplete = false;
|
14971
14977
|
let analyzeUnannotatedFunctions = true;
|
@@ -15012,10 +15018,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15012
15018
|
if (returnTypeResult === null || returnTypeResult === void 0 ? void 0 : returnTypeResult.isIncomplete) {
|
15013
15019
|
isIncomplete = true;
|
15014
15020
|
}
|
15015
|
-
// Do we need to wrap this in an awaitable?
|
15016
|
-
if (returnType && types_1.FunctionType.isWrapReturnTypeInAwait(type)) {
|
15017
|
-
returnType = createAwaitableReturnType(functionNode, returnType, !!((_a = type.details.declaration) === null || _a === void 0 ? void 0 : _a.isGenerator));
|
15018
|
-
}
|
15019
15021
|
}
|
15020
15022
|
}
|
15021
15023
|
}
|
@@ -15036,7 +15038,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15036
15038
|
types_1.FunctionType.hasUnannotatedParams(type) &&
|
15037
15039
|
!types_1.FunctionType.isStubDefinition(type) &&
|
15038
15040
|
!types_1.FunctionType.isPyTypedDefinition(type) &&
|
15039
|
-
!types_1.FunctionType.isWrapReturnTypeInAwait(type) &&
|
15040
15041
|
args) {
|
15041
15042
|
const contextualReturnType = getFunctionInferredReturnTypeUsingArguments(type, args);
|
15042
15043
|
if (contextualReturnType) {
|
@@ -15046,7 +15047,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15046
15047
|
return returnType;
|
15047
15048
|
}
|
15048
15049
|
function getFunctionInferredReturnTypeUsingArguments(type, args) {
|
15049
|
-
var _a;
|
15050
15050
|
let contextualReturnType;
|
15051
15051
|
if (!type.details.declaration) {
|
15052
15052
|
return undefined;
|
@@ -15158,10 +15158,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15158
15158
|
});
|
15159
15159
|
if (contextualReturnType) {
|
15160
15160
|
contextualReturnType = (0, types_1.removeUnbound)(contextualReturnType);
|
15161
|
-
// Do we need to wrap this in an awaitable?
|
15162
|
-
if (types_1.FunctionType.isWrapReturnTypeInAwait(type) && !(0, types_1.isNever)(contextualReturnType)) {
|
15163
|
-
contextualReturnType = createAwaitableReturnType(functionNode, contextualReturnType, !!((_a = type.details.declaration) === null || _a === void 0 ? void 0 : _a.isGenerator));
|
15164
|
-
}
|
15165
15161
|
if (!isResultFromCache) {
|
15166
15162
|
// Cache the resulting type.
|
15167
15163
|
if (!functionType.functionType.callSiteReturnTypeCache) {
|
@@ -17312,7 +17308,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17312
17308
|
/* exemptSelfClsParam */ false);
|
17313
17309
|
});
|
17314
17310
|
if (matchIndex < 0) {
|
17315
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideOverloadNoMatch().format({ index: overrideOverloadIndex }));
|
17311
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideOverloadNoMatch().format({ index: overrideOverloadIndex + 1 }));
|
17316
17312
|
return false;
|
17317
17313
|
}
|
17318
17314
|
if (matchIndex < previousMatchIndex) {
|
@@ -17471,7 +17467,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17471
17467
|
}
|
17472
17468
|
else if (i < overrideParamDetails.positionOnlyParamCount &&
|
17473
17469
|
i >= baseParamDetails.positionOnlyParamCount) {
|
17474
|
-
if (!baseParam.isNameSynthesized
|
17470
|
+
if (!baseParam.isNameSynthesized &&
|
17471
|
+
baseParamDetails.params[i].source !== parameterUtils_1.ParameterSource.PositionOnly) {
|
17475
17472
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
17476
17473
|
index: i + 1,
|
17477
17474
|
baseName: baseParam.name || '*',
|