@zzzen/pyright-internal 1.2.0-dev.20250406 → 1.2.0-dev.20250420
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 +0 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/binder.js +13 -20
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +13 -7
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +1 -1
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constructors.js +2 -2
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +11 -6
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/enums.js +1 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +0 -1
- package/dist/analyzer/importResolver.js +2 -25
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +0 -1
- package/dist/analyzer/namedTuples.js +10 -0
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +1 -1
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/parseTreeUtils.js +18 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/program.js +10 -18
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/programTypes.d.ts +2 -2
- package/dist/analyzer/programTypes.js.map +1 -1
- package/dist/analyzer/protocols.js +2 -2
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +1 -2
- package/dist/analyzer/sourceFile.js +2 -3
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +97 -58
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeGuards.js +91 -52
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +6 -5
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +4 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/extensibility.d.ts +1 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +2 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/languageService/completionProvider.js +1 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +1 -1
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/hoverProvider.js +1 -1
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +2 -2
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +5 -0
- package/dist/localization/localize.js +5 -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 +21 -1
- 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/parser/parser.d.ts +4 -0
- package/dist/parser/parser.js +33 -0
- package/dist/parser/parser.js.map +1 -1
- package/dist/tests/checker.test.js +1 -1
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js +0 -18
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -1
- package/dist/tests/parser.test.js +17 -0
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +4 -5
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/testUtils.js +1 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +2 -2
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +10 -2
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/package.json +1 -1
package/dist/parser/parser.js
CHANGED
@@ -81,6 +81,8 @@ class Parser {
|
|
81
81
|
this._isParsingTypeAnnotation = false;
|
82
82
|
this._isParsingIndexTrailer = false;
|
83
83
|
this._isParsingQuotedText = false;
|
84
|
+
this._isInFinallyBlock = false;
|
85
|
+
this._isInFinallyLoop = false;
|
84
86
|
this._futureImports = new Set();
|
85
87
|
this._importedModules = [];
|
86
88
|
this._containsWildcardImport = false;
|
@@ -88,8 +90,10 @@ class Parser {
|
|
88
90
|
this._typingImportAliases = [];
|
89
91
|
this._typingSymbolAliases = new Map();
|
90
92
|
this._maxChildDepthMap = new Map();
|
93
|
+
this._hasTypeAnnotations = false;
|
91
94
|
}
|
92
95
|
parseSourceFile(fileContents, parseOptions, diagSink) {
|
96
|
+
this._hasTypeAnnotations = false;
|
93
97
|
timing_1.timingStats.tokenizeFileTime.timeOperation(() => {
|
94
98
|
this._startNewParse(fileContents, 0, fileContents.length, parseOptions, diagSink);
|
95
99
|
});
|
@@ -130,6 +134,7 @@ class Parser {
|
|
130
134
|
futureImports: this._futureImports,
|
131
135
|
containsWildcardImport: this._containsWildcardImport,
|
132
136
|
typingSymbolAliases: this._typingSymbolAliases,
|
137
|
+
hasTypeAnnotations: this._hasTypeAnnotations,
|
133
138
|
},
|
134
139
|
tokenizerOutput: this._tokenizerOutput,
|
135
140
|
};
|
@@ -1057,6 +1062,11 @@ class Parser {
|
|
1057
1062
|
_parseLoopSuite() {
|
1058
1063
|
const wasInLoop = this._isInLoop;
|
1059
1064
|
this._isInLoop = true;
|
1065
|
+
// Record the fact that we are no longer in a finally block
|
1066
|
+
// that is contained within a loop. A loop within the finally
|
1067
|
+
// block resets this. See PEP 765 for details.
|
1068
|
+
const wasInFinallyLoop = this._isInFinallyLoop;
|
1069
|
+
this._isInFinallyLoop = false;
|
1060
1070
|
let typeComment;
|
1061
1071
|
const suite = this._parseSuite(this._isInFunction, /* skipBody */ false, () => {
|
1062
1072
|
const comment = this._getTypeAnnotationCommentText();
|
@@ -1065,6 +1075,7 @@ class Parser {
|
|
1065
1075
|
}
|
1066
1076
|
});
|
1067
1077
|
this._isInLoop = wasInLoop;
|
1078
|
+
this._isInFinallyLoop = wasInFinallyLoop;
|
1068
1079
|
if (typeComment) {
|
1069
1080
|
suite.d.typeComment = typeComment;
|
1070
1081
|
}
|
@@ -1442,7 +1453,13 @@ class Parser {
|
|
1442
1453
|
}
|
1443
1454
|
}
|
1444
1455
|
if (this._consumeTokenIfKeyword(16 /* KeywordType.Finally */)) {
|
1456
|
+
const wasInFinallyBlock = this._isInFinallyBlock;
|
1457
|
+
const wasInFinallyLoop = this._isInFinallyLoop;
|
1458
|
+
this._isInFinallyBlock = true;
|
1459
|
+
this._isInFinallyLoop = this._isInLoop;
|
1445
1460
|
tryNode.d.finallySuite = this._parseSuite(this._isInFunction);
|
1461
|
+
this._isInFinallyBlock = wasInFinallyBlock;
|
1462
|
+
this._isInFinallyLoop = wasInFinallyLoop;
|
1446
1463
|
tryNode.d.finallySuite.parent = tryNode;
|
1447
1464
|
(0, parseNodes_1.extendRange)(tryNode, tryNode.d.finallySuite);
|
1448
1465
|
}
|
@@ -1486,12 +1503,18 @@ class Parser {
|
|
1486
1503
|
let functionTypeAnnotationToken;
|
1487
1504
|
const wasInExceptionGroup = this._isInExceptionGroup;
|
1488
1505
|
this._isInExceptionGroup = false;
|
1506
|
+
const wasInFinallyBlock = this._isInFinallyBlock;
|
1507
|
+
const wasInFinallyLoop = this._isInFinallyLoop;
|
1508
|
+
this._isInFinallyBlock = false;
|
1509
|
+
this._isInFinallyLoop = false;
|
1489
1510
|
const suite = this._parseSuite(/* isFunction */ true, this._parseOptions.skipFunctionAndClassBody, () => {
|
1490
1511
|
if (!functionTypeAnnotationToken) {
|
1491
1512
|
functionTypeAnnotationToken = this._getTypeAnnotationCommentText();
|
1492
1513
|
}
|
1493
1514
|
});
|
1494
1515
|
this._isInExceptionGroup = wasInExceptionGroup;
|
1516
|
+
this._isInFinallyBlock = wasInFinallyBlock;
|
1517
|
+
this._isInFinallyLoop = wasInFinallyLoop;
|
1495
1518
|
const functionNode = parseNodes_1.FunctionNode.create(defToken, parseNodes_1.NameNode.create(nameToken), suite, typeParameters);
|
1496
1519
|
if (asyncToken) {
|
1497
1520
|
functionNode.d.isAsync = true;
|
@@ -1926,6 +1949,9 @@ class Parser {
|
|
1926
1949
|
else if (this._isInExceptionGroup) {
|
1927
1950
|
this._addSyntaxError(localize_1.LocMessage.breakInExceptionGroup(), breakToken);
|
1928
1951
|
}
|
1952
|
+
if (this._isInFinallyLoop && pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_14)) {
|
1953
|
+
this._addSyntaxError(localize_1.LocMessage.finallyBreak(), breakToken);
|
1954
|
+
}
|
1929
1955
|
return parseNodes_1.BreakNode.create(breakToken);
|
1930
1956
|
}
|
1931
1957
|
_parseContinueStatement() {
|
@@ -1936,6 +1962,9 @@ class Parser {
|
|
1936
1962
|
else if (this._isInExceptionGroup) {
|
1937
1963
|
this._addSyntaxError(localize_1.LocMessage.continueInExceptionGroup(), continueToken);
|
1938
1964
|
}
|
1965
|
+
if (this._isInFinallyLoop && pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_14)) {
|
1966
|
+
this._addSyntaxError(localize_1.LocMessage.finallyContinue(), continueToken);
|
1967
|
+
}
|
1939
1968
|
return parseNodes_1.ContinueNode.create(continueToken);
|
1940
1969
|
}
|
1941
1970
|
// return_stmt: 'return' [testlist]
|
@@ -1948,6 +1977,9 @@ class Parser {
|
|
1948
1977
|
else if (this._isInExceptionGroup) {
|
1949
1978
|
this._addSyntaxError(localize_1.LocMessage.returnInExceptionGroup(), returnToken);
|
1950
1979
|
}
|
1980
|
+
if (this._isInFinallyBlock && pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_14)) {
|
1981
|
+
this._addSyntaxError(localize_1.LocMessage.finallyReturn(), returnToken);
|
1982
|
+
}
|
1951
1983
|
if (!this._isNextTokenNeverExpression()) {
|
1952
1984
|
const returnExpr = this._parseTestOrStarListAsExpression(
|
1953
1985
|
/* allowAssignmentExpression */ true,
|
@@ -3634,6 +3666,7 @@ class Parser {
|
|
3634
3666
|
result = parseNodes_1.UnpackNode.create(startToken, result);
|
3635
3667
|
}
|
3636
3668
|
this._isParsingTypeAnnotation = wasParsingTypeAnnotation;
|
3669
|
+
this._hasTypeAnnotations = true;
|
3637
3670
|
return result;
|
3638
3671
|
}
|
3639
3672
|
_reportStringTokenErrors(stringToken, unescapedResult) {
|