@zzzen/pyright-internal 1.2.0-dev.20240317 → 1.2.0-dev.20240331
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.js +1 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/binder.js +4 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.d.ts +1 -0
- package/dist/analyzer/cacheManager.js +4 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -2
- package/dist/analyzer/checker.js +16 -11
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +3 -2
- package/dist/analyzer/constructors.js +76 -54
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +2 -0
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js +1 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/deprecatedSymbols.js +40 -40
- package/dist/analyzer/deprecatedSymbols.js.map +1 -1
- package/dist/analyzer/enums.js +1 -0
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.js +25 -23
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/namedTuples.js +2 -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/packageTypeVerifier.js +1 -1
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/patternMatching.js +14 -3
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -7
- package/dist/analyzer/program.js +15 -19
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/programTypes.d.ts +11 -0
- package/dist/analyzer/programTypes.js +11 -0
- package/dist/analyzer/programTypes.js.map +1 -0
- package/dist/analyzer/properties.js +2 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +1 -2
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +2 -2
- package/dist/analyzer/service.js +20 -14
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +4 -4
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +3 -3
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +52 -30
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +2 -2
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +81 -56
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeGuards.js +14 -7
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +2 -2
- package/dist/analyzer/typeUtils.js +41 -5
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +3 -0
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/backgroundAnalysis.js +1 -1
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +1 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +23 -11
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.d.ts +2 -1
- package/dist/commands/commandController.js +3 -0
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/createTypeStub.d.ts +1 -1
- package/dist/commands/createTypeStub.js +3 -3
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.d.ts +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.d.ts +1 -1
- package/dist/commands/quickActionCommand.js +2 -2
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/commands/restartServer.d.ts +1 -1
- package/dist/common/cancellationUtils.js +2 -2
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/caseSensitivityDetector.d.ts +6 -0
- package/dist/common/caseSensitivityDetector.js +18 -0
- package/dist/common/caseSensitivityDetector.js.map +1 -0
- package/dist/common/commandLineOptions.d.ts +3 -2
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/commandUtils.js +1 -1
- package/dist/common/commandUtils.js.map +1 -1
- package/dist/common/configOptions.js +7 -7
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +1 -0
- package/dist/common/envVarUtils.js +42 -7
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +1 -1
- package/dist/common/fileBasedCancellationUtils.js +2 -2
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.js +11 -6
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +62 -0
- package/dist/common/languageServerInterface.js +10 -0
- package/dist/common/languageServerInterface.js.map +1 -0
- package/dist/common/pythonVersion.d.ts +36 -20
- package/dist/common/pythonVersion.js +160 -54
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +8 -4
- package/dist/common/realFileSystem.js +56 -17
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceKeys.d.ts +21 -0
- package/dist/common/serviceKeys.js +26 -0
- package/dist/common/serviceKeys.js.map +1 -0
- package/dist/common/serviceProviderExtensions.d.ts +2 -16
- package/dist/common/serviceProviderExtensions.js +19 -27
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/textEditTracker.js +2 -2
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/uri/constantUri.d.ts +36 -0
- package/dist/common/uri/constantUri.js +112 -0
- package/dist/common/uri/constantUri.js.map +1 -0
- package/dist/common/uri/emptyUri.d.ts +3 -31
- package/dist/common/uri/emptyUri.js +3 -84
- package/dist/common/uri/emptyUri.js.map +1 -1
- package/dist/common/uri/fileUri.d.ts +1 -0
- package/dist/common/uri/fileUri.js +3 -2
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/uri.d.ts +11 -3
- package/dist/common/uri/uri.js +31 -20
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +11 -5
- package/dist/common/uri/uriUtils.js +31 -53
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +4 -4
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +9 -57
- package/dist/languageServerBase.js +18 -8
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +4 -5
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +6 -6
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +43 -42
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +4 -4
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.js +2 -2
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +2 -2
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.d.ts +3 -2
- package/dist/languageService/documentSymbolProvider.js +3 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +2 -2
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +2 -2
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +4 -1
- package/dist/languageService/symbolIndexer.js +21 -11
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +1 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.js +21 -16
- 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.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.js +24 -21
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/unicode.js +3456 -2853
- package/dist/parser/unicode.js.map +1 -1
- package/dist/pyright.js +7 -7
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +3 -1
- package/dist/pyrightFileSystem.js +14 -9
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +0 -1
- package/dist/readonlyAugmentedFileSystem.js +0 -3
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +14 -10
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +12 -12
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +11 -11
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/completions.test.js +4 -4
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +26 -21
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js +2 -3
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +77 -2
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +13 -13
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +12 -12
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +12 -10
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.d.ts +1 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +3 -2
- 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 +3 -3
- package/dist/tests/harness/fourslash/testState.js +36 -32
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testHost.d.ts +7 -0
- package/dist/tests/harness/testHost.js +33 -14
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/vfs/factory.d.ts +3 -4
- package/dist/tests/harness/vfs/factory.js +7 -6
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +5 -3
- package/dist/tests/harness/vfs/filesystem.js +22 -15
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +35 -34
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +5 -6
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/languageServer.test.js +1 -1
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/logger.test.js +1 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/lsp/customLsp.d.ts +1 -1
- package/dist/tests/lsp/languageServer.js +7 -5
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +21 -16
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +1 -2
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +6 -5
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/serialization.test.js +5 -5
- package/dist/tests/serialization.test.js.map +1 -1
- package/dist/tests/service.test.js +16 -25
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +8 -5
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +4 -4
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +5 -5
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +6 -6
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.js +6 -4
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +16 -12
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +2 -2
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +57 -57
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +21 -21
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +27 -27
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/uri.test.js +220 -199
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +7 -7
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +7 -5
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +15 -6
- package/dist/workspaceFactory.js +16 -10
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +5 -5
package/dist/parser/parser.js
CHANGED
@@ -263,7 +263,7 @@ class Parser {
|
|
263
263
|
// type_alias_stmt: "type" name [type_param_seq] = expr
|
264
264
|
_parseTypeAliasStatement() {
|
265
265
|
const typeToken = this._getKeywordToken(35 /* KeywordType.Type */);
|
266
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
266
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
|
267
267
|
this._addSyntaxError(localize_1.LocMessage.typeAliasStatementIllegal(), typeToken);
|
268
268
|
}
|
269
269
|
const nameToken = this._getTokenIfIdentifier();
|
@@ -281,7 +281,10 @@ class Parser {
|
|
281
281
|
else {
|
282
282
|
this._getNextToken();
|
283
283
|
}
|
284
|
+
const wasParsingTypeAnnotation = this._isParsingTypeAnnotation;
|
285
|
+
this._isParsingTypeAnnotation = true;
|
284
286
|
const expression = this._parseTestExpression(/* allowAssignmentExpression */ false);
|
287
|
+
this._isParsingTypeAnnotation = wasParsingTypeAnnotation;
|
285
288
|
return parseNodes_1.TypeAliasNode.create(typeToken, name, expression, typeParameters);
|
286
289
|
}
|
287
290
|
// type_param_seq: '[' (type_param ',')+ ']'
|
@@ -342,7 +345,7 @@ class Parser {
|
|
342
345
|
if (this._consumeTokenIfOperator(2 /* OperatorType.Assign */)) {
|
343
346
|
defaultExpression = this._parseExpression(
|
344
347
|
/* allowUnpack */ typeParamCategory === parseNodes_1.TypeParameterCategory.TypeVarTuple);
|
345
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
348
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_13)) {
|
346
349
|
this._addSyntaxError(localize_1.LocMessage.typeVarDefaultIllegal(), defaultExpression);
|
347
350
|
}
|
348
351
|
}
|
@@ -450,7 +453,7 @@ class Parser {
|
|
450
453
|
}
|
451
454
|
}
|
452
455
|
// This feature requires Python 3.10.
|
453
|
-
if (this._getLanguageVersion()
|
456
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_10)) {
|
454
457
|
this._addSyntaxError(localize_1.LocMessage.matchIncompatible(), matchToken);
|
455
458
|
}
|
456
459
|
// Validate that only the last entry uses an irrefutable pattern.
|
@@ -1216,7 +1219,7 @@ class Parser {
|
|
1216
1219
|
forSuite = this._parseLoopSuite();
|
1217
1220
|
// Versions of Python earlier than 3.9 didn't allow unpack operators if the
|
1218
1221
|
// tuple wasn't enclosed in parentheses.
|
1219
|
-
if (this._getLanguageVersion()
|
1222
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9) && !this._parseOptions.isStubFile) {
|
1220
1223
|
if (seqExpr.nodeType === 52 /* ParseNodeType.Tuple */ && !seqExpr.enclosedInParens) {
|
1221
1224
|
let sawStar = false;
|
1222
1225
|
seqExpr.expressions.forEach((expr) => {
|
@@ -1355,7 +1358,7 @@ class Parser {
|
|
1355
1358
|
const possibleStarToken = this._peekToken();
|
1356
1359
|
let isExceptGroup = false;
|
1357
1360
|
if (this._consumeTokenIfOperator(26 /* OperatorType.Multiply */)) {
|
1358
|
-
if (this._getLanguageVersion()
|
1361
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_11) && !this._parseOptions.isStubFile) {
|
1359
1362
|
this._addSyntaxError(localize_1.LocMessage.exceptionGroupIncompatible(), possibleStarToken);
|
1360
1363
|
}
|
1361
1364
|
isExceptGroup = true;
|
@@ -1435,7 +1438,7 @@ class Parser {
|
|
1435
1438
|
const possibleOpenBracket = this._peekToken();
|
1436
1439
|
if (possibleOpenBracket.type === 15 /* TokenType.OpenBracket */) {
|
1437
1440
|
typeParameters = this._parseTypeParameterList();
|
1438
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
1441
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
|
1439
1442
|
this._addSyntaxError(localize_1.LocMessage.functionTypeParametersIllegal(), typeParameters);
|
1440
1443
|
}
|
1441
1444
|
}
|
@@ -1627,7 +1630,7 @@ class Parser {
|
|
1627
1630
|
starCount = 2;
|
1628
1631
|
}
|
1629
1632
|
else if (this._consumeTokenIfOperator(10 /* OperatorType.Divide */)) {
|
1630
|
-
if (this._getLanguageVersion()
|
1633
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_8) && !this._parseOptions.isStubFile) {
|
1631
1634
|
this._addSyntaxError(localize_1.LocMessage.positionOnlyIncompatible(), firstToken);
|
1632
1635
|
}
|
1633
1636
|
slashCount = 1;
|
@@ -1717,7 +1720,7 @@ class Parser {
|
|
1717
1720
|
}
|
1718
1721
|
if (isParenthesizedWithItemList) {
|
1719
1722
|
this._consumeTokenIfType(13 /* TokenType.OpenParenthesis */);
|
1720
|
-
if (this._getLanguageVersion()
|
1723
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9)) {
|
1721
1724
|
this._addSyntaxError(localize_1.LocMessage.parenthesizedContextManagerIllegal(), possibleParen);
|
1722
1725
|
}
|
1723
1726
|
}
|
@@ -1810,7 +1813,7 @@ class Parser {
|
|
1810
1813
|
const expression = this._parseTestExpression(/* allowAssignmentExpression */ true);
|
1811
1814
|
// Versions of Python prior to 3.9 support a limited set of
|
1812
1815
|
// expression forms.
|
1813
|
-
if (this._getLanguageVersion()
|
1816
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9)) {
|
1814
1817
|
let isSupportedExpressionForm = false;
|
1815
1818
|
if (this._isNameOrMemberAccessExpression(expression)) {
|
1816
1819
|
isSupportedExpressionForm = true;
|
@@ -1851,7 +1854,7 @@ class Parser {
|
|
1851
1854
|
const possibleOpenBracket = this._peekToken();
|
1852
1855
|
if (possibleOpenBracket.type === 15 /* TokenType.OpenBracket */) {
|
1853
1856
|
typeParameters = this._parseTypeParameterList();
|
1854
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
1857
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
|
1855
1858
|
this._addSyntaxError(localize_1.LocMessage.classTypeParametersIllegal(), typeParameters);
|
1856
1859
|
}
|
1857
1860
|
}
|
@@ -2241,7 +2244,7 @@ class Parser {
|
|
2241
2244
|
const yieldToken = this._getKeywordToken(38 /* KeywordType.Yield */);
|
2242
2245
|
const nextToken = this._peekToken();
|
2243
2246
|
if (this._consumeTokenIfKeyword(18 /* KeywordType.From */)) {
|
2244
|
-
if (this._getLanguageVersion()
|
2247
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_3)) {
|
2245
2248
|
this._addSyntaxError(localize_1.LocMessage.yieldFromIllegal(), nextToken);
|
2246
2249
|
}
|
2247
2250
|
return parseNodes_1.YieldFromNode.create(yieldToken, this._parseTestExpression(/* allowAssignmentExpression */ false));
|
@@ -2482,7 +2485,7 @@ class Parser {
|
|
2482
2485
|
if (!this._assignmentExpressionsAllowed || disallowAssignmentExpression) {
|
2483
2486
|
this._addSyntaxError(localize_1.LocMessage.walrusNotAllowed(), walrusToken);
|
2484
2487
|
}
|
2485
|
-
if (this._getLanguageVersion()
|
2488
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_8)) {
|
2486
2489
|
this._addSyntaxError(localize_1.LocMessage.walrusIllegal(), walrusToken);
|
2487
2490
|
}
|
2488
2491
|
const rightExpr = this._parseTestExpression(/* allowAssignmentExpression */ false);
|
@@ -2730,7 +2733,7 @@ class Parser {
|
|
2730
2733
|
let awaitToken;
|
2731
2734
|
if (this._peekKeywordType() === 4 /* KeywordType.Await */) {
|
2732
2735
|
awaitToken = this._getKeywordToken(4 /* KeywordType.Await */);
|
2733
|
-
if (this._getLanguageVersion()
|
2736
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_5)) {
|
2734
2737
|
this._addSyntaxError(localize_1.LocMessage.awaitIllegal(), awaitToken);
|
2735
2738
|
}
|
2736
2739
|
}
|
@@ -2871,7 +2874,7 @@ class Parser {
|
|
2871
2874
|
this._tokenIndex = startOfSubscriptIndex;
|
2872
2875
|
valueExpr = this._parseTestExpression(/* allowAssignmentExpression */ true);
|
2873
2876
|
// Python 3.10 and newer allow assignment expressions to be used inside of a subscript.
|
2874
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
2877
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_10)) {
|
2875
2878
|
this._addSyntaxError(localize_1.LocMessage.assignmentExprInSubscript(), valueExpr);
|
2876
2879
|
}
|
2877
2880
|
}
|
@@ -2894,7 +2897,7 @@ class Parser {
|
|
2894
2897
|
if (argType !== 0 /* ArgumentCategory.Simple */) {
|
2895
2898
|
const unpackListAllowed = this._parseOptions.isStubFile ||
|
2896
2899
|
this._isParsingQuotedText ||
|
2897
|
-
this._getLanguageVersion()
|
2900
|
+
this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_11);
|
2898
2901
|
if (argType === 1 /* ArgumentCategory.UnpackedList */ && !unpackListAllowed) {
|
2899
2902
|
this._addSyntaxError(localize_1.LocMessage.unpackedSubscriptIllegal(), argNode);
|
2900
2903
|
}
|
@@ -2934,7 +2937,7 @@ class Parser {
|
|
2934
2937
|
}
|
2935
2938
|
if (nextTokenType !== 10 /* TokenType.Colon */) {
|
2936
2939
|
// Python 3.10 and newer allow assignment expressions to be used inside of a subscript.
|
2937
|
-
const allowAssignmentExpression = this._parseOptions.isStubFile || this._getLanguageVersion()
|
2940
|
+
const allowAssignmentExpression = this._parseOptions.isStubFile || this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_10);
|
2938
2941
|
sliceExpressions[sliceIndex] = this._parseTestExpression(allowAssignmentExpression);
|
2939
2942
|
}
|
2940
2943
|
sliceIndex++;
|
@@ -3411,7 +3414,7 @@ class Parser {
|
|
3411
3414
|
if (this._consumeTokenIfType(10 /* TokenType.Colon */)) {
|
3412
3415
|
annotationExpr = this._parseTypeAnnotation();
|
3413
3416
|
leftExpr = parseNodes_1.TypeAnnotationNode.create(leftExpr, annotationExpr);
|
3414
|
-
if (!this._parseOptions.isStubFile && this._getLanguageVersion()
|
3417
|
+
if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_6)) {
|
3415
3418
|
this._addSyntaxError(localize_1.LocMessage.varAnnotationIllegal(), annotationExpr);
|
3416
3419
|
}
|
3417
3420
|
if (!this._consumeTokenIfOperator(2 /* OperatorType.Assign */)) {
|
@@ -3542,7 +3545,7 @@ class Parser {
|
|
3542
3545
|
allowUnpack &&
|
3543
3546
|
!this._parseOptions.isStubFile &&
|
3544
3547
|
!this._isParsingQuotedText &&
|
3545
|
-
this._getLanguageVersion()
|
3548
|
+
this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_11)) {
|
3546
3549
|
this._addSyntaxError(localize_1.LocMessage.unpackedSubscriptIllegal(), startToken);
|
3547
3550
|
}
|
3548
3551
|
let result = this._parseTestExpression(/* allowAssignmentExpression */ false);
|
@@ -3560,7 +3563,7 @@ class Parser {
|
|
3560
3563
|
this._addSyntaxError(localize_1.LocMessage.stringNonAsciiBytes(), stringToken);
|
3561
3564
|
}
|
3562
3565
|
if (stringToken.flags & 64 /* StringTokenFlags.Format */) {
|
3563
|
-
if (this._getLanguageVersion()
|
3566
|
+
if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_6)) {
|
3564
3567
|
this._addSyntaxError(localize_1.LocMessage.formatStringIllegal(), stringToken);
|
3565
3568
|
}
|
3566
3569
|
if (stringToken.flags & 32 /* StringTokenFlags.Bytes */) {
|
@@ -3658,7 +3661,7 @@ class Parser {
|
|
3658
3661
|
if (nextToken.type === 9 /* TokenType.Operator */ &&
|
3659
3662
|
nextToken.operatorType === 2 /* OperatorType.Assign */) {
|
3660
3663
|
// This feature requires Python 3.8 or newer.
|
3661
|
-
if (this._parseOptions.pythonVersion
|
3664
|
+
if (this._parseOptions.pythonVersion.isLessThan(pythonVersion_1.pythonVersion3_8)) {
|
3662
3665
|
this._addSyntaxError(localize_1.LocMessage.formatStringDebuggingIllegal(), nextToken);
|
3663
3666
|
}
|
3664
3667
|
this._getNextToken();
|
@@ -3853,7 +3856,7 @@ class Parser {
|
|
3853
3856
|
if (possibleTupleExpr.enclosedInParens) {
|
3854
3857
|
return;
|
3855
3858
|
}
|
3856
|
-
if (this._parseOptions.pythonVersion
|
3859
|
+
if (this._parseOptions.pythonVersion.isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_8)) {
|
3857
3860
|
return;
|
3858
3861
|
}
|
3859
3862
|
for (const expr of possibleTupleExpr.expressions) {
|