@zzzen/pyright-internal 1.2.0-dev.20240630 → 1.2.0-dev.20240714
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/analyzerNodeInfo.js +74 -46
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.js +507 -513
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +652 -633
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +5 -3
- package/dist/analyzer/codeFlowEngine.js +143 -122
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.js +30 -28
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +1 -1
- package/dist/analyzer/constraintSolver.js +71 -67
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +22 -22
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +85 -77
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +113 -176
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +1 -1
- package/dist/analyzer/declarationUtils.js +14 -15
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +85 -85
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.js +71 -57
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +8 -18
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +2 -1
- package/dist/analyzer/importResolver.js +40 -29
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +27 -27
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +33 -59
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +4 -4
- package/dist/analyzer/operations.js +70 -70
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +66 -62
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +4 -4
- package/dist/analyzer/parameterUtils.js +28 -46
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +268 -269
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +76 -76
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +195 -147
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +1 -1
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +78 -147
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +22 -22
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +3 -2
- package/dist/analyzer/sourceFile.js +8 -8
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +20 -19
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +83 -84
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/testWalker.js +2 -2
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +20 -20
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +25 -25
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +2330 -2367
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +33 -31
- package/dist/analyzer/typeEvaluatorTypes.js +48 -41
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +221 -217
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +118 -115
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +104 -103
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +26 -9
- package/dist/analyzer/typeUtils.js +460 -404
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.js +8 -8
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.js +13 -10
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +96 -198
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +147 -103
- package/dist/analyzer/types.js +668 -493
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +33 -33
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/diagnostic.d.ts +14 -0
- package/dist/common/diagnostic.js +41 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.d.ts +4 -0
- package/dist/common/diagnosticSink.js +21 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.js +6 -4
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +1 -0
- package/dist/common/realFileSystem.js +4 -0
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/textEditTracker.js +14 -14
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/languageService/autoImporter.js +10 -10
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +23 -23
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +1 -1
- package/dist/languageService/completionProvider.js +156 -154
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +1 -1
- package/dist/languageService/definitionProvider.js +3 -1
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +19 -19
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.js +25 -24
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js +8 -8
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/referencesProvider.js +8 -8
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +1 -1
- package/dist/languageService/signatureHelpProvider.js +6 -6
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js +3 -3
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +13 -13
- 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.en-us.json +2 -1
- package/dist/parser/parseNodes.d.ts +468 -401
- package/dist/parser/parseNodes.js +626 -355
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +1 -0
- package/dist/parser/parser.js +322 -297
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +265 -5
- package/dist/pyright.js.map +1 -1
- package/dist/tests/classDeclaration.test.js +14 -14
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
- package/dist/tests/harness/vfs/filesystem.js +6 -2
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +4 -3
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +5 -5
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +8 -8
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +7 -7
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +2 -2
- package/dist/tests/typeEvaluator3.test.js +10 -5
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js +2 -2
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +14 -39
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/package.json +1 -1
@@ -94,8 +94,8 @@ function printObjectTypeForClass(type, printTypeFlags, returnTypeCallback) {
|
|
94
94
|
exports.printObjectTypeForClass = printObjectTypeForClass;
|
95
95
|
const maxLiteralStringLength = 50;
|
96
96
|
function isLiteralValueTruncated(type) {
|
97
|
-
if (typeof type.literalValue === 'string') {
|
98
|
-
if (type.literalValue.length > maxLiteralStringLength) {
|
97
|
+
if (typeof type.priv.literalValue === 'string') {
|
98
|
+
if (type.priv.literalValue.length > maxLiteralStringLength) {
|
99
99
|
return true;
|
100
100
|
}
|
101
101
|
}
|
@@ -103,15 +103,15 @@ function isLiteralValueTruncated(type) {
|
|
103
103
|
}
|
104
104
|
exports.isLiteralValueTruncated = isLiteralValueTruncated;
|
105
105
|
function printLiteralValueTruncated(type) {
|
106
|
-
if (type.
|
106
|
+
if (type.shared.name === 'bytes') {
|
107
107
|
return 'bytes';
|
108
108
|
}
|
109
|
-
(0, debug_1.assert)(type.
|
109
|
+
(0, debug_1.assert)(type.shared.name === 'str');
|
110
110
|
return 'LiteralString';
|
111
111
|
}
|
112
112
|
exports.printLiteralValueTruncated = printLiteralValueTruncated;
|
113
113
|
function printLiteralValue(type, quotation = "'") {
|
114
|
-
const literalValue = type.literalValue;
|
114
|
+
const literalValue = type.priv.literalValue;
|
115
115
|
if (literalValue === undefined) {
|
116
116
|
return '';
|
117
117
|
}
|
@@ -122,7 +122,7 @@ function printLiteralValue(type, quotation = "'") {
|
|
122
122
|
if (literalValue.length > maxLiteralStringLength) {
|
123
123
|
effectiveLiteralValue = literalValue.substring(0, maxLiteralStringLength) + '…';
|
124
124
|
}
|
125
|
-
if (type.
|
125
|
+
if (type.shared.name === 'bytes') {
|
126
126
|
let bytesString = '';
|
127
127
|
// There's no good built-in conversion routine in javascript to convert
|
128
128
|
// bytes strings. Determine on a character-by-character basis whether
|
@@ -175,6 +175,7 @@ function printLiteralValue(type, quotation = "'") {
|
|
175
175
|
}
|
176
176
|
exports.printLiteralValue = printLiteralValue;
|
177
177
|
function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount) {
|
178
|
+
var _a, _b, _c;
|
178
179
|
const originalPrintTypeFlags = printTypeFlags;
|
179
180
|
const parenthesizeUnion = (printTypeFlags & 16 /* PrintTypeFlags.ParenthesizeUnion */) !== 0;
|
180
181
|
printTypeFlags &= ~(16 /* PrintTypeFlags.ParenthesizeUnion */ | 128 /* PrintTypeFlags.ParenthesizeCallable */);
|
@@ -187,7 +188,8 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
187
188
|
recursionCount++;
|
188
189
|
// If this is a type alias, see if we should use its name rather than
|
189
190
|
// the type it represents.
|
190
|
-
|
191
|
+
const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
|
192
|
+
if (aliasInfo) {
|
191
193
|
let expandTypeAlias = true;
|
192
194
|
if ((printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) === 0) {
|
193
195
|
expandTypeAlias = false;
|
@@ -201,30 +203,30 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
201
203
|
try {
|
202
204
|
recursionTypes.push(type);
|
203
205
|
let aliasName = (printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0
|
204
|
-
?
|
205
|
-
:
|
206
|
+
? aliasInfo.fullName
|
207
|
+
: aliasInfo.name;
|
206
208
|
// Use the fully-qualified name if the name isn't unique.
|
207
209
|
if (!uniqueNameMap.isUnique(aliasName)) {
|
208
|
-
aliasName =
|
210
|
+
aliasName = aliasInfo.fullName;
|
209
211
|
}
|
210
|
-
const typeParams =
|
212
|
+
const typeParams = aliasInfo.typeParameters;
|
211
213
|
if (typeParams && typeParams.length > 0) {
|
212
214
|
let argumentStrings;
|
213
215
|
// If there is a type arguments array, it's a specialized type alias.
|
214
|
-
if (
|
216
|
+
if (aliasInfo.typeArguments) {
|
215
217
|
if ((printTypeFlags & 2 /* PrintTypeFlags.OmitTypeArgumentsIfUnknown */) === 0 ||
|
216
|
-
|
218
|
+
aliasInfo.typeArguments.some((typeArg) => !(0, types_1.isUnknown)(typeArg))) {
|
217
219
|
argumentStrings = [];
|
218
|
-
|
220
|
+
aliasInfo.typeArguments.forEach((typeArg, index) => {
|
219
221
|
// Which type parameter does this map to?
|
220
222
|
const typeParam = index < typeParams.length ? typeParams[index] : typeParams[typeParams.length - 1];
|
221
223
|
// If this type argument maps to a variadic type parameter, unpack it.
|
222
224
|
if ((0, types_1.isVariadicTypeVar)(typeParam) &&
|
223
225
|
(0, types_1.isClassInstance)(typeArg) &&
|
224
226
|
(0, typeUtils_1.isTupleClass)(typeArg) &&
|
225
|
-
typeArg.tupleTypeArguments &&
|
226
|
-
typeArg.tupleTypeArguments.every((typeArg) => !typeArg.isUnbounded)) {
|
227
|
-
typeArg.tupleTypeArguments.forEach((tupleTypeArg) => {
|
227
|
+
typeArg.priv.tupleTypeArguments &&
|
228
|
+
typeArg.priv.tupleTypeArguments.every((typeArg) => !typeArg.isUnbounded)) {
|
229
|
+
typeArg.priv.tupleTypeArguments.forEach((tupleTypeArg) => {
|
228
230
|
argumentStrings.push(printTypeInternal(tupleTypeArg.type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount));
|
229
231
|
});
|
230
232
|
}
|
@@ -263,24 +265,20 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
263
265
|
}
|
264
266
|
}
|
265
267
|
}
|
266
|
-
if (recursionTypes.find((t) => {
|
267
|
-
var _a;
|
268
|
-
return t === type ||
|
269
|
-
(t.typeAliasInfo !== undefined && t.typeAliasInfo.fullName === ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.fullName));
|
270
|
-
}) ||
|
268
|
+
if (recursionTypes.find((t) => { var _a; return t === type || (!!((_a = t.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) && t.props.typeAliasInfo.fullName === (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.fullName)); }) ||
|
271
269
|
recursionTypes.length > types_1.maxTypeRecursionCount) {
|
272
270
|
// If this is a recursive TypeVar, we've already expanded it once, so
|
273
271
|
// just print its name at this point.
|
274
|
-
if ((0, types_1.isTypeVar)(type) && type.
|
275
|
-
return type.
|
272
|
+
if ((0, types_1.isTypeVar)(type) && type.shared.isSynthesized && type.shared.recursiveAlias) {
|
273
|
+
return type.shared.recursiveAlias.name;
|
276
274
|
}
|
277
|
-
if (
|
278
|
-
if (!
|
275
|
+
if (aliasInfo) {
|
276
|
+
if (!aliasInfo.typeParameters) {
|
279
277
|
let name = (printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0
|
280
|
-
?
|
281
|
-
:
|
278
|
+
? aliasInfo.fullName
|
279
|
+
: aliasInfo.name;
|
282
280
|
if (!uniqueNameMap.isUnique(name)) {
|
283
|
-
name =
|
281
|
+
name = aliasInfo.fullName;
|
284
282
|
}
|
285
283
|
return name;
|
286
284
|
}
|
@@ -298,7 +296,8 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
298
296
|
recursionTypes.push(type);
|
299
297
|
const includeConditionalIndicator = (printTypeFlags & (64 /* PrintTypeFlags.OmitConditionalConstraint */ | 256 /* PrintTypeFlags.PythonSyntax */)) === 0;
|
300
298
|
const getConditionalIndicator = (subtype) => {
|
301
|
-
|
299
|
+
var _a;
|
300
|
+
return !!((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) && includeConditionalIndicator ? '*' : '';
|
302
301
|
};
|
303
302
|
switch (type.category) {
|
304
303
|
case 0 /* TypeCategory.Unbound */: {
|
@@ -317,11 +316,11 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
317
316
|
if (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) {
|
318
317
|
return 'Any';
|
319
318
|
}
|
320
|
-
return `Module("${type.moduleName}")`;
|
319
|
+
return `Module("${type.priv.moduleName}")`;
|
321
320
|
}
|
322
321
|
case 6 /* TypeCategory.Class */: {
|
323
322
|
if (types_1.TypeBase.isInstance(type)) {
|
324
|
-
if (type.literalValue !== undefined) {
|
323
|
+
if (type.priv.literalValue !== undefined) {
|
325
324
|
if (isLiteralValueTruncated(type) && (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0) {
|
326
325
|
return printLiteralValueTruncated(type);
|
327
326
|
}
|
@@ -333,7 +332,7 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
333
332
|
}
|
334
333
|
else {
|
335
334
|
let typeToWrap;
|
336
|
-
if (type.literalValue !== undefined) {
|
335
|
+
if (type.priv.literalValue !== undefined) {
|
337
336
|
if (isLiteralValueTruncated(type) && (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0) {
|
338
337
|
typeToWrap = printLiteralValueTruncated(type);
|
339
338
|
}
|
@@ -342,8 +341,8 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
342
341
|
}
|
343
342
|
}
|
344
343
|
else {
|
345
|
-
if (type.specialForm) {
|
346
|
-
return printTypeInternal(type.specialForm, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
344
|
+
if ((_b = type.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
|
345
|
+
return printTypeInternal(type.props.specialForm, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
347
346
|
}
|
348
347
|
typeToWrap = printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
349
348
|
}
|
@@ -370,8 +369,8 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
370
369
|
case 8 /* TypeCategory.Union */: {
|
371
370
|
// If this is a value expression that evaluates to a union type but is
|
372
371
|
// not a type alias, simply print the special form ("UnionType").
|
373
|
-
if (types_1.TypeBase.isInstantiable(type) && type.specialForm && !
|
374
|
-
return printTypeInternal(type.specialForm, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
372
|
+
if (types_1.TypeBase.isInstantiable(type) && ((_c = type.props) === null || _c === void 0 ? void 0 : _c.specialForm) && !aliasInfo) {
|
373
|
+
return printTypeInternal(type.props.specialForm, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
375
374
|
}
|
376
375
|
// Allocate a set that refers to subtypes in the union by
|
377
376
|
// their indices. If the index is within the set, it is already
|
@@ -385,16 +384,16 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
385
384
|
? printTypeFlags | 128 /* PrintTypeFlags.ParenthesizeCallable */
|
386
385
|
: printTypeFlags;
|
387
386
|
// Start by matching possible type aliases to the subtypes.
|
388
|
-
if ((printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) === 0 && type.typeAliasSources) {
|
389
|
-
for (const typeAliasSource of type.typeAliasSources) {
|
387
|
+
if ((printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) === 0 && type.priv.typeAliasSources) {
|
388
|
+
for (const typeAliasSource of type.priv.typeAliasSources) {
|
390
389
|
let matchedAllSubtypes = true;
|
391
390
|
let allSubtypesPreviouslyHandled = true;
|
392
391
|
const indicesCoveredByTypeAlias = new Set();
|
393
|
-
for (const sourceSubtype of typeAliasSource.subtypes) {
|
392
|
+
for (const sourceSubtype of typeAliasSource.priv.subtypes) {
|
394
393
|
let unionSubtypeIndex = 0;
|
395
394
|
let foundMatch = false;
|
396
395
|
const sourceSubtypeInstance = (0, typeUtils_1.convertToInstance)(sourceSubtype);
|
397
|
-
for (const unionSubtype of type.subtypes) {
|
396
|
+
for (const unionSubtype of type.priv.subtypes) {
|
398
397
|
if ((0, types_1.isTypeSame)(sourceSubtypeInstance, unionSubtype)) {
|
399
398
|
if (!subtypeHandledSet.has(unionSubtypeIndex)) {
|
400
399
|
allSubtypesPreviouslyHandled = false;
|
@@ -416,7 +415,7 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
416
415
|
}
|
417
416
|
}
|
418
417
|
}
|
419
|
-
const noneIndex = type.subtypes.findIndex((subtype) => (0, typeUtils_1.isNoneInstance)(subtype));
|
418
|
+
const noneIndex = type.priv.subtypes.findIndex((subtype) => (0, typeUtils_1.isNoneInstance)(subtype));
|
420
419
|
if (noneIndex >= 0 && !subtypeHandledSet.has(noneIndex)) {
|
421
420
|
const typeWithoutNone = (0, typeUtils_1.removeNoneFromUnion)(type);
|
422
421
|
if ((0, types_1.isNever)(typeWithoutNone)) {
|
@@ -436,7 +435,7 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
436
435
|
const literalClassStrings = new Set();
|
437
436
|
(0, typeUtils_1.doForEachSubtype)(type, (subtype, index) => {
|
438
437
|
if (!subtypeHandledSet.has(index)) {
|
439
|
-
if ((0, types_1.isClassInstance)(subtype) && subtype.literalValue !== undefined) {
|
438
|
+
if ((0, types_1.isClassInstance)(subtype) && subtype.priv.literalValue !== undefined) {
|
440
439
|
if (isLiteralValueTruncated(subtype) &&
|
441
440
|
(printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0) {
|
442
441
|
subtypeStrings.add(printLiteralValueTruncated(subtype));
|
@@ -445,7 +444,7 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
445
444
|
literalObjectStrings.add(printLiteralValue(subtype));
|
446
445
|
}
|
447
446
|
}
|
448
|
-
else if ((0, types_1.isInstantiableClass)(subtype) && subtype.literalValue !== undefined) {
|
447
|
+
else if ((0, types_1.isInstantiableClass)(subtype) && subtype.priv.literalValue !== undefined) {
|
449
448
|
if (isLiteralValueTruncated(subtype) &&
|
450
449
|
(printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0) {
|
451
450
|
subtypeStrings.add(`type[${printLiteralValueTruncated(subtype)}]`);
|
@@ -488,23 +487,23 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
488
487
|
// This will confuse users. The exception is if it's a bound synthesized
|
489
488
|
// type, in which case we'll print the bound type. This is used for
|
490
489
|
// "self" and "cls" parameters.
|
491
|
-
if (type.
|
490
|
+
if (type.shared.isSynthesized) {
|
492
491
|
// If it's a synthesized type var used to implement recursive type
|
493
492
|
// aliases, return the type alias name.
|
494
|
-
if (type.
|
495
|
-
if ((printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) !== 0 && type.
|
493
|
+
if (type.shared.recursiveAlias) {
|
494
|
+
if ((printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) !== 0 && type.shared.boundType) {
|
496
495
|
return printTypeInternal(types_1.TypeBase.isInstance(type)
|
497
|
-
? (0, typeUtils_1.convertToInstance)(type.
|
498
|
-
: type.
|
496
|
+
? (0, typeUtils_1.convertToInstance)(type.shared.boundType)
|
497
|
+
: type.shared.boundType, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
499
498
|
}
|
500
|
-
return type.
|
499
|
+
return type.shared.recursiveAlias.name;
|
501
500
|
}
|
502
501
|
// If it's a synthesized type var used to implement `self` or `cls` types,
|
503
502
|
// print the type with a special character that indicates that the type
|
504
503
|
// is internally represented as a TypeVar.
|
505
|
-
if (type.
|
506
|
-
let boundTypeString = printTypeInternal(type.
|
507
|
-
if (!(0, types_1.isAnyOrUnknown)(type.
|
504
|
+
if (type.shared.isSynthesizedSelf && type.shared.boundType) {
|
505
|
+
let boundTypeString = printTypeInternal(type.shared.boundType, printTypeFlags & ~32 /* PrintTypeFlags.ExpandTypeAlias */, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
506
|
+
if (!(0, types_1.isAnyOrUnknown)(type.shared.boundType)) {
|
508
507
|
if (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) {
|
509
508
|
boundTypeString = `Self`;
|
510
509
|
}
|
@@ -521,24 +520,24 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
521
520
|
? 'Any'
|
522
521
|
: 'Unknown';
|
523
522
|
}
|
524
|
-
if (type.
|
523
|
+
if (type.shared.isParamSpec) {
|
525
524
|
const paramSpecText = _getReadableTypeVarName(type, (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0);
|
526
|
-
if (type.paramSpecAccess) {
|
527
|
-
return `${paramSpecText}.${type.paramSpecAccess}`;
|
525
|
+
if (type.priv.paramSpecAccess) {
|
526
|
+
return `${paramSpecText}.${type.priv.paramSpecAccess}`;
|
528
527
|
}
|
529
528
|
return paramSpecText;
|
530
529
|
}
|
531
530
|
let typeVarName = _getReadableTypeVarName(type, (printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) !== 0);
|
532
|
-
if (type.isVariadicUnpacked) {
|
531
|
+
if (type.priv.isVariadicUnpacked) {
|
533
532
|
typeVarName = _printUnpack(typeVarName, printTypeFlags);
|
534
533
|
}
|
535
|
-
if (type.isVariadicInUnion) {
|
534
|
+
if (type.priv.isVariadicInUnion) {
|
536
535
|
typeVarName = `Union[${typeVarName}]`;
|
537
536
|
}
|
538
537
|
if (types_1.TypeBase.isInstantiable(type)) {
|
539
538
|
typeVarName = `${_printNestedInstantiable(type, typeVarName)}`;
|
540
539
|
}
|
541
|
-
if (!type.
|
540
|
+
if (!type.shared.isVariadic && (printTypeFlags & 2048 /* PrintTypeFlags.PrintTypeVarVariance */) !== 0) {
|
542
541
|
const varianceText = _getTypeVarVarianceText(type);
|
543
542
|
if (varianceText) {
|
544
543
|
typeVarName = `${typeVarName} (${varianceText})`;
|
@@ -547,11 +546,11 @@ function printTypeInternal(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
547
546
|
return typeVarName;
|
548
547
|
}
|
549
548
|
case 3 /* TypeCategory.Never */: {
|
550
|
-
return type.isNoReturn ? 'NoReturn' : 'Never';
|
549
|
+
return type.priv.isNoReturn ? 'NoReturn' : 'Never';
|
551
550
|
}
|
552
551
|
case 2 /* TypeCategory.Any */: {
|
553
552
|
const anyType = type;
|
554
|
-
return anyType.isEllipsis ? '...' : 'Any';
|
553
|
+
return anyType.priv.isEllipsis ? '...' : 'Any';
|
555
554
|
}
|
556
555
|
}
|
557
556
|
return '';
|
@@ -566,12 +565,12 @@ function printFunctionType(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
566
565
|
const typeWithoutParamSpec = paramSpec ? types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(type) : type;
|
567
566
|
// Callable works only in cases where all parameters are positional-only.
|
568
567
|
let isPositionalParamsOnly = false;
|
569
|
-
if (typeWithoutParamSpec.
|
568
|
+
if (typeWithoutParamSpec.shared.parameters.length === 0) {
|
570
569
|
isPositionalParamsOnly = true;
|
571
570
|
}
|
572
571
|
else {
|
573
|
-
if (typeWithoutParamSpec.
|
574
|
-
const lastParam = typeWithoutParamSpec.
|
572
|
+
if (typeWithoutParamSpec.shared.parameters.every((param) => param.category === 0 /* ParameterCategory.Simple */)) {
|
573
|
+
const lastParam = typeWithoutParamSpec.shared.parameters[typeWithoutParamSpec.shared.parameters.length - 1];
|
575
574
|
if (!lastParam.name) {
|
576
575
|
isPositionalParamsOnly = true;
|
577
576
|
}
|
@@ -584,7 +583,7 @@ function printFunctionType(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
584
583
|
}
|
585
584
|
if (isPositionalParamsOnly) {
|
586
585
|
const paramTypes = [];
|
587
|
-
typeWithoutParamSpec.
|
586
|
+
typeWithoutParamSpec.shared.parameters.forEach((param, index) => {
|
588
587
|
if (param.name) {
|
589
588
|
const paramType = types_1.FunctionType.getEffectiveParameterType(typeWithoutParamSpec, index);
|
590
589
|
if (recursionTypes.length < types_1.maxTypeRecursionCount) {
|
@@ -597,9 +596,9 @@ function printFunctionType(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
597
596
|
});
|
598
597
|
if (paramSpec) {
|
599
598
|
if (paramTypes.length > 0) {
|
600
|
-
return `Callable[Concatenate[${paramTypes.join(', ')}, ${paramSpec.
|
599
|
+
return `Callable[Concatenate[${paramTypes.join(', ')}, ${paramSpec.shared.name}], ${returnTypeString}]`;
|
601
600
|
}
|
602
|
-
return `Callable[${paramSpec.
|
601
|
+
return `Callable[${paramSpec.shared.name}, ${returnTypeString}]`;
|
603
602
|
}
|
604
603
|
return `Callable[[${paramTypes.join(', ')}], ${returnTypeString}]`;
|
605
604
|
}
|
@@ -628,10 +627,10 @@ function printFunctionType(type, printTypeFlags, returnTypeCallback, uniqueNameM
|
|
628
627
|
}
|
629
628
|
function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount) {
|
630
629
|
var _a, _b;
|
631
|
-
let objName = type.aliasName;
|
630
|
+
let objName = type.priv.aliasName;
|
632
631
|
if (!objName) {
|
633
632
|
objName =
|
634
|
-
(printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0 ? type.
|
633
|
+
(printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0 ? type.shared.fullName : type.shared.name;
|
635
634
|
}
|
636
635
|
// Special-case NoneType to convert it to None.
|
637
636
|
if (types_1.ClassType.isBuiltIn(type, 'NoneType')) {
|
@@ -639,16 +638,16 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
639
638
|
}
|
640
639
|
// Use the fully-qualified name if the name isn't unique.
|
641
640
|
if (!uniqueNameMap.isUnique(objName)) {
|
642
|
-
objName = type.
|
641
|
+
objName = type.shared.fullName;
|
643
642
|
}
|
644
643
|
// If this is a pseudo-generic class, don't display the type arguments
|
645
644
|
// or type parameters because it will confuse users.
|
646
645
|
if (!types_1.ClassType.isPseudoGenericClass(type)) {
|
647
646
|
const typeParams = types_1.ClassType.getTypeParameters(type);
|
648
647
|
const lastTypeParam = typeParams.length > 0 ? typeParams[typeParams.length - 1] : undefined;
|
649
|
-
const isVariadic = lastTypeParam ? lastTypeParam.
|
648
|
+
const isVariadic = lastTypeParam ? lastTypeParam.shared.isVariadic : false;
|
650
649
|
// If there is a type arguments array, it's a specialized class.
|
651
|
-
const typeArgs = (_a = type.tupleTypeArguments) !== null && _a !== void 0 ? _a : (_b = type.typeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => {
|
650
|
+
const typeArgs = (_a = type.priv.tupleTypeArguments) !== null && _a !== void 0 ? _a : (_b = type.priv.typeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => {
|
652
651
|
return { type: t, isUnbounded: false };
|
653
652
|
});
|
654
653
|
if (typeArgs) {
|
@@ -659,12 +658,12 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
659
658
|
typeArgs.forEach((typeArg, index) => {
|
660
659
|
const typeParam = index < typeParams.length ? typeParams[index] : undefined;
|
661
660
|
if (typeParam &&
|
662
|
-
typeParam.
|
661
|
+
typeParam.shared.isVariadic &&
|
663
662
|
(0, types_1.isClassInstance)(typeArg.type) &&
|
664
663
|
types_1.ClassType.isBuiltIn(typeArg.type, 'tuple') &&
|
665
|
-
typeArg.type.tupleTypeArguments) {
|
664
|
+
typeArg.type.priv.tupleTypeArguments) {
|
666
665
|
// Expand the tuple type that maps to the variadic type parameter.
|
667
|
-
if (typeArg.type.tupleTypeArguments.length === 0) {
|
666
|
+
if (typeArg.type.priv.tupleTypeArguments.length === 0) {
|
668
667
|
if (!(0, types_1.isUnknown)(typeArg.type)) {
|
669
668
|
isAllUnknown = false;
|
670
669
|
}
|
@@ -673,7 +672,7 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
673
672
|
}
|
674
673
|
}
|
675
674
|
else {
|
676
|
-
(0, collectionUtils_1.appendArray)(typeArgStrings, typeArg.type.tupleTypeArguments.map((typeArg) => {
|
675
|
+
(0, collectionUtils_1.appendArray)(typeArgStrings, typeArg.type.priv.tupleTypeArguments.map((typeArg) => {
|
677
676
|
if (!(0, types_1.isUnknown)(typeArg.type)) {
|
678
677
|
isAllUnknown = false;
|
679
678
|
}
|
@@ -703,7 +702,7 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
703
702
|
}
|
704
703
|
}
|
705
704
|
});
|
706
|
-
if (type.isUnpacked) {
|
705
|
+
if (type.priv.isUnpacked) {
|
707
706
|
objName = _printUnpack(objName, printTypeFlags);
|
708
707
|
}
|
709
708
|
if ((printTypeFlags & 2 /* PrintTypeFlags.OmitTypeArgumentsIfUnknown */) === 0 || !isAllUnknown) {
|
@@ -711,7 +710,7 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
711
710
|
}
|
712
711
|
}
|
713
712
|
else {
|
714
|
-
if (type.isUnpacked) {
|
713
|
+
if (type.priv.isUnpacked) {
|
715
714
|
objName = _printUnpack(objName, printTypeFlags);
|
716
715
|
}
|
717
716
|
if (types_1.ClassType.isTupleClass(type) || isVariadic) {
|
@@ -720,7 +719,7 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
720
719
|
}
|
721
720
|
}
|
722
721
|
else {
|
723
|
-
if (type.isUnpacked) {
|
722
|
+
if (type.priv.isUnpacked) {
|
724
723
|
objName = _printUnpack(objName, printTypeFlags);
|
725
724
|
}
|
726
725
|
if (typeParams.length > 0) {
|
@@ -739,7 +738,7 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
739
738
|
}
|
740
739
|
}
|
741
740
|
// Wrap in a "Partial" for TypedDict that has been synthesized as partial.
|
742
|
-
if (type.isTypedDictPartial) {
|
741
|
+
if (type.priv.isTypedDictPartial) {
|
743
742
|
if ((printTypeFlags & 256 /* PrintTypeFlags.PythonSyntax */) === 0) {
|
744
743
|
objName = `Partial[${objName}]`;
|
745
744
|
}
|
@@ -747,23 +746,25 @@ function printObjectTypeForClassInternal(type, printTypeFlags, returnTypeCallbac
|
|
747
746
|
return objName;
|
748
747
|
}
|
749
748
|
function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount) {
|
749
|
+
var _a;
|
750
750
|
const paramTypeStrings = [];
|
751
751
|
let sawDefinedName = false;
|
752
|
+
const functionNode = (_a = type.shared.declaration) === null || _a === void 0 ? void 0 : _a.node;
|
752
753
|
// Remove the (*args: P.args, **kwargs: P.kwargs) from the end of the parameter list.
|
753
754
|
const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(type);
|
754
755
|
if (paramSpec) {
|
755
756
|
type = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(type);
|
756
757
|
}
|
757
|
-
type.
|
758
|
+
type.shared.parameters.forEach((param, index) => {
|
758
759
|
// Handle specialized variadic type parameters specially.
|
759
|
-
if (index === type.
|
760
|
+
if (index === type.shared.parameters.length - 1 &&
|
760
761
|
param.category === 1 /* ParameterCategory.ArgsList */ &&
|
761
762
|
(0, types_1.isVariadicTypeVar)(param.type)) {
|
762
763
|
const specializedParamType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
763
764
|
if ((0, types_1.isClassInstance)(specializedParamType) &&
|
764
765
|
types_1.ClassType.isBuiltIn(specializedParamType, 'tuple') &&
|
765
|
-
specializedParamType.tupleTypeArguments) {
|
766
|
-
specializedParamType.tupleTypeArguments.forEach((paramType) => {
|
766
|
+
specializedParamType.priv.tupleTypeArguments) {
|
767
|
+
specializedParamType.priv.tupleTypeArguments.forEach((paramType) => {
|
767
768
|
const paramString = printTypeInternal(paramType.type, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
768
769
|
paramTypeStrings.push(paramString);
|
769
770
|
});
|
@@ -774,7 +775,7 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
774
775
|
if ((0, parameterUtils_1.isTypedKwargs)(param) &&
|
775
776
|
printTypeFlags & 1024 /* PrintTypeFlags.ExpandTypedDictArgs */ &&
|
776
777
|
param.type.category === 6 /* TypeCategory.Class */) {
|
777
|
-
param.type.
|
778
|
+
param.type.shared.typedDictEntries.knownItems.forEach((v, k) => {
|
778
779
|
const valueTypeString = printTypeInternal(v.valueType, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
779
780
|
paramTypeStrings.push(`${k}: ${valueTypeString}`);
|
780
781
|
});
|
@@ -782,7 +783,7 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
782
783
|
}
|
783
784
|
let paramString = '';
|
784
785
|
if (param.category === 1 /* ParameterCategory.ArgsList */) {
|
785
|
-
if (!param.name || !
|
786
|
+
if (!param.name || !types_1.FunctionParam.isNameSynthesized(param)) {
|
786
787
|
paramString += '*';
|
787
788
|
}
|
788
789
|
}
|
@@ -790,7 +791,7 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
790
791
|
paramString += '**';
|
791
792
|
}
|
792
793
|
let emittedParamName = false;
|
793
|
-
if (param.name && !
|
794
|
+
if (param.name && !types_1.FunctionParam.isNameSynthesized(param)) {
|
794
795
|
paramString += param.name;
|
795
796
|
sawDefinedName = true;
|
796
797
|
emittedParamName = true;
|
@@ -804,7 +805,7 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
804
805
|
let isParamSpecArgsKwargsParam = false;
|
805
806
|
if (param.name) {
|
806
807
|
// Avoid printing type types if parameter have unknown type.
|
807
|
-
if (param
|
808
|
+
if (types_1.FunctionParam.isTypeDeclared(param) || types_1.FunctionParam.isTypeInferred(param)) {
|
808
809
|
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
809
810
|
let paramTypeString = recursionTypes.length < types_1.maxTypeRecursionCount
|
810
811
|
? printTypeInternal(paramType, printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount)
|
@@ -837,7 +838,7 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
837
838
|
defaultValueAssignment = ' = ';
|
838
839
|
}
|
839
840
|
else if ((printTypeFlags & 2 /* PrintTypeFlags.OmitTypeArgumentsIfUnknown */) === 0) {
|
840
|
-
if (!
|
841
|
+
if (!types_1.FunctionParam.isNameSynthesized(param)) {
|
841
842
|
paramString += ': ';
|
842
843
|
}
|
843
844
|
if (printTypeFlags & (1 /* PrintTypeFlags.PrintUnknownWithAny */ | 256 /* PrintTypeFlags.PythonSyntax */)) {
|
@@ -857,9 +858,10 @@ function printFunctionPartsInternal(type, printTypeFlags, returnTypeCallback, un
|
|
857
858
|
return;
|
858
859
|
}
|
859
860
|
}
|
860
|
-
if (param.
|
861
|
-
|
862
|
-
|
861
|
+
if (param.defaultType) {
|
862
|
+
const paramNode = functionNode === null || functionNode === void 0 ? void 0 : functionNode.d.params.find((p) => { var _a; return ((_a = p.d.name) === null || _a === void 0 ? void 0 : _a.d.value) === param.name; });
|
863
|
+
if (paramNode === null || paramNode === void 0 ? void 0 : paramNode.d.defaultValue) {
|
864
|
+
paramString += defaultValueAssignment + ParseTreeUtils.printExpression(paramNode.d.defaultValue);
|
863
865
|
}
|
864
866
|
else {
|
865
867
|
// If the function doesn't originate from a function declaration (e.g. it is
|
@@ -900,8 +902,8 @@ function _printUnpack(textToWrap, flags) {
|
|
900
902
|
// Surrounds a printed type with Type[...] as many times as needed
|
901
903
|
// for the nested instantiable count.
|
902
904
|
function _printNestedInstantiable(type, textToWrap) {
|
903
|
-
var _a;
|
904
|
-
const nestedTypes = ((_a = type.
|
905
|
+
var _a, _b;
|
906
|
+
const nestedTypes = ((_b = (_a = type.props) === null || _a === void 0 ? void 0 : _a.instantiableDepth) !== null && _b !== void 0 ? _b : 0) + 1;
|
905
907
|
for (let nestLevel = 0; nestLevel < nestedTypes; nestLevel++) {
|
906
908
|
textToWrap = `type[${textToWrap}]`;
|
907
909
|
}
|
@@ -909,13 +911,13 @@ function _printNestedInstantiable(type, textToWrap) {
|
|
909
911
|
}
|
910
912
|
function _getReadableTypeVarName(type, usePythonSyntax) {
|
911
913
|
if (usePythonSyntax) {
|
912
|
-
return type.
|
914
|
+
return type.shared.name;
|
913
915
|
}
|
914
916
|
return types_1.TypeVarType.getReadableName(type);
|
915
917
|
}
|
916
918
|
function _getTypeVarVarianceText(type) {
|
917
919
|
var _a;
|
918
|
-
const computedVariance = (_a = type.computedVariance) !== null && _a !== void 0 ? _a : type.
|
920
|
+
const computedVariance = (_a = type.priv.computedVariance) !== null && _a !== void 0 ? _a : type.shared.declaredVariance;
|
919
921
|
if (computedVariance === 2 /* Variance.Invariant */) {
|
920
922
|
return 'invariant';
|
921
923
|
}
|
@@ -937,12 +939,13 @@ class UniqueNameMap {
|
|
937
939
|
this._map = new Map();
|
938
940
|
}
|
939
941
|
build(type, recursionTypes = [], recursionCount = 0) {
|
940
|
-
var _a;
|
942
|
+
var _a, _b;
|
941
943
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
942
944
|
return;
|
943
945
|
}
|
944
946
|
recursionCount++;
|
945
|
-
|
947
|
+
const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
|
948
|
+
if (aliasInfo) {
|
946
949
|
let expandTypeAlias = true;
|
947
950
|
if ((this._printTypeFlags & 32 /* PrintTypeFlags.ExpandTypeAlias */) === 0) {
|
948
951
|
expandTypeAlias = false;
|
@@ -954,14 +957,14 @@ class UniqueNameMap {
|
|
954
957
|
}
|
955
958
|
if (!expandTypeAlias) {
|
956
959
|
const typeAliasName = (this._printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0
|
957
|
-
?
|
958
|
-
:
|
960
|
+
? aliasInfo.fullName
|
961
|
+
: aliasInfo.name;
|
959
962
|
this._addIfUnique(typeAliasName, type, /* useTypeAliasName */ true);
|
960
963
|
// Recursively add the type arguments if present.
|
961
|
-
if (
|
964
|
+
if (aliasInfo.typeArguments) {
|
962
965
|
recursionTypes.push(type);
|
963
966
|
try {
|
964
|
-
|
967
|
+
aliasInfo.typeArguments.forEach((typeArg) => {
|
965
968
|
this.build(typeArg, recursionTypes, recursionCount);
|
966
969
|
});
|
967
970
|
}
|
@@ -976,7 +979,7 @@ class UniqueNameMap {
|
|
976
979
|
recursionTypes.push(type);
|
977
980
|
switch (type.category) {
|
978
981
|
case 4 /* TypeCategory.Function */: {
|
979
|
-
type.
|
982
|
+
type.shared.parameters.forEach((_, index) => {
|
980
983
|
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
981
984
|
this.build(paramType, recursionTypes, recursionCount);
|
982
985
|
});
|
@@ -985,31 +988,31 @@ class UniqueNameMap {
|
|
985
988
|
break;
|
986
989
|
}
|
987
990
|
case 5 /* TypeCategory.OverloadedFunction */: {
|
988
|
-
type.overloads.forEach((overload) => {
|
991
|
+
type.priv.overloads.forEach((overload) => {
|
989
992
|
this.build(overload, recursionTypes, recursionCount);
|
990
993
|
});
|
991
994
|
break;
|
992
995
|
}
|
993
996
|
case 6 /* TypeCategory.Class */: {
|
994
|
-
if (type.literalValue !== undefined) {
|
997
|
+
if (type.priv.literalValue !== undefined) {
|
995
998
|
break;
|
996
999
|
}
|
997
|
-
let className = type.aliasName;
|
1000
|
+
let className = type.priv.aliasName;
|
998
1001
|
if (!className) {
|
999
1002
|
className =
|
1000
1003
|
(this._printTypeFlags & 4096 /* PrintTypeFlags.UseFullyQualifiedNames */) !== 0
|
1001
|
-
? type.
|
1002
|
-
: type.
|
1004
|
+
? type.shared.fullName
|
1005
|
+
: type.shared.name;
|
1003
1006
|
}
|
1004
1007
|
this._addIfUnique(className, type);
|
1005
1008
|
if (!types_1.ClassType.isPseudoGenericClass(type)) {
|
1006
|
-
if (type.tupleTypeArguments) {
|
1007
|
-
type.tupleTypeArguments.forEach((typeArg) => {
|
1009
|
+
if (type.priv.tupleTypeArguments) {
|
1010
|
+
type.priv.tupleTypeArguments.forEach((typeArg) => {
|
1008
1011
|
this.build(typeArg.type, recursionTypes, recursionCount);
|
1009
1012
|
});
|
1010
1013
|
}
|
1011
|
-
else if (type.typeArguments) {
|
1012
|
-
type.typeArguments.forEach((typeArg) => {
|
1014
|
+
else if (type.priv.typeArguments) {
|
1015
|
+
type.priv.typeArguments.forEach((typeArg) => {
|
1013
1016
|
this.build(typeArg, recursionTypes, recursionCount);
|
1014
1017
|
});
|
1015
1018
|
}
|
@@ -1020,7 +1023,7 @@ class UniqueNameMap {
|
|
1020
1023
|
(0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
|
1021
1024
|
this.build(subtype, recursionTypes, recursionCount);
|
1022
1025
|
});
|
1023
|
-
(
|
1026
|
+
(_b = type.priv.typeAliasSources) === null || _b === void 0 ? void 0 : _b.forEach((typeAliasSource) => {
|
1024
1027
|
this.build(typeAliasSource, recursionTypes, recursionCount);
|
1025
1028
|
});
|
1026
1029
|
break;
|
@@ -1047,9 +1050,9 @@ class UniqueNameMap {
|
|
1047
1050
|
}
|
1048
1051
|
}
|
1049
1052
|
_isSameTypeName(type1, type2, useTypeAliasName) {
|
1050
|
-
var _a, _b;
|
1053
|
+
var _a, _b, _c, _d;
|
1051
1054
|
if (useTypeAliasName) {
|
1052
|
-
return ((_a = type1.
|
1055
|
+
return ((_b = (_a = type1.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.fullName) === ((_d = (_c = type2.props) === null || _c === void 0 ? void 0 : _c.typeAliasInfo) === null || _d === void 0 ? void 0 : _d.fullName);
|
1053
1056
|
}
|
1054
1057
|
if ((0, types_1.isClass)(type1) && (0, types_1.isClass)(type2)) {
|
1055
1058
|
return types_1.ClassType.isSameGenericClass(type1, type2);
|