@zzzen/pyright-internal 1.2.0-dev.20231029 → 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/checker.js +57 -50
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +4 -4
- 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 +2 -3
- 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 +2 -1
- package/dist/analyzer/importResolver.js +13 -5
- 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/patternMatching.js +5 -5
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -1
- package/dist/analyzer/program.js +17 -12
- 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 +1 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.js +11 -4
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +1 -0
- package/dist/analyzer/sourceFile.js +3 -0
- package/dist/analyzer/sourceFile.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 +748 -805
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +12 -25
- package/dist/analyzer/typeEvaluatorTypes.js +1 -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 +10 -10
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +8 -19
- package/dist/analyzer/types.js +44 -76
- package/dist/analyzer/types.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/pathUtils.d.ts +1 -1
- package/dist/common/pathUtils.js +11 -10
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +4 -6
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/languageServerBase.d.ts +2 -2
- package/dist/languageServerBase.js +14 -14
- 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.js +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 +4 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -1
- package/dist/localization/package.nls.de.json +1 -1
- package/dist/localization/package.nls.en-us.json +4 -0
- package/dist/localization/package.nls.es.json +1 -1
- package/dist/localization/package.nls.fr.json +1 -1
- package/dist/localization/package.nls.it.json +1 -1
- package/dist/localization/package.nls.ja.json +1 -1
- package/dist/localization/package.nls.ko.json +1 -1
- package/dist/localization/package.nls.pl.json +1 -1
- package/dist/localization/package.nls.pt-br.json +1 -1
- package/dist/localization/package.nls.ru.json +1 -1
- package/dist/localization/package.nls.tr.json +1 -1
- package/dist/localization/package.nls.zh-cn.json +1 -1
- package/dist/localization/package.nls.zh-tw.json +1 -1
- package/dist/pyright.js +3 -6
- package/dist/pyright.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +10 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/fourslash/{completions.importInterimFile.fourslash.js → completions.importInterimFile.fourslash.disabled.js} +2 -2
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +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/harness/fourslash/testState.d.ts +1 -1
- package/dist/tests/harness/fourslash/testState.js +1 -1
- 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/logger.test.js +0 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +30 -1
- 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 +1 -1
- package/dist/tests/typeEvaluator3.test.js +7 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +6 -2
- package/dist/tests/typeEvaluator4.test.js.map +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/completions.importInterimFile.fourslash.js.map +0 -1
- /package/dist/tests/fourslash/{completions.importInterimFile.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 */,
|
@@ -353,7 +351,7 @@ var ClassType;
|
|
353
351
|
(function (ClassType) {
|
354
352
|
function createInstantiable(name, fullName, moduleName, filePath, flags, typeSourceId, declaredMetaclass, effectiveMetaclass, docString) {
|
355
353
|
const newClass = {
|
356
|
-
category:
|
354
|
+
category: 6 /* Class */,
|
357
355
|
details: {
|
358
356
|
name,
|
359
357
|
fullName,
|
@@ -405,7 +403,7 @@ var ClassType;
|
|
405
403
|
ClassType.cloneAsInstantiable = cloneAsInstantiable;
|
406
404
|
function cloneForSpecialization(classType, typeArguments, isTypeArgumentExplicit, includeSubclasses = false, tupleTypeArguments, isEmptyContainer) {
|
407
405
|
const newClassType = TypeBase.cloneType(classType);
|
408
|
-
newClassType.typeArguments = typeArguments;
|
406
|
+
newClassType.typeArguments = (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 0 ? undefined : typeArguments;
|
409
407
|
newClassType.isTypeArgumentExplicit = isTypeArgumentExplicit;
|
410
408
|
if (includeSubclasses) {
|
411
409
|
newClassType.includeSubclasses = true;
|
@@ -910,7 +908,7 @@ var FunctionType;
|
|
910
908
|
FunctionType.createSynthesizedInstance = createSynthesizedInstance;
|
911
909
|
function create(name, fullName, moduleName, functionFlags, typeFlags, docString) {
|
912
910
|
const newFunctionType = {
|
913
|
-
category:
|
911
|
+
category: 4 /* Function */,
|
914
912
|
details: {
|
915
913
|
name,
|
916
914
|
fullName,
|
@@ -1329,6 +1327,9 @@ var FunctionType;
|
|
1329
1327
|
FunctionType.getEffectiveParameterDefaultArgType = getEffectiveParameterDefaultArgType;
|
1330
1328
|
function addParameter(type, param) {
|
1331
1329
|
type.details.parameters.push(param);
|
1330
|
+
if (type.specializedTypes) {
|
1331
|
+
type.specializedTypes.parameterTypes.push(param.type);
|
1332
|
+
}
|
1332
1333
|
}
|
1333
1334
|
FunctionType.addParameter = addParameter;
|
1334
1335
|
function getSpecializedReturnType(type) {
|
@@ -1342,7 +1343,7 @@ var OverloadedFunctionType;
|
|
1342
1343
|
(function (OverloadedFunctionType) {
|
1343
1344
|
function create(overloads) {
|
1344
1345
|
const newType = {
|
1345
|
-
category:
|
1346
|
+
category: 5 /* OverloadedFunction */,
|
1346
1347
|
overloads: [],
|
1347
1348
|
flags: 2 /* Instance */,
|
1348
1349
|
};
|
@@ -1367,34 +1368,15 @@ var OverloadedFunctionType;
|
|
1367
1368
|
}
|
1368
1369
|
OverloadedFunctionType.getImplementation = getImplementation;
|
1369
1370
|
})(OverloadedFunctionType = exports.OverloadedFunctionType || (exports.OverloadedFunctionType = {}));
|
1370
|
-
var NoneType;
|
1371
|
-
(function (NoneType) {
|
1372
|
-
const _noneInstance = {
|
1373
|
-
category: 3 /* None */,
|
1374
|
-
flags: 2 /* Instance */,
|
1375
|
-
};
|
1376
|
-
const _noneType = {
|
1377
|
-
category: 3 /* None */,
|
1378
|
-
flags: 1 /* Instantiable */,
|
1379
|
-
};
|
1380
|
-
function createInstance() {
|
1381
|
-
return _noneInstance;
|
1382
|
-
}
|
1383
|
-
NoneType.createInstance = createInstance;
|
1384
|
-
function createType() {
|
1385
|
-
return _noneType;
|
1386
|
-
}
|
1387
|
-
NoneType.createType = createType;
|
1388
|
-
})(NoneType = exports.NoneType || (exports.NoneType = {}));
|
1389
1371
|
var NeverType;
|
1390
1372
|
(function (NeverType) {
|
1391
1373
|
const _neverInstance = {
|
1392
|
-
category:
|
1374
|
+
category: 3 /* Never */,
|
1393
1375
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1394
1376
|
isNoReturn: false,
|
1395
1377
|
};
|
1396
1378
|
const _noReturnInstance = {
|
1397
|
-
category:
|
1379
|
+
category: 3 /* Never */,
|
1398
1380
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1399
1381
|
isNoReturn: true,
|
1400
1382
|
};
|
@@ -1519,7 +1501,7 @@ var UnionType;
|
|
1519
1501
|
(function (UnionType) {
|
1520
1502
|
function create() {
|
1521
1503
|
const newUnionType = {
|
1522
|
-
category:
|
1504
|
+
category: 8 /* Union */,
|
1523
1505
|
subtypes: [],
|
1524
1506
|
flags: 2 /* Instance */ | 1 /* Instantiable */,
|
1525
1507
|
};
|
@@ -1592,7 +1574,7 @@ var UnionType;
|
|
1592
1574
|
}
|
1593
1575
|
UnionType.containsType = containsType;
|
1594
1576
|
function addTypeAliasSource(unionType, typeAliasSource) {
|
1595
|
-
if (typeAliasSource.category ===
|
1577
|
+
if (typeAliasSource.category === 8 /* Union */) {
|
1596
1578
|
const sourcesToAdd = typeAliasSource.typeAliasInfo ? [typeAliasSource] : typeAliasSource.typeAliasSources;
|
1597
1579
|
if (sourcesToAdd) {
|
1598
1580
|
if (!unionType.typeAliasSources) {
|
@@ -1748,7 +1730,7 @@ var TypeVarType;
|
|
1748
1730
|
TypeVarType.makeNameWithScope = makeNameWithScope;
|
1749
1731
|
function create(name, isParamSpec, typeFlags, runtimeClass) {
|
1750
1732
|
const newTypeVarType = {
|
1751
|
-
category:
|
1733
|
+
category: 9 /* TypeVar */,
|
1752
1734
|
details: {
|
1753
1735
|
name,
|
1754
1736
|
constraints: [],
|
@@ -1799,17 +1781,9 @@ var TypeVarType;
|
|
1799
1781
|
TypeVarType.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
1800
1782
|
})(TypeVarType = exports.TypeVarType || (exports.TypeVarType = {}));
|
1801
1783
|
function isNever(type) {
|
1802
|
-
return type.category ===
|
1784
|
+
return type.category === 3 /* Never */;
|
1803
1785
|
}
|
1804
1786
|
exports.isNever = isNever;
|
1805
|
-
function isNoneInstance(type) {
|
1806
|
-
return type.category === 3 /* None */ && TypeBase.isInstance(type);
|
1807
|
-
}
|
1808
|
-
exports.isNoneInstance = isNoneInstance;
|
1809
|
-
function isNoneTypeClass(type) {
|
1810
|
-
return type.category === 3 /* None */ && TypeBase.isInstantiable(type);
|
1811
|
-
}
|
1812
|
-
exports.isNoneTypeClass = isNoneTypeClass;
|
1813
1787
|
function isAny(type) {
|
1814
1788
|
return type.category === 2 /* Any */;
|
1815
1789
|
}
|
@@ -1833,7 +1807,7 @@ function isUnbound(type) {
|
|
1833
1807
|
}
|
1834
1808
|
exports.isUnbound = isUnbound;
|
1835
1809
|
function isUnion(type) {
|
1836
|
-
return type.category ===
|
1810
|
+
return type.category === 8 /* Union */;
|
1837
1811
|
}
|
1838
1812
|
exports.isUnion = isUnion;
|
1839
1813
|
function isPossiblyUnbound(type) {
|
@@ -1847,31 +1821,31 @@ function isPossiblyUnbound(type) {
|
|
1847
1821
|
}
|
1848
1822
|
exports.isPossiblyUnbound = isPossiblyUnbound;
|
1849
1823
|
function isClass(type) {
|
1850
|
-
return type.category ===
|
1824
|
+
return type.category === 6 /* Class */;
|
1851
1825
|
}
|
1852
1826
|
exports.isClass = isClass;
|
1853
1827
|
function isInstantiableClass(type) {
|
1854
|
-
return type.category ===
|
1828
|
+
return type.category === 6 /* Class */ && TypeBase.isInstantiable(type);
|
1855
1829
|
}
|
1856
1830
|
exports.isInstantiableClass = isInstantiableClass;
|
1857
1831
|
function isClassInstance(type) {
|
1858
|
-
return type.category ===
|
1832
|
+
return type.category === 6 /* Class */ && TypeBase.isInstance(type);
|
1859
1833
|
}
|
1860
1834
|
exports.isClassInstance = isClassInstance;
|
1861
1835
|
function isModule(type) {
|
1862
|
-
return type.category ===
|
1836
|
+
return type.category === 7 /* Module */;
|
1863
1837
|
}
|
1864
1838
|
exports.isModule = isModule;
|
1865
1839
|
function isTypeVar(type) {
|
1866
|
-
return type.category ===
|
1840
|
+
return type.category === 9 /* TypeVar */;
|
1867
1841
|
}
|
1868
1842
|
exports.isTypeVar = isTypeVar;
|
1869
1843
|
function isVariadicTypeVar(type) {
|
1870
|
-
return type.category ===
|
1844
|
+
return type.category === 9 /* TypeVar */ && type.details.isVariadic;
|
1871
1845
|
}
|
1872
1846
|
exports.isVariadicTypeVar = isVariadicTypeVar;
|
1873
1847
|
function isUnpackedVariadicTypeVar(type) {
|
1874
|
-
return (type.category ===
|
1848
|
+
return (type.category === 9 /* TypeVar */ &&
|
1875
1849
|
type.details.isVariadic &&
|
1876
1850
|
!!type.isVariadicUnpacked &&
|
1877
1851
|
!type.isVariadicInUnion);
|
@@ -1889,15 +1863,15 @@ function isUnpacked(type) {
|
|
1889
1863
|
}
|
1890
1864
|
exports.isUnpacked = isUnpacked;
|
1891
1865
|
function isParamSpec(type) {
|
1892
|
-
return type.category ===
|
1866
|
+
return type.category === 9 /* TypeVar */ && type.details.isParamSpec;
|
1893
1867
|
}
|
1894
1868
|
exports.isParamSpec = isParamSpec;
|
1895
1869
|
function isFunction(type) {
|
1896
|
-
return type.category ===
|
1870
|
+
return type.category === 4 /* Function */;
|
1897
1871
|
}
|
1898
1872
|
exports.isFunction = isFunction;
|
1899
1873
|
function isOverloadedFunction(type) {
|
1900
|
-
return type.category ===
|
1874
|
+
return type.category === 5 /* OverloadedFunction */;
|
1901
1875
|
}
|
1902
1876
|
exports.isOverloadedFunction = isOverloadedFunction;
|
1903
1877
|
function getTypeAliasInfo(type) {
|
@@ -1954,7 +1928,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
1954
1928
|
}
|
1955
1929
|
recursionCount++;
|
1956
1930
|
switch (type1.category) {
|
1957
|
-
case
|
1931
|
+
case 6 /* Class */: {
|
1958
1932
|
const classType2 = type2;
|
1959
1933
|
// If the details are not the same it's not the same class.
|
1960
1934
|
if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
|
@@ -2005,7 +1979,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2005
1979
|
}
|
2006
1980
|
return true;
|
2007
1981
|
}
|
2008
|
-
case
|
1982
|
+
case 4 /* Function */: {
|
2009
1983
|
// Make sure the parameter counts match.
|
2010
1984
|
const functionType2 = type2;
|
2011
1985
|
const params1 = type1.details.parameters;
|
@@ -2076,7 +2050,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2076
2050
|
}
|
2077
2051
|
return true;
|
2078
2052
|
}
|
2079
|
-
case
|
2053
|
+
case 5 /* OverloadedFunction */: {
|
2080
2054
|
// Make sure the overload counts match.
|
2081
2055
|
const functionType2 = type2;
|
2082
2056
|
if (type1.overloads.length !== functionType2.overloads.length) {
|
@@ -2091,7 +2065,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2091
2065
|
}
|
2092
2066
|
return true;
|
2093
2067
|
}
|
2094
|
-
case
|
2068
|
+
case 8 /* Union */: {
|
2095
2069
|
const unionType2 = type2;
|
2096
2070
|
const subtypes1 = type1.subtypes;
|
2097
2071
|
const subtypes2 = unionType2.subtypes;
|
@@ -2103,7 +2077,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2103
2077
|
const exclusionSet = new Set();
|
2104
2078
|
return (findSubtype(type1, (subtype) => !UnionType.containsType(unionType2, subtype, exclusionSet, recursionCount)) === undefined);
|
2105
2079
|
}
|
2106
|
-
case
|
2080
|
+
case 9 /* TypeVar */: {
|
2107
2081
|
const type2TypeVar = type2;
|
2108
2082
|
if (type1.scopeId !== type2TypeVar.scopeId) {
|
2109
2083
|
return false;
|
@@ -2162,7 +2136,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2162
2136
|
}
|
2163
2137
|
return true;
|
2164
2138
|
}
|
2165
|
-
case
|
2139
|
+
case 7 /* Module */: {
|
2166
2140
|
const type2Module = type2;
|
2167
2141
|
// Module types are the same if they share the same
|
2168
2142
|
// module symbol table.
|
@@ -2202,12 +2176,6 @@ function removeUnbound(type) {
|
|
2202
2176
|
return type;
|
2203
2177
|
}
|
2204
2178
|
exports.removeUnbound = removeUnbound;
|
2205
|
-
// If the type is a union, remove an "None" type from the union,
|
2206
|
-
// returning only the known types.
|
2207
|
-
function removeNoneFromUnion(type) {
|
2208
|
-
return removeFromUnion(type, (t) => isNoneInstance(t));
|
2209
|
-
}
|
2210
|
-
exports.removeNoneFromUnion = removeNoneFromUnion;
|
2211
2179
|
function removeFromUnion(type, removeFilter) {
|
2212
2180
|
if (isUnion(type)) {
|
2213
2181
|
const remainingTypes = type.subtypes.filter((t) => !removeFilter(t));
|
@@ -2238,12 +2206,12 @@ exports.findSubtype = findSubtype;
|
|
2238
2206
|
function combineTypes(subtypes, maxSubtypeCount) {
|
2239
2207
|
// Filter out any "Never" and "NoReturn" types.
|
2240
2208
|
let sawNoReturn = false;
|
2241
|
-
if (subtypes.some((subtype) => subtype.category ===
|
2209
|
+
if (subtypes.some((subtype) => subtype.category === 3 /* Never */))
|
2242
2210
|
subtypes = subtypes.filter((subtype) => {
|
2243
|
-
if (subtype.category ===
|
2211
|
+
if (subtype.category === 3 /* Never */ && subtype.isNoReturn) {
|
2244
2212
|
sawNoReturn = true;
|
2245
2213
|
}
|
2246
|
-
return subtype.category !==
|
2214
|
+
return subtype.category !== 3 /* Never */;
|
2247
2215
|
});
|
2248
2216
|
if (subtypes.length === 0) {
|
2249
2217
|
return sawNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
|