@zzzen/pyright-internal 1.2.0-dev.20240428 → 1.2.0-dev.20240505
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.js +42 -29
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/operations.js +3 -2
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/patternMatching.js +19 -13
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/scope.js +3 -1
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +27 -14
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeUtils.js +1 -5
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.js +3 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/envVarUtils.js +1 -2
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -2
- package/dist/languageServerBase.js +13 -35
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +1 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/dynamicFeature.d.ts +18 -0
- package/dist/languageService/dynamicFeature.js +54 -0
- package/dist/languageService/dynamicFeature.js.map +1 -0
- package/dist/languageService/fileWatcherDynamicFeature.d.ts +12 -0
- package/dist/languageService/fileWatcherDynamicFeature.js +49 -0
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -0
- package/dist/localization/package.nls.cs.json +28 -26
- package/dist/localization/package.nls.de.json +28 -26
- package/dist/localization/package.nls.en-us.json +1 -1
- package/dist/localization/package.nls.es.json +27 -25
- package/dist/localization/package.nls.fr.json +28 -26
- package/dist/localization/package.nls.it.json +28 -26
- package/dist/localization/package.nls.ja.json +28 -26
- package/dist/localization/package.nls.ko.json +28 -26
- package/dist/localization/package.nls.pl.json +27 -25
- package/dist/localization/package.nls.pt-br.json +28 -26
- package/dist/localization/package.nls.qps-ploc.json +25 -23
- package/dist/localization/package.nls.ru.json +28 -26
- package/dist/localization/package.nls.tr.json +28 -26
- package/dist/localization/package.nls.zh-cn.json +28 -26
- package/dist/localization/package.nls.zh-tw.json +28 -26
- package/dist/parser/tokenizer.js +7 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +20 -0
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +7 -2
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +59 -479
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +0 -486
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +0 -604
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -423
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.d.ts +1 -0
- package/dist/tests/typeEvaluator6.test.js +712 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -0
- package/dist/tests/typeEvaluator7.test.d.ts +1 -0
- package/dist/tests/typeEvaluator7.test.js +677 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -0
- package/dist/tests/typeEvaluator8.test.d.ts +1 -0
- package/dist/tests/typeEvaluator8.test.js +660 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -0
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
@@ -767,31 +767,37 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
767
767
|
if (baseType) {
|
768
768
|
(0, typeUtils_1.doForEachSubtype)(baseType, (subtype) => {
|
769
769
|
const tupleType = (0, typeUtils_1.getSpecializedTupleType)(subtype);
|
770
|
-
if ((0, types_1.isClassInstance)(subtype)
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
const subscriptType = this._evaluator.getType(node.items[0].valueExpression);
|
780
|
-
if (subscriptType &&
|
781
|
-
(0, types_1.isClassInstance)(subscriptType) &&
|
782
|
-
types_1.ClassType.isBuiltIn(subscriptType, 'int') &&
|
783
|
-
(0, typeUtils_1.isLiteralType)(subscriptType) &&
|
784
|
-
typeof subscriptType.literalValue === 'number') {
|
785
|
-
if ((subscriptType.literalValue >= 0 && subscriptType.literalValue >= tupleLength) ||
|
786
|
-
(subscriptType.literalValue < 0 && subscriptType.literalValue + tupleLength < 0)) {
|
787
|
-
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.tupleIndexOutOfRange().format({
|
788
|
-
index: subscriptType.literalValue,
|
789
|
-
type: this._evaluator.printType(subtype),
|
790
|
-
}), node);
|
791
|
-
}
|
792
|
-
}
|
793
|
-
}
|
770
|
+
if (!(0, types_1.isClassInstance)(subtype) || !(tupleType === null || tupleType === void 0 ? void 0 : tupleType.tupleTypeArguments) || (0, typeUtils_1.isUnboundedTupleClass)(tupleType)) {
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
const tupleLength = tupleType.tupleTypeArguments.length;
|
774
|
+
if (node.items.length !== 1 ||
|
775
|
+
node.trailingComma ||
|
776
|
+
node.items[0].argumentCategory !== 0 /* ArgumentCategory.Simple */ ||
|
777
|
+
node.items[0].name) {
|
778
|
+
return;
|
794
779
|
}
|
780
|
+
const subscriptType = this._evaluator.getType(node.items[0].valueExpression);
|
781
|
+
if (!subscriptType ||
|
782
|
+
!(0, types_1.isClassInstance)(subscriptType) ||
|
783
|
+
!types_1.ClassType.isBuiltIn(subscriptType, 'int') ||
|
784
|
+
!(0, typeUtils_1.isLiteralType)(subscriptType) ||
|
785
|
+
typeof subscriptType.literalValue !== 'number') {
|
786
|
+
return;
|
787
|
+
}
|
788
|
+
if ((subscriptType.literalValue < 0 || subscriptType.literalValue < tupleLength) &&
|
789
|
+
(subscriptType.literalValue >= 0 || subscriptType.literalValue + tupleLength >= 0)) {
|
790
|
+
return;
|
791
|
+
}
|
792
|
+
// This can be an expensive check, so we save it for the end once we
|
793
|
+
// are about to emit a diagnostic.
|
794
|
+
if (this._evaluator.isTypeSubsumedByOtherType(tupleType, baseType, /* allowAnyToSubsume */ false)) {
|
795
|
+
return;
|
796
|
+
}
|
797
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.tupleIndexOutOfRange().format({
|
798
|
+
index: subscriptType.literalValue,
|
799
|
+
type: this._evaluator.printType(subtype),
|
800
|
+
}), node);
|
795
801
|
});
|
796
802
|
}
|
797
803
|
return true;
|
@@ -2153,11 +2159,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2153
2159
|
if (decl.type === 1 /* DeclarationType.Variable */) {
|
2154
2160
|
if (decl.inferredTypeSource) {
|
2155
2161
|
if (sawAssignment) {
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2162
|
+
let exemptAssignment = false;
|
2163
|
+
if (scopeType === 3 /* ScopeType.Class */) {
|
2164
|
+
// We check for assignment of Final instance and class variables
|
2165
|
+
// in the type evaluator because we need to take into account whether
|
2166
|
+
// the assignment is within an `__init__` method, so ignore class
|
2167
|
+
// scopes here.
|
2168
|
+
const classOrFunc = ParseTreeUtils.getEnclosingClassOrFunction(decl.node);
|
2169
|
+
if ((classOrFunc === null || classOrFunc === void 0 ? void 0 : classOrFunc.nodeType) === 28 /* ParseNodeType.Function */) {
|
2170
|
+
exemptAssignment = true;
|
2171
|
+
}
|
2172
|
+
}
|
2173
|
+
if (!exemptAssignment) {
|
2161
2174
|
reportRedeclaration = true;
|
2162
2175
|
}
|
2163
2176
|
}
|