@zzzen/pyright-internal 1.2.0-dev.20230730 → 1.2.0-dev.20230813
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 +6 -5
- package/dist/analyzer/backgroundAnalysisProgram.js +6 -5
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +3 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +5 -3
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +10 -6
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +1 -0
- package/dist/analyzer/constraintSolver.js +30 -23
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.js +2 -2
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/decorators.js +8 -8
- package/dist/analyzer/decorators.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/packageTypeVerifier.js +4 -1
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -1
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +3 -3
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +4 -1
- package/dist/analyzer/program.js +8 -10
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +28 -20
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.d.ts +3 -0
- package/dist/analyzer/service.js +44 -9
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +127 -78
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -1
- package/dist/analyzer/typeEvaluatorTypes.js +8 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +6 -6
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +1 -1
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +4 -6
- package/dist/analyzer/typeUtils.js +56 -31
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +9 -4
- package/dist/analyzer/types.js +4 -8
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.d.ts +2 -1
- package/dist/backgroundAnalysis.js +2 -2
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +3 -2
- package/dist/backgroundAnalysisBase.js +3 -3
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +7 -5
- package/dist/backgroundThreadBase.js +20 -6
- 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/console.js.map +1 -1
- package/dist/common/extensibility.d.ts +4 -29
- package/dist/common/extensibility.js +5 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +2 -15
- 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/pathUtils.d.ts +1 -0
- package/dist/common/pathUtils.js +19 -5
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +2 -1
- package/dist/common/realFileSystem.js +13 -9
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.d.ts +14 -0
- package/dist/common/serviceProvider.js +37 -0
- package/dist/common/serviceProvider.js.map +1 -0
- package/dist/common/serviceProviderExtensions.d.ts +16 -0
- package/dist/common/serviceProviderExtensions.js +27 -0
- package/dist/common/serviceProviderExtensions.js.map +1 -0
- package/dist/languageServerBase.d.ts +11 -7
- package/dist/languageServerBase.js +21 -13
- 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/navigationUtils.js +1 -1
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +7 -1
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +3 -0
- package/dist/localization/localize.js +1 -0
- package/dist/localization/localize.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 +3 -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/nodeMain.js +2 -1
- package/dist/nodeMain.js.map +1 -1
- package/dist/parser/parser.js +2 -2
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +2 -0
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +3 -1
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +3 -2
- package/dist/readonlyAugmentedFileSystem.js +2 -2
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +8 -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/fourslash/runner.js +1 -1
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +1 -1
- package/dist/tests/harness/fourslash/testState.js +7 -2
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
- package/dist/tests/harness/vfs/filesystem.js +1 -1
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/service.test.js +65 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/testUtils.js +6 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +2 -2
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/zipfs.test.js +8 -5
- package/dist/tests/zipfs.test.js.map +1 -1
- package/package.json +1 -1
@@ -109,7 +109,17 @@ var AssignTypeFlags;
|
|
109
109
|
// each other.
|
110
110
|
class UniqueSignatureTracker {
|
111
111
|
constructor() {
|
112
|
-
this.
|
112
|
+
this._trackedSignatures = [];
|
113
|
+
}
|
114
|
+
getTrackedSignatures() {
|
115
|
+
return this._trackedSignatures;
|
116
|
+
}
|
117
|
+
addTrackedSignatures(signatures) {
|
118
|
+
signatures.forEach((s) => {
|
119
|
+
s.expressionOffsets.forEach((offset) => {
|
120
|
+
this.addSignature(s.type, offset);
|
121
|
+
});
|
122
|
+
});
|
113
123
|
}
|
114
124
|
findSignature(signature) {
|
115
125
|
// Use the associated overload type if this is a function associated with an overload.
|
@@ -117,7 +127,7 @@ class UniqueSignatureTracker {
|
|
117
127
|
if ((0, types_1.isFunction)(signature) && signature.overloaded) {
|
118
128
|
effectiveSignature = signature.overloaded;
|
119
129
|
}
|
120
|
-
return this.
|
130
|
+
return this._trackedSignatures.find((s) => {
|
121
131
|
return (0, types_1.isTypeSame)(effectiveSignature, s.type);
|
122
132
|
});
|
123
133
|
}
|
@@ -132,7 +142,7 @@ class UniqueSignatureTracker {
|
|
132
142
|
}
|
133
143
|
}
|
134
144
|
else {
|
135
|
-
this.
|
145
|
+
this._trackedSignatures.push({ type: effectiveSignature, expressionOffsets: [offset] });
|
136
146
|
}
|
137
147
|
}
|
138
148
|
}
|
@@ -186,35 +196,35 @@ function makeInferenceContext(expectedType, isTypeIncomplete, signatureTracker)
|
|
186
196
|
}
|
187
197
|
exports.makeInferenceContext = makeInferenceContext;
|
188
198
|
// Calls a callback for each subtype and combines the results
|
189
|
-
// into a final type.
|
199
|
+
// into a final type. It performs no memory allocations if the
|
200
|
+
// transformed type is the same as the original.
|
190
201
|
function mapSubtypes(type, callback) {
|
191
202
|
if ((0, types_1.isUnion)(type)) {
|
192
|
-
|
193
|
-
|
194
|
-
type.subtypes.forEach((subtype) => {
|
203
|
+
for (let i = 0; i < type.subtypes.length; i++) {
|
204
|
+
const subtype = type.subtypes[i];
|
195
205
|
const transformedType = callback(subtype);
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
206
|
+
// Avoid doing any memory allocations until a change is detected.
|
207
|
+
if (subtype !== transformedType) {
|
208
|
+
const typesToCombine = type.subtypes.slice(0, i);
|
209
|
+
// Create a helper lambda that accumulates transformed subtypes.
|
210
|
+
const accumulateSubtype = (newSubtype) => {
|
211
|
+
if (newSubtype) {
|
212
|
+
typesToCombine.push(addConditionToType(newSubtype, getTypeCondition(type)));
|
213
|
+
}
|
214
|
+
};
|
215
|
+
accumulateSubtype(transformedType);
|
216
|
+
for (i++; i < type.subtypes.length; i++) {
|
217
|
+
accumulateSubtype(callback(type.subtypes[i]));
|
200
218
|
}
|
201
|
-
|
202
|
-
|
219
|
+
const newType = (0, types_1.combineTypes)(typesToCombine);
|
220
|
+
// Do our best to retain type aliases.
|
221
|
+
if (newType.category === 9 /* Union */) {
|
222
|
+
types_1.UnionType.addTypeAliasSource(newType, type);
|
203
223
|
}
|
224
|
+
return newType;
|
204
225
|
}
|
205
|
-
else {
|
206
|
-
typeChanged = true;
|
207
|
-
}
|
208
|
-
});
|
209
|
-
if (!typeChanged) {
|
210
|
-
return type;
|
211
|
-
}
|
212
|
-
const newType = (0, types_1.combineTypes)(newSubtypes);
|
213
|
-
// Do our best to retain type aliases.
|
214
|
-
if (newType.category === 9 /* Union */) {
|
215
|
-
types_1.UnionType.addTypeAliasSource(newType, type);
|
216
226
|
}
|
217
|
-
return
|
227
|
+
return type;
|
218
228
|
}
|
219
229
|
const transformedSubtype = callback(type);
|
220
230
|
if (!transformedSubtype) {
|
@@ -519,7 +529,7 @@ function transformPossibleRecursiveTypeAlias(type) {
|
|
519
529
|
let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype));
|
520
530
|
if (newType !== type && type.typeAliasInfo) {
|
521
531
|
// Copy the type alias information if present.
|
522
|
-
newType = types_1.TypeBase.cloneForTypeAlias(newType, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
532
|
+
newType = types_1.TypeBase.cloneForTypeAlias(newType, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
523
533
|
}
|
524
534
|
return newType;
|
525
535
|
}
|
@@ -752,7 +762,18 @@ function partiallySpecializeType(type, contextClassType, selfClass, typeClassTyp
|
|
752
762
|
exports.partiallySpecializeType = partiallySpecializeType;
|
753
763
|
function populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass) {
|
754
764
|
const synthesizedSelfTypeVar = synthesizeTypeVarForSelfCls(contextClassType, /* isClsParam */ false);
|
755
|
-
|
765
|
+
const selfInstance = convertToInstance(selfClass);
|
766
|
+
// We can't call stripLiteralValue here because that method requires the type evaluator.
|
767
|
+
// Instead, we'll do a simplified version of it here.
|
768
|
+
const selfWithoutLiteral = mapSubtypes(selfInstance, (subtype) => {
|
769
|
+
if ((0, types_1.isClass)(subtype)) {
|
770
|
+
if (subtype.literalValue !== undefined) {
|
771
|
+
return types_1.ClassType.cloneWithLiteral(subtype, /* value */ undefined);
|
772
|
+
}
|
773
|
+
}
|
774
|
+
return subtype;
|
775
|
+
});
|
776
|
+
typeVarContext.setTypeVarType(synthesizedSelfTypeVar, selfInstance, selfWithoutLiteral);
|
756
777
|
}
|
757
778
|
exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
|
758
779
|
// Looks for duplicate function types within the type and ensures that
|
@@ -1596,7 +1617,7 @@ function convertToInstance(type, includeSubclasses = true) {
|
|
1596
1617
|
});
|
1597
1618
|
// Copy over any type alias information.
|
1598
1619
|
if (type.typeAliasInfo && type !== result) {
|
1599
|
-
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1620
|
+
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1600
1621
|
}
|
1601
1622
|
if (type !== result && includeSubclasses) {
|
1602
1623
|
// Cache the converted value for next time.
|
@@ -1633,7 +1654,7 @@ function convertToInstantiable(type, includeSubclasses = true) {
|
|
1633
1654
|
});
|
1634
1655
|
// Copy over any type alias information.
|
1635
1656
|
if (type.typeAliasInfo && type !== result) {
|
1636
|
-
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1657
|
+
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1637
1658
|
}
|
1638
1659
|
if (type !== result) {
|
1639
1660
|
// Cache the converted value for next time.
|
@@ -2417,7 +2438,7 @@ class TypeVarTransformer {
|
|
2417
2438
|
return replacementType;
|
2418
2439
|
});
|
2419
2440
|
if (requiresUpdate) {
|
2420
|
-
return types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, typeArgs);
|
2441
|
+
return types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, typeArgs);
|
2421
2442
|
}
|
2422
2443
|
return type;
|
2423
2444
|
}
|
@@ -2540,7 +2561,7 @@ class TypeVarTransformer {
|
|
2540
2561
|
return updatedType;
|
2541
2562
|
});
|
2542
2563
|
return requiresUpdate
|
2543
|
-
? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, newTypeArgs)
|
2564
|
+
? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, newTypeArgs)
|
2544
2565
|
: type;
|
2545
2566
|
}
|
2546
2567
|
transformTypeVarsInClassType(classType, recursionCount) {
|
@@ -2857,6 +2878,9 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
|
|
2857
2878
|
return classType;
|
2858
2879
|
}
|
2859
2880
|
transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
2881
|
+
if (sourceType.trackedSignatures) {
|
2882
|
+
this._signatureTracker.addTrackedSignatures(sourceType.trackedSignatures);
|
2883
|
+
}
|
2860
2884
|
// If this function is not generic, there's no need to check for uniqueness.
|
2861
2885
|
if (sourceType.details.typeParameters.length === 0) {
|
2862
2886
|
return super.transformTypeVarsInFunctionType(sourceType, recursionCount);
|
@@ -3103,6 +3127,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3103
3127
|
const filteredOverloads = [];
|
3104
3128
|
doForEachSubtype((0, types_1.combineTypes)(overloadTypes), (subtype) => {
|
3105
3129
|
(0, debug_1.assert)((0, types_1.isFunction)(subtype));
|
3130
|
+
subtype = types_1.FunctionType.cloneWithNewFlags(subtype, subtype.details.flags | 256 /* Overloaded */);
|
3106
3131
|
filteredOverloads.push(subtype);
|
3107
3132
|
});
|
3108
3133
|
if (filteredOverloads.length === 1) {
|