@zzzen/pyright-internal 1.2.0-dev.20231022 → 1.2.0-dev.20231105
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/analyzerFileInfo.d.ts +1 -0
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +3 -4
- package/dist/analyzer/backgroundAnalysisProgram.js +6 -3
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +1 -6
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.d.ts +3 -0
- package/dist/analyzer/cacheManager.js +11 -0
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.js +57 -50
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +0 -1
- package/dist/analyzer/codeFlowEngine.js +5 -5
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +4 -2
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +11 -9
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +1 -1
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +41 -36
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +3 -3
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/enums.d.ts +2 -5
- package/dist/analyzer/enums.js +4 -2
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +1 -1
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +6 -2
- package/dist/analyzer/importResolver.js +51 -8
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/namedTuples.js +3 -2
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +22 -25
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +19 -21
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -0
- package/dist/analyzer/parseTreeUtils.js +11 -2
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +5 -5
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +3 -4
- package/dist/analyzer/program.js +22 -27
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +5 -5
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +24 -6
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.d.ts +1 -2
- package/dist/analyzer/service.js +16 -6
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +1 -1
- package/dist/analyzer/sourceFile.js +3 -9
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.d.ts +0 -4
- package/dist/analyzer/sourceFileInfo.js +0 -9
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +11 -13
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +3 -3
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +867 -889
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +13 -25
- package/dist/analyzer/typeEvaluatorTypes.js +4 -36
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +27 -23
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +19 -18
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +17 -8
- package/dist/analyzer/typeUtils.js +146 -93
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.js +6 -7
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.d.ts +1 -2
- package/dist/analyzer/typeWalker.js +7 -13
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +17 -17
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +10 -22
- package/dist/analyzer/types.js +48 -86
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +3 -1
- package/dist/backgroundAnalysisBase.js +27 -0
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +7 -9
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +2 -1
- package/dist/common/commandLineOptions.js +1 -1
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -1
- package/dist/common/configOptions.js +22 -24
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/fullAccessHost.js +16 -1
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/pathUtils.d.ts +2 -2
- package/dist/common/pathUtils.js +18 -11
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +15 -14
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProviderExtensions.d.ts +2 -0
- package/dist/common/serviceProviderExtensions.js +5 -0
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/languageServerBase.d.ts +4 -6
- package/dist/languageServerBase.js +16 -19
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +1 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +3 -3
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +8 -8
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +1 -1
- package/dist/languageService/definitionProvider.js +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +7 -0
- package/dist/languageService/documentSymbolCollector.js +29 -4
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.js +1 -1
- package/dist/languageService/signatureHelpProvider.js +0 -14
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +4 -4
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +12 -0
- package/dist/localization/localize.js +6 -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 +4 -0
- 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 +3 -6
- package/dist/pyright.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +12 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js +46 -0
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +1 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +4 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js +4 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js +4 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/fourslash.d.ts +3 -0
- package/dist/tests/fourslash/hover.class.docString.fourslash.js +4 -0
- package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +4 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/{hover.docFromScr.stringFormat.fourslash.js → hover.docFromSrc.stringFormat.fourslash.js} +1 -1
- package/dist/tests/fourslash/{hover.docFromScr.stringFormat.fourslash.js.map → hover.docFromSrc.stringFormat.fourslash.js.map} +1 -1
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.js +24 -0
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +4 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js +6 -6
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js +4 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +2 -2
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +6 -4
- package/dist/tests/harness/fourslash/testState.js +24 -9
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +1 -1
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +0 -31
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/logger.test.js +0 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +47 -0
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/testUtils.js +2 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +3 -3
- package/dist/tests/typeEvaluator2.test.js +2 -2
- package/dist/tests/typeEvaluator3.test.js +7 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +5 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typePrinter.test.js +12 -16
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +2 -0
- package/dist/tests/zipfs.test.js.map +1 -1
- package/package.json +1 -1
- /package/dist/tests/fourslash/{hover.docFromScr.stringFormat.fourslash.d.ts → completions.importInterimFile.fourslash.disabled.d.ts} +0 -0
package/dist/analyzer/types.js
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
* Representation of types used during type analysis within Python.
|
9
9
|
*/
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
-
exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isParamSpec = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedVariadicTypeVar = exports.isVariadicTypeVar = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.
|
12
|
-
exports.isSameWithoutLiteralValue =
|
11
|
+
exports.combineTypes = exports.findSubtype = exports.removeFromUnion = exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isParamSpec = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedVariadicTypeVar = exports.isVariadicTypeVar = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.isNever = exports.TypeVarType = exports.TypeVarScopeType = exports.Variance = exports.UnionType = exports.TypeCondition = exports.AnyType = exports.NeverType = exports.OverloadedFunctionType = exports.FunctionType = exports.FunctionTypeFlags = exports.isKeywordOnlySeparator = exports.isPositionOnlySeparator = exports.ClassType = exports.ClassTypeFlags = exports.ModuleType = exports.UnknownType = exports.UnboundType = exports.TypeBase = exports.maxTypeRecursionCount = exports.EnumLiteral = exports.InScopePlaceholderScopeId = exports.WildcardTypeVarScopeId = exports.TypeFlags = exports.TypeCategory = void 0;
|
12
|
+
exports.isSameWithoutLiteralValue = void 0;
|
13
13
|
const debug_1 = require("../common/debug");
|
14
14
|
var TypeCategory;
|
15
15
|
(function (TypeCategory) {
|
@@ -21,26 +21,24 @@ var TypeCategory;
|
|
21
21
|
TypeCategory[TypeCategory["Unknown"] = 1] = "Unknown";
|
22
22
|
// Type can be anything.
|
23
23
|
TypeCategory[TypeCategory["Any"] = 2] = "Any";
|
24
|
-
// Special "None" type defined in Python.
|
25
|
-
TypeCategory[TypeCategory["None"] = 3] = "None";
|
26
24
|
// Used in type narrowing to indicate that all possible
|
27
25
|
// subtypes in a union have been eliminated, and execution
|
28
26
|
// should never get to this point.
|
29
|
-
TypeCategory[TypeCategory["Never"] =
|
27
|
+
TypeCategory[TypeCategory["Never"] = 3] = "Never";
|
30
28
|
// Callable type with typed input parameters and return parameter.
|
31
|
-
TypeCategory[TypeCategory["Function"] =
|
29
|
+
TypeCategory[TypeCategory["Function"] = 4] = "Function";
|
32
30
|
// Functions defined with @overload decorator in stub files that
|
33
31
|
// have multiple function declarations for a common implementation.
|
34
|
-
TypeCategory[TypeCategory["OverloadedFunction"] =
|
32
|
+
TypeCategory[TypeCategory["OverloadedFunction"] = 5] = "OverloadedFunction";
|
35
33
|
// Class definition, including associated instance methods,
|
36
34
|
// class methods, static methods, properties, and variables.
|
37
|
-
TypeCategory[TypeCategory["Class"] =
|
35
|
+
TypeCategory[TypeCategory["Class"] = 6] = "Class";
|
38
36
|
// Module instance.
|
39
|
-
TypeCategory[TypeCategory["Module"] =
|
40
|
-
// Composite type (e.g. Number OR String
|
41
|
-
TypeCategory[TypeCategory["Union"] =
|
37
|
+
TypeCategory[TypeCategory["Module"] = 7] = "Module";
|
38
|
+
// Composite type (e.g. Number OR String).
|
39
|
+
TypeCategory[TypeCategory["Union"] = 8] = "Union";
|
42
40
|
// Type variable (defined with TypeVar)
|
43
|
-
TypeCategory[TypeCategory["TypeVar"] =
|
41
|
+
TypeCategory[TypeCategory["TypeVar"] = 9] = "TypeVar";
|
44
42
|
})(TypeCategory = exports.TypeCategory || (exports.TypeCategory = {}));
|
45
43
|
var TypeFlags;
|
46
44
|
(function (TypeFlags) {
|
@@ -235,7 +233,7 @@ var ModuleType;
|
|
235
233
|
(function (ModuleType) {
|
236
234
|
function create(moduleName, filePath, symbolTable) {
|
237
235
|
const newModuleType = {
|
238
|
-
category:
|
236
|
+
category: 7 /* Module */,
|
239
237
|
fields: symbolTable || new Map(),
|
240
238
|
loaderFields: new Map(),
|
241
239
|
flags: 1 /* Instantiable */ | 1 /* Instantiable */,
|
@@ -295,9 +293,6 @@ var ClassTypeFlags;
|
|
295
293
|
// Used in conjunction with TypedDictClass, indicates that
|
296
294
|
// the dictionary values can be omitted.
|
297
295
|
ClassTypeFlags[ClassTypeFlags["CanOmitDictValues"] = 256] = "CanOmitDictValues";
|
298
|
-
// Used in conjunction with TypedDictClass, indicates that
|
299
|
-
// the dictionary values are all readonly.
|
300
|
-
ClassTypeFlags[ClassTypeFlags["DictValuesReadOnly"] = 512] = "DictValuesReadOnly";
|
301
296
|
// The class derives from a class that has the ABCMeta
|
302
297
|
// metaclass. Such classes are allowed to contain
|
303
298
|
// @abstractmethod decorators.
|
@@ -356,7 +351,7 @@ var ClassType;
|
|
356
351
|
(function (ClassType) {
|
357
352
|
function createInstantiable(name, fullName, moduleName, filePath, flags, typeSourceId, declaredMetaclass, effectiveMetaclass, docString) {
|
358
353
|
const newClass = {
|
359
|
-
category:
|
354
|
+
category: 6 /* Class */,
|
360
355
|
details: {
|
361
356
|
name,
|
362
357
|
fullName,
|
@@ -408,7 +403,7 @@ var ClassType;
|
|
408
403
|
ClassType.cloneAsInstantiable = cloneAsInstantiable;
|
409
404
|
function cloneForSpecialization(classType, typeArguments, isTypeArgumentExplicit, includeSubclasses = false, tupleTypeArguments, isEmptyContainer) {
|
410
405
|
const newClassType = TypeBase.cloneType(classType);
|
411
|
-
newClassType.typeArguments = typeArguments;
|
406
|
+
newClassType.typeArguments = (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 0 ? undefined : typeArguments;
|
412
407
|
newClassType.isTypeArgumentExplicit = isTypeArgumentExplicit;
|
413
408
|
if (includeSubclasses) {
|
414
409
|
newClassType.includeSubclasses = true;
|
@@ -650,10 +645,6 @@ var ClassType;
|
|
650
645
|
return !!(classType.details.flags & 256 /* CanOmitDictValues */);
|
651
646
|
}
|
652
647
|
ClassType.isCanOmitDictValues = isCanOmitDictValues;
|
653
|
-
function isDictValuesReadOnly(classType) {
|
654
|
-
return !!(classType.details.flags & 512 /* DictValuesReadOnly */);
|
655
|
-
}
|
656
|
-
ClassType.isDictValuesReadOnly = isDictValuesReadOnly;
|
657
648
|
function isEnumClass(classType) {
|
658
649
|
return !!(classType.details.flags & 1048576 /* EnumClass */);
|
659
650
|
}
|
@@ -917,7 +908,7 @@ var FunctionType;
|
|
917
908
|
FunctionType.createSynthesizedInstance = createSynthesizedInstance;
|
918
909
|
function create(name, fullName, moduleName, functionFlags, typeFlags, docString) {
|
919
910
|
const newFunctionType = {
|
920
|
-
category:
|
911
|
+
category: 4 /* Function */,
|
921
912
|
details: {
|
922
913
|
name,
|
923
914
|
fullName,
|
@@ -1336,6 +1327,9 @@ var FunctionType;
|
|
1336
1327
|
FunctionType.getEffectiveParameterDefaultArgType = getEffectiveParameterDefaultArgType;
|
1337
1328
|
function addParameter(type, param) {
|
1338
1329
|
type.details.parameters.push(param);
|
1330
|
+
if (type.specializedTypes) {
|
1331
|
+
type.specializedTypes.parameterTypes.push(param.type);
|
1332
|
+
}
|
1339
1333
|
}
|
1340
1334
|
FunctionType.addParameter = addParameter;
|
1341
1335
|
function getSpecializedReturnType(type) {
|
@@ -1349,7 +1343,7 @@ var OverloadedFunctionType;
|
|
1349
1343
|
(function (OverloadedFunctionType) {
|
1350
1344
|
function create(overloads) {
|
1351
1345
|
const newType = {
|
1352
|
-
category:
|
1346
|
+
category: 5 /* OverloadedFunction */,
|
1353
1347
|
overloads: [],
|
1354
1348
|
flags: 2 /* Instance */,
|
1355
1349
|
};
|
@@ -1374,34 +1368,15 @@ var OverloadedFunctionType;
|
|
1374
1368
|
}
|
1375
1369
|
OverloadedFunctionType.getImplementation = getImplementation;
|
1376
1370
|
})(OverloadedFunctionType = exports.OverloadedFunctionType || (exports.OverloadedFunctionType = {}));
|
1377
|
-
var NoneType;
|
1378
|
-
(function (NoneType) {
|
1379
|
-
const _noneInstance = {
|
1380
|
-
category: 3 /* None */,
|
1381
|
-
flags: 2 /* Instance */,
|
1382
|
-
};
|
1383
|
-
const _noneType = {
|
1384
|
-
category: 3 /* None */,
|
1385
|
-
flags: 1 /* Instantiable */,
|
1386
|
-
};
|
1387
|
-
function createInstance() {
|
1388
|
-
return _noneInstance;
|
1389
|
-
}
|
1390
|
-
NoneType.createInstance = createInstance;
|
1391
|
-
function createType() {
|
1392
|
-
return _noneType;
|
1393
|
-
}
|
1394
|
-
NoneType.createType = createType;
|
1395
|
-
})(NoneType = exports.NoneType || (exports.NoneType = {}));
|
1396
1371
|
var NeverType;
|
1397
1372
|
(function (NeverType) {
|
1398
1373
|
const _neverInstance = {
|
1399
|
-
category:
|
1374
|
+
category: 3 /* Never */,
|
1400
1375
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1401
1376
|
isNoReturn: false,
|
1402
1377
|
};
|
1403
1378
|
const _noReturnInstance = {
|
1404
|
-
category:
|
1379
|
+
category: 3 /* Never */,
|
1405
1380
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1406
1381
|
isNoReturn: true,
|
1407
1382
|
};
|
@@ -1526,7 +1501,7 @@ var UnionType;
|
|
1526
1501
|
(function (UnionType) {
|
1527
1502
|
function create() {
|
1528
1503
|
const newUnionType = {
|
1529
|
-
category:
|
1504
|
+
category: 8 /* Union */,
|
1530
1505
|
subtypes: [],
|
1531
1506
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1532
1507
|
};
|
@@ -1599,7 +1574,7 @@ var UnionType;
|
|
1599
1574
|
}
|
1600
1575
|
UnionType.containsType = containsType;
|
1601
1576
|
function addTypeAliasSource(unionType, typeAliasSource) {
|
1602
|
-
if (typeAliasSource.category ===
|
1577
|
+
if (typeAliasSource.category === 8 /* Union */) {
|
1603
1578
|
const sourcesToAdd = typeAliasSource.typeAliasInfo ? [typeAliasSource] : typeAliasSource.typeAliasSources;
|
1604
1579
|
if (sourcesToAdd) {
|
1605
1580
|
if (!unionType.typeAliasSources) {
|
@@ -1633,8 +1608,8 @@ var TypeVarType;
|
|
1633
1608
|
return create(name, /* isParamSpec */ false, 2 /* Instance */);
|
1634
1609
|
}
|
1635
1610
|
TypeVarType.createInstance = createInstance;
|
1636
|
-
function createInstantiable(name, isParamSpec = false) {
|
1637
|
-
return create(name, isParamSpec, 1 /* Instantiable
|
1611
|
+
function createInstantiable(name, isParamSpec = false, runtimeClass) {
|
1612
|
+
return create(name, isParamSpec, 1 /* Instantiable */, runtimeClass);
|
1638
1613
|
}
|
1639
1614
|
TypeVarType.createInstantiable = createInstantiable;
|
1640
1615
|
function cloneAsInstance(type) {
|
@@ -1753,9 +1728,9 @@ var TypeVarType;
|
|
1753
1728
|
return `${name}.${scopeId}`;
|
1754
1729
|
}
|
1755
1730
|
TypeVarType.makeNameWithScope = makeNameWithScope;
|
1756
|
-
function create(name, isParamSpec, typeFlags) {
|
1731
|
+
function create(name, isParamSpec, typeFlags, runtimeClass) {
|
1757
1732
|
const newTypeVarType = {
|
1758
|
-
category:
|
1733
|
+
category: 9 /* TypeVar */,
|
1759
1734
|
details: {
|
1760
1735
|
name,
|
1761
1736
|
constraints: [],
|
@@ -1763,6 +1738,7 @@ var TypeVarType;
|
|
1763
1738
|
isParamSpec,
|
1764
1739
|
isVariadic: false,
|
1765
1740
|
isSynthesized: false,
|
1741
|
+
runtimeClass,
|
1766
1742
|
},
|
1767
1743
|
flags: typeFlags,
|
1768
1744
|
};
|
@@ -1805,17 +1781,9 @@ var TypeVarType;
|
|
1805
1781
|
TypeVarType.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
1806
1782
|
})(TypeVarType = exports.TypeVarType || (exports.TypeVarType = {}));
|
1807
1783
|
function isNever(type) {
|
1808
|
-
return type.category ===
|
1784
|
+
return type.category === 3 /* Never */;
|
1809
1785
|
}
|
1810
1786
|
exports.isNever = isNever;
|
1811
|
-
function isNoneInstance(type) {
|
1812
|
-
return type.category === 3 /* None */ && TypeBase.isInstance(type);
|
1813
|
-
}
|
1814
|
-
exports.isNoneInstance = isNoneInstance;
|
1815
|
-
function isNoneTypeClass(type) {
|
1816
|
-
return type.category === 3 /* None */ && TypeBase.isInstantiable(type);
|
1817
|
-
}
|
1818
|
-
exports.isNoneTypeClass = isNoneTypeClass;
|
1819
1787
|
function isAny(type) {
|
1820
1788
|
return type.category === 2 /* Any */;
|
1821
1789
|
}
|
@@ -1839,7 +1807,7 @@ function isUnbound(type) {
|
|
1839
1807
|
}
|
1840
1808
|
exports.isUnbound = isUnbound;
|
1841
1809
|
function isUnion(type) {
|
1842
|
-
return type.category ===
|
1810
|
+
return type.category === 8 /* Union */;
|
1843
1811
|
}
|
1844
1812
|
exports.isUnion = isUnion;
|
1845
1813
|
function isPossiblyUnbound(type) {
|
@@ -1853,31 +1821,31 @@ function isPossiblyUnbound(type) {
|
|
1853
1821
|
}
|
1854
1822
|
exports.isPossiblyUnbound = isPossiblyUnbound;
|
1855
1823
|
function isClass(type) {
|
1856
|
-
return type.category ===
|
1824
|
+
return type.category === 6 /* Class */;
|
1857
1825
|
}
|
1858
1826
|
exports.isClass = isClass;
|
1859
1827
|
function isInstantiableClass(type) {
|
1860
|
-
return type.category ===
|
1828
|
+
return type.category === 6 /* Class */ && TypeBase.isInstantiable(type);
|
1861
1829
|
}
|
1862
1830
|
exports.isInstantiableClass = isInstantiableClass;
|
1863
1831
|
function isClassInstance(type) {
|
1864
|
-
return type.category ===
|
1832
|
+
return type.category === 6 /* Class */ && TypeBase.isInstance(type);
|
1865
1833
|
}
|
1866
1834
|
exports.isClassInstance = isClassInstance;
|
1867
1835
|
function isModule(type) {
|
1868
|
-
return type.category ===
|
1836
|
+
return type.category === 7 /* Module */;
|
1869
1837
|
}
|
1870
1838
|
exports.isModule = isModule;
|
1871
1839
|
function isTypeVar(type) {
|
1872
|
-
return type.category ===
|
1840
|
+
return type.category === 9 /* TypeVar */;
|
1873
1841
|
}
|
1874
1842
|
exports.isTypeVar = isTypeVar;
|
1875
1843
|
function isVariadicTypeVar(type) {
|
1876
|
-
return type.category ===
|
1844
|
+
return type.category === 9 /* TypeVar */ && type.details.isVariadic;
|
1877
1845
|
}
|
1878
1846
|
exports.isVariadicTypeVar = isVariadicTypeVar;
|
1879
1847
|
function isUnpackedVariadicTypeVar(type) {
|
1880
|
-
return (type.category ===
|
1848
|
+
return (type.category === 9 /* TypeVar */ &&
|
1881
1849
|
type.details.isVariadic &&
|
1882
1850
|
!!type.isVariadicUnpacked &&
|
1883
1851
|
!type.isVariadicInUnion);
|
@@ -1895,15 +1863,15 @@ function isUnpacked(type) {
|
|
1895
1863
|
}
|
1896
1864
|
exports.isUnpacked = isUnpacked;
|
1897
1865
|
function isParamSpec(type) {
|
1898
|
-
return type.category ===
|
1866
|
+
return type.category === 9 /* TypeVar */ && type.details.isParamSpec;
|
1899
1867
|
}
|
1900
1868
|
exports.isParamSpec = isParamSpec;
|
1901
1869
|
function isFunction(type) {
|
1902
|
-
return type.category ===
|
1870
|
+
return type.category === 4 /* Function */;
|
1903
1871
|
}
|
1904
1872
|
exports.isFunction = isFunction;
|
1905
1873
|
function isOverloadedFunction(type) {
|
1906
|
-
return type.category ===
|
1874
|
+
return type.category === 5 /* OverloadedFunction */;
|
1907
1875
|
}
|
1908
1876
|
exports.isOverloadedFunction = isOverloadedFunction;
|
1909
1877
|
function getTypeAliasInfo(type) {
|
@@ -1960,7 +1928,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
1960
1928
|
}
|
1961
1929
|
recursionCount++;
|
1962
1930
|
switch (type1.category) {
|
1963
|
-
case
|
1931
|
+
case 6 /* Class */: {
|
1964
1932
|
const classType2 = type2;
|
1965
1933
|
// If the details are not the same it's not the same class.
|
1966
1934
|
if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
|
@@ -2011,7 +1979,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2011
1979
|
}
|
2012
1980
|
return true;
|
2013
1981
|
}
|
2014
|
-
case
|
1982
|
+
case 4 /* Function */: {
|
2015
1983
|
// Make sure the parameter counts match.
|
2016
1984
|
const functionType2 = type2;
|
2017
1985
|
const params1 = type1.details.parameters;
|
@@ -2082,7 +2050,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2082
2050
|
}
|
2083
2051
|
return true;
|
2084
2052
|
}
|
2085
|
-
case
|
2053
|
+
case 5 /* OverloadedFunction */: {
|
2086
2054
|
// Make sure the overload counts match.
|
2087
2055
|
const functionType2 = type2;
|
2088
2056
|
if (type1.overloads.length !== functionType2.overloads.length) {
|
@@ -2097,7 +2065,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2097
2065
|
}
|
2098
2066
|
return true;
|
2099
2067
|
}
|
2100
|
-
case
|
2068
|
+
case 8 /* Union */: {
|
2101
2069
|
const unionType2 = type2;
|
2102
2070
|
const subtypes1 = type1.subtypes;
|
2103
2071
|
const subtypes2 = unionType2.subtypes;
|
@@ -2109,7 +2077,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2109
2077
|
const exclusionSet = new Set();
|
2110
2078
|
return (findSubtype(type1, (subtype) => !UnionType.containsType(unionType2, subtype, exclusionSet, recursionCount)) === undefined);
|
2111
2079
|
}
|
2112
|
-
case
|
2080
|
+
case 9 /* TypeVar */: {
|
2113
2081
|
const type2TypeVar = type2;
|
2114
2082
|
if (type1.scopeId !== type2TypeVar.scopeId) {
|
2115
2083
|
return false;
|
@@ -2168,7 +2136,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2168
2136
|
}
|
2169
2137
|
return true;
|
2170
2138
|
}
|
2171
|
-
case
|
2139
|
+
case 7 /* Module */: {
|
2172
2140
|
const type2Module = type2;
|
2173
2141
|
// Module types are the same if they share the same
|
2174
2142
|
// module symbol table.
|
@@ -2208,12 +2176,6 @@ function removeUnbound(type) {
|
|
2208
2176
|
return type;
|
2209
2177
|
}
|
2210
2178
|
exports.removeUnbound = removeUnbound;
|
2211
|
-
// If the type is a union, remove an "None" type from the union,
|
2212
|
-
// returning only the known types.
|
2213
|
-
function removeNoneFromUnion(type) {
|
2214
|
-
return removeFromUnion(type, (t) => isNoneInstance(t));
|
2215
|
-
}
|
2216
|
-
exports.removeNoneFromUnion = removeNoneFromUnion;
|
2217
2179
|
function removeFromUnion(type, removeFilter) {
|
2218
2180
|
if (isUnion(type)) {
|
2219
2181
|
const remainingTypes = type.subtypes.filter((t) => !removeFilter(t));
|
@@ -2244,12 +2206,12 @@ exports.findSubtype = findSubtype;
|
|
2244
2206
|
function combineTypes(subtypes, maxSubtypeCount) {
|
2245
2207
|
// Filter out any "Never" and "NoReturn" types.
|
2246
2208
|
let sawNoReturn = false;
|
2247
|
-
if (subtypes.some((subtype) => subtype.category ===
|
2209
|
+
if (subtypes.some((subtype) => subtype.category === 3 /* Never */))
|
2248
2210
|
subtypes = subtypes.filter((subtype) => {
|
2249
|
-
if (subtype.category ===
|
2211
|
+
if (subtype.category === 3 /* Never */ && subtype.isNoReturn) {
|
2250
2212
|
sawNoReturn = true;
|
2251
2213
|
}
|
2252
|
-
return subtype.category !==
|
2214
|
+
return subtype.category !== 3 /* Never */;
|
2253
2215
|
});
|
2254
2216
|
if (subtypes.length === 0) {
|
2255
2217
|
return sawNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
|