@zzzen/pyright-internal 1.2.0-dev.20241208 → 1.2.0-dev.20241222
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/analysis.js +1 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +17 -18
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +18 -35
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +38 -55
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +146 -185
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +24 -31
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +23 -24
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.js +1 -2
- package/dist/analyzer/constraintTracker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +10 -12
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +14 -19
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +32 -27
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +8 -11
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +2 -3
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +6 -8
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/enums.js +12 -13
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +1 -2
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +18 -27
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +4 -5
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +6 -7
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +14 -17
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +48 -50
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -7
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js +8 -9
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +30 -44
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +2 -3
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +18 -20
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +29 -40
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +21 -23
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +1 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js +10 -10
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/service.js +32 -47
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +21 -26
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js +2 -3
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +5 -5
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +19 -30
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/testWalker.js +1 -2
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +7 -9
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.js +11 -13
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +5 -6
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +7 -11
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +619 -776
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +2 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +26 -36
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +15 -24
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +1 -2
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +65 -94
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +4 -8
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +39 -46
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +64 -103
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.js +2 -3
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +9 -10
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +6 -7
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +3 -3
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/asyncInitialization.js +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +2 -4
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/configOptions.js +6 -9
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +1 -2
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js +2 -2
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js +1 -1
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/diagnostic.js +3 -5
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/envVarUtils.js +1 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +1 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.js +5 -5
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.js +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.js +1 -1
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.js +1 -2
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/progressReporter.js +1 -2
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/realFileSystem.js +2 -3
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/streamUtils.d.ts +2 -0
- package/dist/common/streamUtils.js +29 -0
- package/dist/common/streamUtils.js.map +1 -0
- package/dist/common/textEditTracker.js +4 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/tomlUtils.js +3 -1
- package/dist/common/tomlUtils.js.map +1 -1
- package/dist/common/uri/baseUri.js +1 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/emptyUri.js +1 -1
- package/dist/common/uri/emptyUri.js.map +1 -1
- package/dist/common/uri/fileUri.js +2 -2
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +1 -1
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.js +2 -3
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.js +6 -8
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.js +2 -2
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +10 -15
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js +34 -42
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +8 -10
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +16 -19
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +6 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +81 -106
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +3 -3
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +6 -9
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +32 -32
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/dynamicFeature.js +1 -2
- package/dist/languageService/dynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +17 -23
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +4 -9
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js +2 -4
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +11 -15
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +15 -17
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.js +3 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +6 -0
- package/dist/localization/package.nls.de.json +6 -0
- package/dist/localization/package.nls.en-us.json +8 -8
- package/dist/localization/package.nls.es.json +6 -0
- package/dist/localization/package.nls.fr.json +7 -1
- package/dist/localization/package.nls.it.json +6 -0
- package/dist/localization/package.nls.ja.json +6 -0
- package/dist/localization/package.nls.ko.json +6 -0
- package/dist/localization/package.nls.pl.json +6 -0
- package/dist/localization/package.nls.pt-br.json +6 -0
- package/dist/localization/package.nls.qps-ploc.json +6 -0
- package/dist/localization/package.nls.ru.json +6 -0
- package/dist/localization/package.nls.tr.json +6 -0
- package/dist/localization/package.nls.zh-cn.json +6 -0
- package/dist/localization/package.nls.zh-tw.json +6 -0
- package/dist/parser/parser.js +30 -38
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +8 -13
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pprof/profiler.js +3 -3
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js +9 -11
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.js +4 -5
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.js +3 -5
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +3 -3
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js +7 -10
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/completions.test.js +3 -3
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +10 -15
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +4 -6
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +9 -12
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +45 -60
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +6 -7
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +3 -3
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +6 -7
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +2 -2
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +11 -12
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.js +1 -2
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +10 -14
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +10 -14
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +7 -7
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +2 -2
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/service.test.js +2 -3
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +2 -3
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +3 -4
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +3 -6
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +3 -4
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typePrinter.test.js +1 -2
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +3 -5
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -3
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/binder.js
CHANGED
@@ -106,7 +106,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
106
106
|
this._fileInfo = fileInfo;
|
107
107
|
}
|
108
108
|
bindModule(node) {
|
109
|
-
var _a;
|
110
109
|
// We'll assume that if there is no builtins scope provided, we must be
|
111
110
|
// binding the builtins module itself.
|
112
111
|
const isBuiltInModule = this._fileInfo.builtinsScope === undefined;
|
@@ -141,8 +140,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
141
140
|
// Use the __all__ list to determine whether any potential private
|
142
141
|
// symbols should be made externally hidden or private.
|
143
142
|
this._potentialHiddenSymbols.forEach((symbol, name) => {
|
144
|
-
|
145
|
-
if (!((_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.some((sym) => sym === name))) {
|
143
|
+
if (!this._dunderAllNames?.some((sym) => sym === name)) {
|
146
144
|
if (this._fileInfo.isStubFile) {
|
147
145
|
symbol.setIsExternallyHidden();
|
148
146
|
}
|
@@ -152,8 +150,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
152
150
|
}
|
153
151
|
});
|
154
152
|
this._potentialPrivateSymbols.forEach((symbol, name) => {
|
155
|
-
|
156
|
-
if (!((_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.some((sym) => sym === name))) {
|
153
|
+
if (!this._dunderAllNames?.some((sym) => sym === name)) {
|
157
154
|
symbol.setIsPrivateMember();
|
158
155
|
}
|
159
156
|
});
|
@@ -171,7 +168,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
171
168
|
const scope = AnalyzerNodeInfo.getScope(node);
|
172
169
|
if (scope && this._dunderAllNames) {
|
173
170
|
for (const name of this._dunderAllNames) {
|
174
|
-
|
171
|
+
scope.symbolTable.get(name)?.setIsInDunderAll();
|
175
172
|
}
|
176
173
|
}
|
177
174
|
}
|
@@ -236,7 +233,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
236
233
|
typeParamScope = AnalyzerNodeInfo.getScope(node.d.typeParams);
|
237
234
|
}
|
238
235
|
this.walkMultiple(node.d.arguments);
|
239
|
-
this._createNewScope(3 /* ScopeType.Class */, typeParamScope
|
236
|
+
this._createNewScope(3 /* ScopeType.Class */, typeParamScope ?? this._getNonClassParentScope(),
|
240
237
|
/* proxyScope */ undefined, () => {
|
241
238
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
242
239
|
this._addImplicitSymbolToCurrentScope('__doc__', node, 'str | None');
|
@@ -303,7 +300,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
303
300
|
}
|
304
301
|
// Don't walk the body of the function until we're done analyzing
|
305
302
|
// the current scope.
|
306
|
-
this._createNewScope(2 /* ScopeType.Function */, typeParamScope
|
303
|
+
this._createNewScope(2 /* ScopeType.Function */, typeParamScope ?? this._getNonClassParentScope(),
|
307
304
|
/* proxyScope */ undefined, () => {
|
308
305
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
309
306
|
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
@@ -399,7 +396,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
399
396
|
return false;
|
400
397
|
}
|
401
398
|
visitCall(node) {
|
402
|
-
var _a, _b;
|
403
399
|
this._disableTrueFalseTargets(() => {
|
404
400
|
this.walk(node.d.leftExpr);
|
405
401
|
const sortedArgs = ParseTreeUtils.getArgsByRuntimeOrder(node);
|
@@ -435,12 +431,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
435
431
|
// Is this a call to "__all__.extend([<list>])"?
|
436
432
|
if (argExpr.nodeType === 34 /* ParseNodeType.List */) {
|
437
433
|
if (argExpr.d.items.every((listEntryNode) => {
|
438
|
-
var _a, _b;
|
439
434
|
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
440
435
|
listEntryNode.d.strings.length === 1 &&
|
441
436
|
listEntryNode.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
442
|
-
|
443
|
-
|
437
|
+
this._dunderAllNames?.push(listEntryNode.d.strings[0].d.value);
|
438
|
+
this._dunderAllStringNodes?.push(listEntryNode.d.strings[0]);
|
444
439
|
return true;
|
445
440
|
}
|
446
441
|
return false;
|
@@ -455,8 +450,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
455
450
|
const namesToAdd = this._getDunderAllNamesFromImport(argExpr.d.leftExpr.d.value);
|
456
451
|
if (namesToAdd && namesToAdd.length > 0) {
|
457
452
|
namesToAdd.forEach((name) => {
|
458
|
-
|
459
|
-
(_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.push(name);
|
453
|
+
this._dunderAllNames?.push(name);
|
460
454
|
});
|
461
455
|
}
|
462
456
|
emitDunderAllWarning = false;
|
@@ -480,8 +474,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
480
474
|
if (argExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
|
481
475
|
argExpr.d.strings.length === 1 &&
|
482
476
|
argExpr.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
483
|
-
|
484
|
-
|
477
|
+
this._dunderAllNames?.push(argExpr.d.strings[0].d.value);
|
478
|
+
this._dunderAllStringNodes?.push(argExpr.d.strings[0]);
|
485
479
|
emitDunderAllWarning = false;
|
486
480
|
}
|
487
481
|
}
|
@@ -553,7 +547,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
553
547
|
AnalyzerNodeInfo.setDeclaration(node, typeAliasDeclaration);
|
554
548
|
this._createAssignmentTargetFlowNodes(node.d.name, /* walkTargets */ true, /* unbound */ false);
|
555
549
|
const prevScope = this._currentScope;
|
556
|
-
this._currentScope = typeParamScope
|
550
|
+
this._currentScope = typeParamScope ?? this._currentScope;
|
557
551
|
this.walk(node.d.expr);
|
558
552
|
this._currentScope = prevScope;
|
559
553
|
return false;
|
@@ -746,11 +740,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
746
740
|
if (expr.nodeType === 34 /* ParseNodeType.List */) {
|
747
741
|
// Is this the form __all__ += ["a", "b"]?
|
748
742
|
expr.d.items.forEach((listEntryNode) => {
|
749
|
-
var _a;
|
750
743
|
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
751
744
|
listEntryNode.d.strings.length === 1 &&
|
752
745
|
listEntryNode.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
753
|
-
|
746
|
+
this._dunderAllNames?.push(listEntryNode.d.strings[0].d.value);
|
754
747
|
this._dunderAllStringNodes.push(listEntryNode.d.strings[0]);
|
755
748
|
}
|
756
749
|
});
|
@@ -763,8 +756,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
763
756
|
const namesToAdd = this._getDunderAllNamesFromImport(expr.d.leftExpr.d.value);
|
764
757
|
if (namesToAdd) {
|
765
758
|
namesToAdd.forEach((name) => {
|
766
|
-
|
767
|
-
(_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.push(name);
|
759
|
+
this._dunderAllNames?.push(name);
|
768
760
|
});
|
769
761
|
emitDunderAllWarning = false;
|
770
762
|
}
|
@@ -785,13 +777,12 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
785
777
|
return false;
|
786
778
|
}
|
787
779
|
visitTypeAnnotation(node) {
|
788
|
-
var _a;
|
789
780
|
if (this._handleTypingStubAssignmentOrAnnotation(node)) {
|
790
781
|
return false;
|
791
782
|
}
|
792
783
|
// If this is an annotated variable assignment within a class body,
|
793
784
|
// we need to evaluate the type annotation first.
|
794
|
-
const bindVariableBeforeAnnotationEvaluation =
|
785
|
+
const bindVariableBeforeAnnotationEvaluation = node.parent?.nodeType === 3 /* ParseNodeType.Assignment */ &&
|
795
786
|
ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true) !== undefined;
|
796
787
|
if (!bindVariableBeforeAnnotationEvaluation) {
|
797
788
|
this.walk(node.d.annotation);
|
@@ -834,8 +825,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
834
825
|
this._addAntecedent(preForLabel, this._currentFlowNode);
|
835
826
|
// Add any target expressions since they are modified in the loop.
|
836
827
|
targetExpressions.forEach((value) => {
|
837
|
-
|
838
|
-
(_a = this._currentScopeCodeFlowExpressions) === null || _a === void 0 ? void 0 : _a.add(value);
|
828
|
+
this._currentScopeCodeFlowExpressions?.add(value);
|
839
829
|
});
|
840
830
|
});
|
841
831
|
this._currentFlowNode = this._finishFlowLabel(preElseLabel);
|
@@ -1169,18 +1159,17 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1169
1159
|
return false;
|
1170
1160
|
}
|
1171
1161
|
visitAwait(node) {
|
1172
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
1173
1162
|
// Make sure this is within an async lambda or function.
|
1174
1163
|
const execScopeNode = ParseTreeUtils.getExecutionScopeNode(node);
|
1175
|
-
if (
|
1176
|
-
if (this._fileInfo.ipythonMode &&
|
1164
|
+
if (execScopeNode?.nodeType !== 31 /* ParseNodeType.Function */ || !execScopeNode.d.isAsync) {
|
1165
|
+
if (this._fileInfo.ipythonMode && execScopeNode?.nodeType === 36 /* ParseNodeType.Module */) {
|
1177
1166
|
// Top level await is allowed in ipython mode.
|
1178
1167
|
return true;
|
1179
1168
|
}
|
1180
|
-
const isInGenerator =
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1169
|
+
const isInGenerator = node.parent?.nodeType === 11 /* ParseNodeType.Comprehension */ &&
|
1170
|
+
node.parent?.parent?.nodeType !== 34 /* ParseNodeType.List */ &&
|
1171
|
+
node.parent?.parent?.nodeType !== 45 /* ParseNodeType.Set */ &&
|
1172
|
+
node.parent?.parent?.nodeType !== 18 /* ParseNodeType.Dictionary */;
|
1184
1173
|
// Allow if it's within a generator expression. Execution of
|
1185
1174
|
// generator expressions is deferred and therefore can be
|
1186
1175
|
// run within the context of an async function later.
|
@@ -1239,7 +1228,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1239
1228
|
return true;
|
1240
1229
|
}
|
1241
1230
|
visitImportAs(node) {
|
1242
|
-
var _a, _b, _c, _d, _e, _f;
|
1243
1231
|
if (node.d.module.d.nameParts.length > 0) {
|
1244
1232
|
const firstNamePartValue = node.d.module.d.nameParts[0].d.value;
|
1245
1233
|
let symbolName;
|
@@ -1277,20 +1265,19 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1277
1265
|
this._createFlowAssignment(node.d.alias ? node.d.alias : node.d.module.d.nameParts[0]);
|
1278
1266
|
if (node.d.module.d.nameParts.length === 1) {
|
1279
1267
|
if (firstNamePartValue === 'typing' || firstNamePartValue === 'typing_extensions') {
|
1280
|
-
this._typingImportAliases.push(
|
1268
|
+
this._typingImportAliases.push(node.d.alias?.d.value ?? firstNamePartValue);
|
1281
1269
|
}
|
1282
1270
|
else if (firstNamePartValue === 'sys') {
|
1283
|
-
this._sysImportAliases.push(
|
1271
|
+
this._sysImportAliases.push(node.d.alias?.d.value ?? firstNamePartValue);
|
1284
1272
|
}
|
1285
1273
|
else if (firstNamePartValue === 'dataclasses') {
|
1286
|
-
this._dataclassesImportAliases.push(
|
1274
|
+
this._dataclassesImportAliases.push(node.d.alias?.d.value ?? firstNamePartValue);
|
1287
1275
|
}
|
1288
1276
|
}
|
1289
1277
|
}
|
1290
1278
|
return true;
|
1291
1279
|
}
|
1292
1280
|
visitImportFrom(node) {
|
1293
|
-
var _a;
|
1294
1281
|
const typingSymbolsOfInterest = ['Final', 'ClassVar', 'Annotated'];
|
1295
1282
|
const dataclassesSymbolsOfInterest = ['InitVar'];
|
1296
1283
|
const importInfo = AnalyzerNodeInfo.getImportInfo(node.d.module);
|
@@ -1326,7 +1313,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1326
1313
|
const names = [];
|
1327
1314
|
// Note that this scope uses a wildcard import, so we cannot shortcut
|
1328
1315
|
// any code flow checks. All expressions are potentially in play.
|
1329
|
-
|
1316
|
+
this._currentScopeCodeFlowExpressions?.add(codeFlowTypes_1.wildcardImportReferenceKey);
|
1330
1317
|
const lookupInfo = this._fileInfo.importLookup(resolvedPath);
|
1331
1318
|
if (lookupInfo) {
|
1332
1319
|
const wildcardNames = this._getWildcardImportNames(lookupInfo);
|
@@ -1483,7 +1470,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1483
1470
|
range: (0, positionUtils_1.convertTextRangeToRange)(nameNode, this._fileInfo.lines),
|
1484
1471
|
moduleName: this._formatModuleName(node.d.module),
|
1485
1472
|
isInExceptSuite: this._isInExceptSuite,
|
1486
|
-
isNativeLib: importInfo
|
1473
|
+
isNativeLib: importInfo?.isNativeLib,
|
1487
1474
|
};
|
1488
1475
|
symbol.addDeclaration(aliasDecl);
|
1489
1476
|
this._createFlowAssignment(importSymbolNode.d.alias || importSymbolNode.d.name);
|
@@ -1646,7 +1633,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1646
1633
|
}
|
1647
1634
|
this._createNewScope(1 /* ScopeType.Comprehension */, this._getNonClassParentScope(),
|
1648
1635
|
/* proxyScope */ undefined, () => {
|
1649
|
-
var _a, _b, _c;
|
1650
1636
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
1651
1637
|
const falseLabel = this._createBranchLabel();
|
1652
1638
|
// We'll walk the forIfNodes list twice. The first time we'll
|
@@ -1665,9 +1651,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1665
1651
|
// Allow if it's within a generator expression. Execution of
|
1666
1652
|
// generator expressions is deferred and therefore can be
|
1667
1653
|
// run within the context of an async function later.
|
1668
|
-
if (
|
1669
|
-
|
1670
|
-
|
1654
|
+
if (node.parent?.nodeType === 34 /* ParseNodeType.List */ ||
|
1655
|
+
node.parent?.nodeType === 45 /* ParseNodeType.Set */ ||
|
1656
|
+
node.parent?.nodeType === 18 /* ParseNodeType.Dictionary */) {
|
1671
1657
|
this._addSyntaxError(localize_1.LocMessage.asyncNotInAsyncFunction(), compr.d.asyncToken);
|
1672
1658
|
}
|
1673
1659
|
}
|
@@ -1930,16 +1916,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1930
1916
|
// Attempts to resolve the module name, import it, and return
|
1931
1917
|
// its __all__ symbols.
|
1932
1918
|
_getDunderAllNamesFromImport(varName) {
|
1933
|
-
var _a, _b;
|
1934
1919
|
const varSymbol = this._currentScope.lookUpSymbol(varName);
|
1935
1920
|
if (!varSymbol) {
|
1936
1921
|
return undefined;
|
1937
1922
|
}
|
1938
1923
|
// There should be only one declaration for the variable.
|
1939
1924
|
const aliasDecl = varSymbol.getDeclarations().find((decl) => decl.type === 8 /* DeclarationType.Alias */);
|
1940
|
-
const resolvedUri =
|
1925
|
+
const resolvedUri = aliasDecl?.uri && !aliasDecl.uri.isEmpty() && aliasDecl.loadSymbolsFromPath
|
1941
1926
|
? aliasDecl.uri
|
1942
|
-
:
|
1927
|
+
: aliasDecl?.submoduleFallback?.uri &&
|
1943
1928
|
!aliasDecl.submoduleFallback.uri.isEmpty() &&
|
1944
1929
|
aliasDecl.submoduleFallback.loadSymbolsFromPath
|
1945
1930
|
? aliasDecl.submoduleFallback.uri
|
@@ -1948,12 +1933,12 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1948
1933
|
return undefined;
|
1949
1934
|
}
|
1950
1935
|
let lookupInfo = this._fileInfo.importLookup(resolvedUri);
|
1951
|
-
if (lookupInfo
|
1936
|
+
if (lookupInfo?.dunderAllNames) {
|
1952
1937
|
return lookupInfo.dunderAllNames;
|
1953
1938
|
}
|
1954
|
-
if (
|
1939
|
+
if (aliasDecl?.submoduleFallback?.uri && !aliasDecl.submoduleFallback.uri.isEmpty()) {
|
1955
1940
|
lookupInfo = this._fileInfo.importLookup(aliasDecl.submoduleFallback.uri);
|
1956
|
-
return lookupInfo
|
1941
|
+
return lookupInfo?.dunderAllNames;
|
1957
1942
|
}
|
1958
1943
|
return undefined;
|
1959
1944
|
}
|
@@ -1966,7 +1951,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1966
1951
|
this._createFlowAssignment(node.d.module.d.nameParts[0]);
|
1967
1952
|
}
|
1968
1953
|
_createAliasDeclarationForMultipartImportName(node, importAlias, importInfo, symbol) {
|
1969
|
-
var _a;
|
1970
1954
|
const firstNamePartValue = node.d.module.d.nameParts[0].d.value;
|
1971
1955
|
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode);
|
1972
1956
|
// See if there's already a matching alias declaration for this import.
|
@@ -2017,7 +2001,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2017
2001
|
loadSymbolsFromPath: true,
|
2018
2002
|
range: (0, textRange_1.getEmptyRange)(),
|
2019
2003
|
usesLocalName: !!importAlias,
|
2020
|
-
moduleName:
|
2004
|
+
moduleName: importInfo?.importName ?? '',
|
2021
2005
|
firstNamePart: importAlias
|
2022
2006
|
? this._formatModuleName(node.d.module)
|
2023
2007
|
: '.'.repeat(node.d.module.d.leadingDots) + firstNamePartValue,
|
@@ -2910,7 +2894,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2910
2894
|
return exemptSymbols.some((name) => name === symbolName);
|
2911
2895
|
}
|
2912
2896
|
_addTypeDeclarationForVariable(target, typeAnnotation) {
|
2913
|
-
var _a, _b, _c;
|
2914
2897
|
let declarationHandled = false;
|
2915
2898
|
switch (target.nodeType) {
|
2916
2899
|
case 38 /* ParseNodeType.Name */: {
|
@@ -2940,8 +2923,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2940
2923
|
const containingClass = ParseTreeUtils.getEnclosingClassOrFunction(target);
|
2941
2924
|
if (containingClass && containingClass.nodeType === 10 /* ParseNodeType.Class */) {
|
2942
2925
|
// Make sure it's part of an assignment.
|
2943
|
-
if (
|
2944
|
-
|
2926
|
+
if (target.parent?.nodeType === 3 /* ParseNodeType.Assignment */ ||
|
2927
|
+
target.parent?.parent?.nodeType === 3 /* ParseNodeType.Assignment */) {
|
2945
2928
|
isFinalAssignedInClassBody = true;
|
2946
2929
|
}
|
2947
2930
|
}
|
@@ -3090,7 +3073,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3090
3073
|
// Allow Final to be enclosed in ClassVar. Normally, Final implies
|
3091
3074
|
// ClassVar, but this combination is required in the case of dataclasses.
|
3092
3075
|
const classVarInfo = this._isAnnotationClassVar(typeAnnotation);
|
3093
|
-
if (classVarInfo
|
3076
|
+
if (classVarInfo?.classVarTypeNode) {
|
3094
3077
|
typeAnnotation = classVarInfo.classVarTypeNode;
|
3095
3078
|
}
|
3096
3079
|
if (this._isTypingAnnotation(typeAnnotation, 'Final')) {
|