@zzzen/pyright-internal 1.2.0-dev.20240310 → 1.2.0-dev.20240317
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/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +38 -45
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/operations.js +8 -8
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +1 -1
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +16 -12
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/service.js +1 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +188 -73
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +6 -1
- package/dist/analyzer/typeGuards.js +8 -11
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -1
- package/dist/analyzer/typeUtils.js +13 -14
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +2 -1
- package/dist/analyzer/types.js +1 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +4 -1
- package/dist/backgroundThreadBase.js +14 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +0 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +5 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/logTracker.d.ts +5 -5
- package/dist/common/logTracker.js +7 -6
- package/dist/common/logTracker.js.map +1 -1
- package/dist/localization/localize.d.ts +4 -0
- package/dist/localization/localize.js +1 -8
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +13 -5
- package/dist/localization/package.nls.de.json +13 -5
- package/dist/localization/package.nls.en-us.json +1 -0
- package/dist/localization/package.nls.es.json +13 -5
- package/dist/localization/package.nls.fr.json +15 -7
- package/dist/localization/package.nls.it.json +11 -3
- package/dist/localization/package.nls.ja.json +13 -5
- package/dist/localization/package.nls.ko.json +13 -5
- package/dist/localization/package.nls.pl.json +13 -5
- package/dist/localization/package.nls.pt-br.json +13 -5
- package/dist/localization/package.nls.qps-ploc.json +13 -5
- package/dist/localization/package.nls.ru.json +12 -4
- package/dist/localization/package.nls.tr.json +13 -5
- package/dist/localization/package.nls.zh-cn.json +13 -5
- package/dist/localization/package.nls.zh-tw.json +13 -5
- package/dist/parser/parser.js +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +12 -12
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.d.ts +0 -1
- package/dist/parser/tokenizer.js +41 -41
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.d.ts +1 -2
- package/dist/parser/tokenizerTypes.js +0 -1
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +2 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +2 -2
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +9 -7
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/package.json +1 -1
@@ -93,6 +93,7 @@ export declare class Checker extends ParseTreeWalker {
|
|
93
93
|
private _isLegalOverloadImplementation;
|
94
94
|
private _walkStatementsAndReportUnreachable;
|
95
95
|
private _validateStubStatement;
|
96
|
+
private _validateExceptionTypeRecursive;
|
96
97
|
private _validateExceptionType;
|
97
98
|
private _reportUnusedDunderAllSymbols;
|
98
99
|
private _validateSymbolTables;
|
package/dist/analyzer/checker.js
CHANGED
@@ -1121,7 +1121,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1121
1121
|
}
|
1122
1122
|
let isTypeBool = true;
|
1123
1123
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
1124
|
-
this._evaluator.mapSubtypesExpandTypeVars(operandType, /*
|
1124
|
+
this._evaluator.mapSubtypesExpandTypeVars(operandType, /* options */ undefined, (expandedSubtype) => {
|
1125
1125
|
if ((0, types_1.isAnyOrUnknown)(expandedSubtype)) {
|
1126
1126
|
return undefined;
|
1127
1127
|
}
|
@@ -1556,7 +1556,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1556
1556
|
// other types, and ParamSpecs. There are legitimate uses for singleton
|
1557
1557
|
// instances in these particular cases.
|
1558
1558
|
let isExempt = nameType.details.constraints.length > 0 ||
|
1559
|
-
|
1559
|
+
nameType.details.isDefaultExplicit ||
|
1560
1560
|
(exemptBoundTypeVar && subscriptIndex !== undefined) ||
|
1561
1561
|
(0, types_1.isParamSpec)(nameType);
|
1562
1562
|
if (!isExempt && baseExpression && subscriptIndex !== undefined) {
|
@@ -1604,7 +1604,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1604
1604
|
if (constructorClass && nameType.scopeId === constructorClass.details.typeVarScopeId) {
|
1605
1605
|
const existingEntry = classTypeVarUsage.get(nameType.details.name);
|
1606
1606
|
const isParamTypeWithEllipsisUsage = ((_d = curParamNode === null || curParamNode === void 0 ? void 0 : curParamNode.defaultValue) === null || _d === void 0 ? void 0 : _d.nodeType) === 18 /* ParseNodeType.Ellipsis */;
|
1607
|
-
const isExempt = !!nameType.details.
|
1607
|
+
const isExempt = !!nameType.details.isDefaultExplicit;
|
1608
1608
|
if (!existingEntry) {
|
1609
1609
|
classTypeVarUsage.set(nameType.details.name, {
|
1610
1610
|
typeVar: nameType,
|
@@ -1935,57 +1935,48 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1935
1935
|
}
|
1936
1936
|
}
|
1937
1937
|
}
|
1938
|
-
|
1939
|
-
var _a, _b;
|
1940
|
-
const baseExceptionType = this._evaluator.getBuiltInType(errorNode, 'BaseException');
|
1938
|
+
_validateExceptionTypeRecursive(exceptionType, diag, baseExceptionType, allowTuple) {
|
1941
1939
|
const derivesFromBaseException = (classType) => {
|
1942
1940
|
if (!baseExceptionType || !(0, types_1.isInstantiableClass)(baseExceptionType)) {
|
1943
1941
|
return true;
|
1944
1942
|
}
|
1945
1943
|
return (0, typeUtils_1.derivesFromClassRecursive)(classType, baseExceptionType, /* ignoreUnknown */ false);
|
1946
1944
|
};
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
resultingExceptionType = exceptionType;
|
1951
|
-
}
|
1952
|
-
else {
|
1953
|
-
if ((0, types_1.isInstantiableClass)(exceptionType)) {
|
1954
|
-
if (!derivesFromBaseException(exceptionType)) {
|
1955
|
-
diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
|
1956
|
-
type: this._evaluator.printType(exceptionType),
|
1957
|
-
}));
|
1958
|
-
}
|
1959
|
-
resultingExceptionType = types_1.ClassType.cloneAsInstance(exceptionType);
|
1945
|
+
(0, typeUtils_1.doForEachSubtype)(exceptionType, (exceptionSubtype) => {
|
1946
|
+
if ((0, types_1.isAnyOrUnknown)(exceptionSubtype)) {
|
1947
|
+
return;
|
1960
1948
|
}
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
}
|
1968
|
-
if ((0, types_1.isInstantiableClass)(subtype)) {
|
1969
|
-
if (!derivesFromBaseException(subtype)) {
|
1970
|
-
diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
|
1971
|
-
type: this._evaluator.printType(exceptionType),
|
1972
|
-
}));
|
1973
|
-
}
|
1974
|
-
return types_1.ClassType.cloneAsInstance(subtype);
|
1949
|
+
if ((0, types_1.isClass)(exceptionSubtype)) {
|
1950
|
+
if (types_1.TypeBase.isInstantiable(exceptionSubtype)) {
|
1951
|
+
if (!derivesFromBaseException(exceptionSubtype)) {
|
1952
|
+
diag.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
|
1953
|
+
type: this._evaluator.printType(exceptionSubtype),
|
1954
|
+
}));
|
1975
1955
|
}
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1956
|
+
return;
|
1957
|
+
}
|
1958
|
+
if (allowTuple && exceptionSubtype.tupleTypeArguments) {
|
1959
|
+
exceptionSubtype.tupleTypeArguments.forEach((typeArg) => {
|
1960
|
+
this._validateExceptionTypeRecursive(typeArg.type, diag, baseExceptionType,
|
1961
|
+
/* allowTuple */ false);
|
1962
|
+
});
|
1963
|
+
return;
|
1964
|
+
}
|
1965
|
+
diag.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
|
1966
|
+
type: this._evaluator.printType(exceptionSubtype),
|
1967
|
+
}));
|
1981
1968
|
}
|
1982
|
-
}
|
1969
|
+
});
|
1970
|
+
}
|
1971
|
+
_validateExceptionType(exceptionType, errorNode) {
|
1972
|
+
const baseExceptionType = this._evaluator.getBuiltInType(errorNode, 'BaseException');
|
1973
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
1974
|
+
this._validateExceptionTypeRecursive(exceptionType, diagAddendum, baseExceptionType, /* allowTuple */ true);
|
1983
1975
|
if (!diagAddendum.isEmpty()) {
|
1984
1976
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.exceptionTypeNotClass().format({
|
1985
1977
|
type: this._evaluator.printType(exceptionType),
|
1986
1978
|
}), errorNode);
|
1987
1979
|
}
|
1988
|
-
return resultingExceptionType || types_1.UnknownType.create();
|
1989
1980
|
}
|
1990
1981
|
_reportUnusedDunderAllSymbols(nodes) {
|
1991
1982
|
// If this rule is disabled, don't bother doing the work.
|
@@ -4347,9 +4338,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4347
4338
|
return;
|
4348
4339
|
}
|
4349
4340
|
// If the symbol has no declaration, and the type is inferred,
|
4350
|
-
// skip
|
4351
|
-
|
4352
|
-
|
4341
|
+
// skip the type validation but still check for other issues like
|
4342
|
+
// Final overrides and class/instance variable mismatches.
|
4343
|
+
let validateType = true;
|
4344
|
+
if (!symbol.hasTypedDeclarations()) {
|
4345
|
+
validateType = false;
|
4353
4346
|
}
|
4354
4347
|
// Get the symbol type defined in this class.
|
4355
4348
|
const typeOfSymbol = this._evaluator.getEffectiveTypeOfSymbol(symbol);
|
@@ -4374,7 +4367,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4374
4367
|
continue;
|
4375
4368
|
}
|
4376
4369
|
firstOverride = firstOverride !== null && firstOverride !== void 0 ? firstOverride : baseClassAndSymbol;
|
4377
|
-
this._validateBaseClassOverride(baseClassAndSymbol, symbol, typeOfSymbol, classType, name);
|
4370
|
+
this._validateBaseClassOverride(baseClassAndSymbol, symbol, validateType ? typeOfSymbol : types_1.AnyType.create(), classType, name);
|
4378
4371
|
}
|
4379
4372
|
if (!firstOverride) {
|
4380
4373
|
// If this is a method decorated with @override, validate that there
|
@@ -4557,7 +4550,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4557
4550
|
// Handle properties specially.
|
4558
4551
|
if (!(0, typeUtils_1.isProperty)(overrideType)) {
|
4559
4552
|
const decls = overrideSymbol.getDeclarations();
|
4560
|
-
if (decls.length > 0) {
|
4553
|
+
if (decls.length > 0 && overrideSymbol.isClassMember()) {
|
4561
4554
|
const lastDecl = decls[decls.length - 1];
|
4562
4555
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4563
4556
|
name: memberName,
|