@zzzen/pyright-internal 1.2.0-dev.20231112 → 1.2.0-dev.20231126
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.d.ts +1 -1
- package/dist/analyzer/analysis.js +5 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.d.ts +1 -1
- package/dist/analyzer/analyzerNodeInfo.d.ts +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +1 -1
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +198 -194
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.js +1 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +286 -256
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +1 -1
- package/dist/analyzer/codeFlowEngine.js +26 -26
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +1 -1
- package/dist/analyzer/codeFlowTypes.js +23 -23
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +39 -37
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +48 -45
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +8 -8
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +33 -31
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +67 -63
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +2 -2
- package/dist/analyzer/declaration.js +10 -10
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +44 -41
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +51 -51
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +1 -1
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/docStringUtils.js +1 -1
- package/dist/analyzer/enums.js +27 -27
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +4 -4
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +27 -18
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.js +1 -1
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +31 -27
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +36 -32
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +78 -78
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +1 -1
- package/dist/analyzer/packageTypeReport.js +2 -2
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +90 -90
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +14 -14
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.d.ts +2 -2
- package/dist/analyzer/parseTreeCleaner.js +5 -1
- package/dist/analyzer/parseTreeCleaner.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/parseTreeUtils.js +383 -379
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +161 -157
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +1 -1
- package/dist/analyzer/patternMatching.js +71 -64
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -1
- package/dist/analyzer/program.js +20 -17
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +53 -44
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -14
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +5 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/regions.js +3 -3
- package/dist/analyzer/regions.js.map +1 -1
- package/dist/analyzer/scope.js +8 -8
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +1 -1
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.js +5 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +25 -21
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +2 -2
- package/dist/analyzer/sourceMapper.js +15 -8
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +40 -40
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +1 -1
- package/dist/analyzer/symbol.js +26 -26
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolUtils.js +1 -1
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/testWalker.js +5 -5
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +1 -1
- package/dist/analyzer/tracePrinter.js +35 -31
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +5 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +13 -9
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +1272 -1176
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -1
- package/dist/analyzer/typeEvaluatorTypes.js +3 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +1 -1
- package/dist/analyzer/typeGuards.js +95 -67
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +1 -1
- package/dist/analyzer/typePrinter.js +80 -76
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +26 -22
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +163 -123
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +1 -0
- package/dist/analyzer/typeVarContext.js +12 -9
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.js +10 -10
- package/dist/analyzer/typedDicts.js +74 -70
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +17 -12
- package/dist/analyzer/types.js +191 -181
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -2
- package/dist/backgroundAnalysisBase.js +5 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +5 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.js +7 -7
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/commandResult.js +1 -1
- package/dist/commands/commandResult.js.map +1 -1
- package/dist/commands/commands.js +1 -1
- package/dist/commands/commands.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +196 -196
- 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/charCodes.js +1 -1
- package/dist/common/charCodes.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +5 -1
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/collectionUtils.d.ts +3 -3
- package/dist/common/collectionUtils.js +3 -3
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -1
- package/dist/common/commandLineOptions.js +5 -5
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -1
- package/dist/common/configOptions.js +11 -7
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +7 -3
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.d.ts +2 -2
- package/dist/common/core.js +6 -6
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.js +6 -6
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.js +1 -1
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/diagnosticSink.js +12 -12
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.d.ts +1 -1
- package/dist/common/editAction.js +2 -2
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/envVarUtils.js +5 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.js +1 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +5 -1
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js +2 -2
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fileWatcher.d.ts +2 -2
- package/dist/common/fullAccessHost.js +10 -6
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +1 -1
- package/dist/common/host.js +2 -2
- package/dist/common/host.js.map +1 -1
- package/dist/common/lspUtils.js +7 -7
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/memUtils.d.ts +1 -1
- package/dist/common/pathUtils.js +12 -8
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/pythonVersion.js +1 -1
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.js +5 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.d.ts +1 -1
- package/dist/common/serviceProvider.js +5 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +1 -1
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.js +5 -5
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js +11 -7
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.js +3 -3
- package/dist/common/textRange.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -3
- package/dist/languageServerBase.js +19 -19
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +3 -3
- package/dist/languageService/autoImporter.js +12 -8
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +27 -23
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +8 -8
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +171 -173
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +9 -9
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +14 -10
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +7 -3
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +1 -1
- package/dist/languageService/documentSymbolCollector.js +21 -17
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.js +30 -26
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js +1 -1
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/quickActions.js +10 -6
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +1 -1
- package/dist/languageService/referencesProvider.js +24 -20
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +8 -4
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js +8 -4
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +20 -16
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +5 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +10 -12
- package/dist/localization/localize.js +8 -5
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +5 -8
- package/dist/localization/package.nls.de.json +5 -8
- package/dist/localization/package.nls.en-us.json +12 -9
- package/dist/localization/package.nls.es.json +5 -8
- package/dist/localization/package.nls.fr.json +5 -8
- package/dist/localization/package.nls.it.json +5 -8
- package/dist/localization/package.nls.ja.json +5 -8
- package/dist/localization/package.nls.ko.json +5 -8
- package/dist/localization/package.nls.pl.json +5 -8
- package/dist/localization/package.nls.pt-br.json +5 -8
- package/dist/localization/package.nls.qps-ploc.json +2 -5
- package/dist/localization/package.nls.ru.json +5 -8
- package/dist/localization/package.nls.tr.json +5 -8
- package/dist/localization/package.nls.zh-cn.json +5 -8
- package/dist/localization/package.nls.zh-tw.json +5 -8
- package/dist/parser/characterStream.js +3 -3
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js +13 -9
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +12 -12
- package/dist/parser/parseNodes.js +193 -193
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +563 -559
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +47 -47
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js +288 -288
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.js +35 -35
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/parser/unicode.d.ts +3 -3
- package/dist/pyright.js +38 -18
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -0
- package/dist/pyrightFileSystem.js +1 -1
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +1 -0
- package/dist/tests/chainedSourceFiles.test.js +5 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +5 -1
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/collectionUtils.test.js +5 -1
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/common.test.js +5 -1
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/config.test.js +7 -5
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js +8 -4
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/deferred.test.js +5 -1
- package/dist/tests/deferred.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +5 -1
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +0 -22
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/docStringUtils.test.js +5 -1
- package/dist/tests/docStringUtils.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +5 -1
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +5 -1
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js +5 -1
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.params.fourslash.js +11 -0
- package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +10 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +13 -13
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js +11 -7
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.d.ts +1 -1
- package/dist/tests/harness/fourslash/runner.js +5 -1
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +5 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.js +6 -2
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +17 -13
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +9 -5
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +5 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testHost.js +5 -1
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.d.ts +13 -12
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js +6 -2
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +4 -3
- package/dist/tests/harness/vfs/filesystem.js +11 -7
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +30 -26
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +25 -25
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +6 -6
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/localizer.test.js +5 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/logger.test.js +5 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +10 -10
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +13 -9
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +5 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +5 -1
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +5 -1
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/stringUtils.test.js +10 -6
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symbolNameUtils.test.js +5 -1
- package/dist/tests/symbolNameUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +5 -1
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testUtils.js +11 -7
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textRange.test.js +5 -1
- package/dist/tests/textRange.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +463 -459
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +18 -2
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +19 -3
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +11 -3
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +11 -3
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +5 -1
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +44 -40
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +5 -1
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +5 -1
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -2
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
package/dist/analyzer/binder.js
CHANGED
@@ -18,7 +18,11 @@
|
|
18
18
|
*/
|
19
19
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
20
20
|
if (k2 === undefined) k2 = k;
|
21
|
-
Object.
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
24
|
+
}
|
25
|
+
Object.defineProperty(o, k2, desc);
|
22
26
|
}) : (function(o, m, k, k2) {
|
23
27
|
if (k2 === undefined) k2 = k;
|
24
28
|
o[k2] = m[k];
|
@@ -109,7 +113,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
109
113
|
// We'll assume that if there is no builtins scope provided, we must be
|
110
114
|
// binding the builtins module itself.
|
111
115
|
const isBuiltInModule = this._fileInfo.builtinsScope === undefined;
|
112
|
-
this._createNewScope(isBuiltInModule ? 4 /* Builtin */ : 3 /* Module */, this._fileInfo.builtinsScope, () => {
|
116
|
+
this._createNewScope(isBuiltInModule ? 4 /* ScopeType.Builtin */ : 3 /* ScopeType.Module */, this._fileInfo.builtinsScope, () => {
|
113
117
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
114
118
|
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode);
|
115
119
|
// Bind implicit names.
|
@@ -201,13 +205,13 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
201
205
|
}
|
202
206
|
// A source file was found, but the type stub was missing.
|
203
207
|
if (!importResult.isStubFile &&
|
204
|
-
importResult.importType === 1 /* ThirdParty */ &&
|
208
|
+
importResult.importType === 1 /* ImportType.ThirdParty */ &&
|
205
209
|
!importResult.pyTypedInfo) {
|
206
210
|
const diagnostic = this._addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingTypeStubs, diagnosticRules_1.DiagnosticRule.reportMissingTypeStubs, localize_1.Localizer.Diagnostic.stubFileMissing().format({ importName: importResult.importName }), node);
|
207
211
|
if (diagnostic) {
|
208
212
|
// Add a diagnostic action for resolving this diagnostic.
|
209
213
|
const createTypeStubAction = {
|
210
|
-
action: "pyright.createtypestub" /* createTypeStub */,
|
214
|
+
action: "pyright.createtypestub" /* Commands.createTypeStub */,
|
211
215
|
moduleName: importResult.importName,
|
212
216
|
};
|
213
217
|
diagnostic.addAction(createTypeStubAction);
|
@@ -218,7 +222,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
218
222
|
visitClass(node) {
|
219
223
|
this.walkMultiple(node.decorators);
|
220
224
|
const classDeclaration = {
|
221
|
-
type: 6 /* Class */,
|
225
|
+
type: 6 /* DeclarationType.Class */,
|
222
226
|
node,
|
223
227
|
path: this._fileInfo.filePath,
|
224
228
|
range: (0, positionUtils_1.convertTextRangeToRange)(node.name, this._fileInfo.lines),
|
@@ -235,7 +239,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
235
239
|
this.walk(node.typeParameters);
|
236
240
|
}
|
237
241
|
this.walkMultiple(node.arguments);
|
238
|
-
this._createNewScope(2 /* Class */, this._getNonClassParentScope(), () => {
|
242
|
+
this._createNewScope(2 /* ScopeType.Class */, this._getNonClassParentScope(), () => {
|
239
243
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
240
244
|
this._addImplicitSymbolToCurrentScope('__doc__', node, 'str | None');
|
241
245
|
this._addImplicitSymbolToCurrentScope('__module__', node, 'str');
|
@@ -261,7 +265,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
261
265
|
const symbol = this._bindNameToScope(this._currentScope, node.name);
|
262
266
|
const containingClassNode = ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true);
|
263
267
|
const functionDeclaration = {
|
264
|
-
type: 5 /* Function */,
|
268
|
+
type: 5 /* DeclarationType.Function */,
|
265
269
|
node,
|
266
270
|
isMethod: !!containingClassNode,
|
267
271
|
isGenerator: false,
|
@@ -301,7 +305,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
301
305
|
}
|
302
306
|
// Don't walk the body of the function until we're done analyzing
|
303
307
|
// the current scope.
|
304
|
-
this._createNewScope(1 /* Function */, this._getNonClassParentScope(), () => {
|
308
|
+
this._createNewScope(1 /* ScopeType.Function */, this._getNonClassParentScope(), () => {
|
305
309
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
306
310
|
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
307
311
|
if (enclosingClass) {
|
@@ -323,7 +327,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
323
327
|
}
|
324
328
|
if (symbol) {
|
325
329
|
const paramDeclaration = {
|
326
|
-
type: 2 /* Parameter */,
|
330
|
+
type: 2 /* DeclarationType.Parameter */,
|
327
331
|
node: paramNode,
|
328
332
|
path: this._fileInfo.filePath,
|
329
333
|
range: (0, positionUtils_1.convertTextRangeToRange)(paramNode, this._fileInfo.lines),
|
@@ -371,7 +375,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
371
375
|
this.walk(param.defaultValue);
|
372
376
|
}
|
373
377
|
});
|
374
|
-
this._createNewScope(1 /* Function */, this._getNonClassParentScope(), () => {
|
378
|
+
this._createNewScope(1 /* ScopeType.Function */, this._getNonClassParentScope(), () => {
|
375
379
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
376
380
|
this._deferBinding(() => {
|
377
381
|
// Create a start node for the lambda.
|
@@ -381,7 +385,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
381
385
|
const symbol = this._bindNameToScope(this._currentScope, paramNode.name);
|
382
386
|
if (symbol) {
|
383
387
|
const paramDeclaration = {
|
384
|
-
type: 2 /* Parameter */,
|
388
|
+
type: 2 /* DeclarationType.Parameter */,
|
385
389
|
node: paramNode,
|
386
390
|
path: this._fileInfo.filePath,
|
387
391
|
range: (0, positionUtils_1.convertTextRangeToRange)(paramNode, this._fileInfo.lines),
|
@@ -421,7 +425,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
421
425
|
// There are libraries that make extensive use of unannotated decorators,
|
422
426
|
// and this can lead to a performance issue when walking the control
|
423
427
|
// flow graph if we need to evaluate every decorator.
|
424
|
-
if (!ParseTreeUtils.isNodeContainedWithinNodeType(node, 13 /* Decorator */)) {
|
428
|
+
if (!ParseTreeUtils.isNodeContainedWithinNodeType(node, 13 /* ParseNodeType.Decorator */)) {
|
425
429
|
// Skip if we're in an 'Annotated' annotation because this creates
|
426
430
|
// problems for "No Return" return type analysis when annotation
|
427
431
|
// evaluation is deferred.
|
@@ -430,29 +434,29 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
430
434
|
}
|
431
435
|
}
|
432
436
|
// Is this an manipulation of dunder all?
|
433
|
-
if (this._currentScope.type === 3 /* Module */ &&
|
434
|
-
node.leftExpression.nodeType === 35 /* MemberAccess */ &&
|
435
|
-
node.leftExpression.leftExpression.nodeType === 38 /* Name */ &&
|
437
|
+
if (this._currentScope.type === 3 /* ScopeType.Module */ &&
|
438
|
+
node.leftExpression.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
|
439
|
+
node.leftExpression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
436
440
|
node.leftExpression.leftExpression.value === '__all__') {
|
437
441
|
let emitDunderAllWarning = true;
|
438
442
|
// Is this a call to "__all__.extend()"?
|
439
443
|
if (node.leftExpression.memberName.value === 'extend' && node.arguments.length === 1) {
|
440
444
|
const argExpr = node.arguments[0].valueExpression;
|
441
445
|
// Is this a call to "__all__.extend([<list>])"?
|
442
|
-
if (argExpr.nodeType === 31 /* List */) {
|
446
|
+
if (argExpr.nodeType === 31 /* ParseNodeType.List */) {
|
443
447
|
argExpr.entries.forEach((listEntryNode) => {
|
444
448
|
var _a, _b;
|
445
|
-
if (listEntryNode.nodeType === 48 /* StringList */ &&
|
449
|
+
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
446
450
|
listEntryNode.strings.length === 1 &&
|
447
|
-
listEntryNode.strings[0].nodeType === 49 /* String */) {
|
451
|
+
listEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
448
452
|
(_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.push(listEntryNode.strings[0].value);
|
449
453
|
(_b = this._dunderAllStringNodes) === null || _b === void 0 ? void 0 : _b.push(listEntryNode.strings[0]);
|
450
454
|
emitDunderAllWarning = false;
|
451
455
|
}
|
452
456
|
});
|
453
457
|
}
|
454
|
-
else if (argExpr.nodeType === 35 /* MemberAccess */ &&
|
455
|
-
argExpr.leftExpression.nodeType === 38 /* Name */ &&
|
458
|
+
else if (argExpr.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
|
459
|
+
argExpr.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
456
460
|
argExpr.memberName.value === '__all__') {
|
457
461
|
// Is this a call to "__all__.extend(<mod>.__all__)"?
|
458
462
|
const namesToAdd = this._getDunderAllNamesFromImport(argExpr.leftExpression.value);
|
@@ -468,9 +472,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
468
472
|
else if (node.leftExpression.memberName.value === 'remove' && node.arguments.length === 1) {
|
469
473
|
// Is this a call to "__all__.remove()"?
|
470
474
|
const argExpr = node.arguments[0].valueExpression;
|
471
|
-
if (argExpr.nodeType === 48 /* StringList */ &&
|
475
|
+
if (argExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
|
472
476
|
argExpr.strings.length === 1 &&
|
473
|
-
argExpr.strings[0].nodeType === 49 /* String */ &&
|
477
|
+
argExpr.strings[0].nodeType === 49 /* ParseNodeType.String */ &&
|
474
478
|
this._dunderAllNames) {
|
475
479
|
this._dunderAllNames = this._dunderAllNames.filter((name) => name !== argExpr.strings[0].value);
|
476
480
|
this._dunderAllStringNodes = this._dunderAllStringNodes.filter((node) => node.value !== argExpr.strings[0].value);
|
@@ -480,9 +484,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
480
484
|
else if (node.leftExpression.memberName.value === 'append' && node.arguments.length === 1) {
|
481
485
|
// Is this a call to "__all__.append()"?
|
482
486
|
const argExpr = node.arguments[0].valueExpression;
|
483
|
-
if (argExpr.nodeType === 48 /* StringList */ &&
|
487
|
+
if (argExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
|
484
488
|
argExpr.strings.length === 1 &&
|
485
|
-
argExpr.strings[0].nodeType === 49 /* String */) {
|
489
|
+
argExpr.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
486
490
|
(_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.push(argExpr.strings[0].value);
|
487
491
|
(_b = this._dunderAllStringNodes) === null || _b === void 0 ? void 0 : _b.push(argExpr.strings[0]);
|
488
492
|
emitDunderAllWarning = false;
|
@@ -503,9 +507,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
503
507
|
});
|
504
508
|
node.parameters.forEach((param) => {
|
505
509
|
const name = param.name;
|
506
|
-
const symbol = new symbol_1.Symbol(0 /* None */);
|
510
|
+
const symbol = new symbol_1.Symbol(0 /* SymbolFlags.None */);
|
507
511
|
const paramDeclaration = {
|
508
|
-
type: 3 /* TypeParameter */,
|
512
|
+
type: 3 /* DeclarationType.TypeParameter */,
|
509
513
|
node: param,
|
510
514
|
path: this._fileInfo.filePath,
|
511
515
|
range: (0, positionUtils_1.convertTextRangeToRange)(node, this._fileInfo.lines),
|
@@ -536,7 +540,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
536
540
|
this.walk(node.typeParameters);
|
537
541
|
}
|
538
542
|
const typeAliasDeclaration = {
|
539
|
-
type: 4 /* TypeAlias */,
|
543
|
+
type: 4 /* DeclarationType.TypeAlias */,
|
540
544
|
node,
|
541
545
|
path: this._fileInfo.filePath,
|
542
546
|
range: (0, positionUtils_1.convertTextRangeToRange)(node.name, this._fileInfo.lines),
|
@@ -571,11 +575,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
571
575
|
// If the assignment target base expression is potentially a
|
572
576
|
// TypedDict, add the base expression to the flow expressions set
|
573
577
|
// to accommodate TypedDict type narrowing.
|
574
|
-
if (node.leftExpression.nodeType === 24 /* Index */) {
|
578
|
+
if (node.leftExpression.nodeType === 24 /* ParseNodeType.Index */) {
|
575
579
|
const target = node.leftExpression;
|
576
580
|
if (target.items.length === 1 &&
|
577
581
|
!target.trailingComma &&
|
578
|
-
target.items[0].valueExpression.nodeType === 48 /* StringList */) {
|
582
|
+
target.items[0].valueExpression.nodeType === 48 /* ParseNodeType.StringList */) {
|
579
583
|
if ((0, codeFlowTypes_1.isCodeFlowSupportedForReference)(target.baseExpression)) {
|
580
584
|
const baseExprReferenceKey = (0, codeFlowTypes_1.createKeyForReference)(target.baseExpression);
|
581
585
|
this._currentScopeCodeFlowExpressions.add(baseExprReferenceKey);
|
@@ -589,7 +593,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
589
593
|
// or as class variables, not as local variables within a function.
|
590
594
|
isPossibleTypeAlias = false;
|
591
595
|
}
|
592
|
-
else if (node.rightExpression.nodeType === 9 /* Call */ && this._fileInfo.isTypingStubFile) {
|
596
|
+
else if (node.rightExpression.nodeType === 9 /* ParseNodeType.Call */ && this._fileInfo.isTypingStubFile) {
|
593
597
|
// Some special built-in types defined in typing.pyi use
|
594
598
|
// assignments of the form List = _Alias(). We don't want to
|
595
599
|
// treat these as type aliases.
|
@@ -603,19 +607,19 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
603
607
|
// If we didn't create assignment target flow nodes above, do so now.
|
604
608
|
this._createAssignmentTargetFlowNodes(node.leftExpression, /* walkTargets */ true, /* unbound */ false);
|
605
609
|
// Is this an assignment to dunder all?
|
606
|
-
if (this._currentScope.type === 3 /* Module */) {
|
607
|
-
if ((node.leftExpression.nodeType === 38 /* Name */ && node.leftExpression.value === '__all__') ||
|
608
|
-
(node.leftExpression.nodeType === 54 /* TypeAnnotation */ &&
|
609
|
-
node.leftExpression.valueExpression.nodeType === 38 /* Name */ &&
|
610
|
+
if (this._currentScope.type === 3 /* ScopeType.Module */) {
|
611
|
+
if ((node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && node.leftExpression.value === '__all__') ||
|
612
|
+
(node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */ &&
|
613
|
+
node.leftExpression.valueExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
610
614
|
node.leftExpression.valueExpression.value === '__all__')) {
|
611
615
|
const expr = node.rightExpression;
|
612
616
|
this._dunderAllNames = [];
|
613
617
|
let emitDunderAllWarning = false;
|
614
|
-
if (expr.nodeType === 31 /* List */) {
|
618
|
+
if (expr.nodeType === 31 /* ParseNodeType.List */) {
|
615
619
|
expr.entries.forEach((listEntryNode) => {
|
616
|
-
if (listEntryNode.nodeType === 48 /* StringList */ &&
|
620
|
+
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
617
621
|
listEntryNode.strings.length === 1 &&
|
618
|
-
listEntryNode.strings[0].nodeType === 49 /* String */) {
|
622
|
+
listEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
619
623
|
this._dunderAllNames.push(listEntryNode.strings[0].value);
|
620
624
|
this._dunderAllStringNodes.push(listEntryNode.strings[0]);
|
621
625
|
}
|
@@ -624,11 +628,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
624
628
|
}
|
625
629
|
});
|
626
630
|
}
|
627
|
-
else if (expr.nodeType === 52 /* Tuple */) {
|
631
|
+
else if (expr.nodeType === 52 /* ParseNodeType.Tuple */) {
|
628
632
|
expr.expressions.forEach((tupleEntryNode) => {
|
629
|
-
if (tupleEntryNode.nodeType === 48 /* StringList */ &&
|
633
|
+
if (tupleEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
630
634
|
tupleEntryNode.strings.length === 1 &&
|
631
|
-
tupleEntryNode.strings[0].nodeType === 49 /* String */) {
|
635
|
+
tupleEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
632
636
|
this._dunderAllNames.push(tupleEntryNode.strings[0].value);
|
633
637
|
this._dunderAllStringNodes.push(tupleEntryNode.strings[0]);
|
634
638
|
}
|
@@ -647,22 +651,22 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
647
651
|
}
|
648
652
|
}
|
649
653
|
// Is this an assignment to dunder slots?
|
650
|
-
if (this._currentScope.type === 2 /* Class */) {
|
651
|
-
if ((node.leftExpression.nodeType === 38 /* Name */ && node.leftExpression.value === '__slots__') ||
|
652
|
-
(node.leftExpression.nodeType === 54 /* TypeAnnotation */ &&
|
653
|
-
node.leftExpression.valueExpression.nodeType === 38 /* Name */ &&
|
654
|
+
if (this._currentScope.type === 2 /* ScopeType.Class */) {
|
655
|
+
if ((node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && node.leftExpression.value === '__slots__') ||
|
656
|
+
(node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */ &&
|
657
|
+
node.leftExpression.valueExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
654
658
|
node.leftExpression.valueExpression.value === '__slots__')) {
|
655
659
|
const expr = node.rightExpression;
|
656
660
|
this._dunderSlotsEntries = [];
|
657
661
|
let isExpressionUnderstood = true;
|
658
|
-
if (expr.nodeType === 48 /* StringList */) {
|
662
|
+
if (expr.nodeType === 48 /* ParseNodeType.StringList */) {
|
659
663
|
this._dunderSlotsEntries.push(expr);
|
660
664
|
}
|
661
|
-
else if (expr.nodeType === 31 /* List */) {
|
665
|
+
else if (expr.nodeType === 31 /* ParseNodeType.List */) {
|
662
666
|
expr.entries.forEach((listEntryNode) => {
|
663
|
-
if (listEntryNode.nodeType === 48 /* StringList */ &&
|
667
|
+
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
664
668
|
listEntryNode.strings.length === 1 &&
|
665
|
-
listEntryNode.strings[0].nodeType === 49 /* String */) {
|
669
|
+
listEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
666
670
|
this._dunderSlotsEntries.push(listEntryNode);
|
667
671
|
}
|
668
672
|
else {
|
@@ -670,11 +674,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
670
674
|
}
|
671
675
|
});
|
672
676
|
}
|
673
|
-
else if (expr.nodeType === 52 /* Tuple */) {
|
677
|
+
else if (expr.nodeType === 52 /* ParseNodeType.Tuple */) {
|
674
678
|
expr.expressions.forEach((tupleEntryNode) => {
|
675
|
-
if (tupleEntryNode.nodeType === 48 /* StringList */ &&
|
679
|
+
if (tupleEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
676
680
|
tupleEntryNode.strings.length === 1 &&
|
677
|
-
tupleEntryNode.strings[0].nodeType === 49 /* String */) {
|
681
|
+
tupleEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
678
682
|
this._dunderSlotsEntries.push(tupleEntryNode);
|
679
683
|
}
|
680
684
|
else {
|
@@ -735,27 +739,27 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
735
739
|
this._createAssignmentTargetFlowNodes(node.destExpression, /* walkTargets */ false, /* unbound */ false);
|
736
740
|
// Is this an assignment to dunder all of the form
|
737
741
|
// __all__ += <expression>?
|
738
|
-
if (node.operator === 1 /* AddEqual */ &&
|
739
|
-
this._currentScope.type === 3 /* Module */ &&
|
740
|
-
node.leftExpression.nodeType === 38 /* Name */ &&
|
742
|
+
if (node.operator === 1 /* OperatorType.AddEqual */ &&
|
743
|
+
this._currentScope.type === 3 /* ScopeType.Module */ &&
|
744
|
+
node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
741
745
|
node.leftExpression.value === '__all__') {
|
742
746
|
const expr = node.rightExpression;
|
743
747
|
let emitDunderAllWarning = true;
|
744
|
-
if (expr.nodeType === 31 /* List */) {
|
748
|
+
if (expr.nodeType === 31 /* ParseNodeType.List */) {
|
745
749
|
// Is this the form __all__ += ["a", "b"]?
|
746
750
|
expr.entries.forEach((listEntryNode) => {
|
747
751
|
var _a;
|
748
|
-
if (listEntryNode.nodeType === 48 /* StringList */ &&
|
752
|
+
if (listEntryNode.nodeType === 48 /* ParseNodeType.StringList */ &&
|
749
753
|
listEntryNode.strings.length === 1 &&
|
750
|
-
listEntryNode.strings[0].nodeType === 49 /* String */) {
|
754
|
+
listEntryNode.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
751
755
|
(_a = this._dunderAllNames) === null || _a === void 0 ? void 0 : _a.push(listEntryNode.strings[0].value);
|
752
756
|
this._dunderAllStringNodes.push(listEntryNode.strings[0]);
|
753
757
|
}
|
754
758
|
});
|
755
759
|
emitDunderAllWarning = false;
|
756
760
|
}
|
757
|
-
else if (expr.nodeType === 35 /* MemberAccess */ &&
|
758
|
-
expr.leftExpression.nodeType === 38 /* Name */ &&
|
761
|
+
else if (expr.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
|
762
|
+
expr.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
759
763
|
expr.memberName.value === '__all__') {
|
760
764
|
// Is this using the form "__all__ += <mod>.__all__"?
|
761
765
|
const namesToAdd = this._getDunderAllNamesFromImport(expr.leftExpression.value);
|
@@ -789,7 +793,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
789
793
|
}
|
790
794
|
// If this is an annotated variable assignment within a class body,
|
791
795
|
// we need to evaluate the type annotation first.
|
792
|
-
const bindVariableBeforeAnnotationEvaluation = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* Assignment */ &&
|
796
|
+
const bindVariableBeforeAnnotationEvaluation = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* ParseNodeType.Assignment */ &&
|
793
797
|
ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true) !== undefined;
|
794
798
|
if (!bindVariableBeforeAnnotationEvaluation) {
|
795
799
|
this.walk(node.typeAnnotation);
|
@@ -1009,7 +1013,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1009
1013
|
this._createAssignmentTargetFlowNodes(node.name, /* walkTargets */ true, /* unbound */ false);
|
1010
1014
|
if (symbol) {
|
1011
1015
|
const declaration = {
|
1012
|
-
type: 1 /* Variable */,
|
1016
|
+
type: 1 /* DeclarationType.Variable */,
|
1013
1017
|
node: node.name,
|
1014
1018
|
isConstant: (0, symbolNameUtils_1.isConstantName)(node.name.value),
|
1015
1019
|
inferredTypeSource: node,
|
@@ -1183,7 +1187,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1183
1187
|
// Allow if it's within a generator expression. Execution of
|
1184
1188
|
// generator expressions is deferred and therefore can be
|
1185
1189
|
// run within the context of an async function later.
|
1186
|
-
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== 32 /* ListComprehension */) {
|
1190
|
+
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== 32 /* ParseNodeType.ListComprehension */) {
|
1187
1191
|
this._addError(localize_1.Localizer.Diagnostic.awaitNotInAsync(), node);
|
1188
1192
|
}
|
1189
1193
|
}
|
@@ -1194,7 +1198,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1194
1198
|
node.nameList.forEach((name) => {
|
1195
1199
|
const nameValue = name.value;
|
1196
1200
|
// Is the binding inconsistent?
|
1197
|
-
if (this._currentScope.getBindingType(nameValue) === 0 /* Nonlocal */) {
|
1201
|
+
if (this._currentScope.getBindingType(nameValue) === 0 /* NameBindingType.Nonlocal */) {
|
1198
1202
|
this._addError(localize_1.Localizer.Diagnostic.nonLocalRedefinition().format({ name: nameValue }), name);
|
1199
1203
|
}
|
1200
1204
|
const valueWithScope = this._currentScope.lookUpSymbolRecursive(nameValue);
|
@@ -1205,7 +1209,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1205
1209
|
// Add it to the global scope if it's not already added.
|
1206
1210
|
this._bindNameToScope(globalScope, name);
|
1207
1211
|
if (this._currentScope !== globalScope) {
|
1208
|
-
this._currentScope.setBindingType(nameValue, 1 /* Global */);
|
1212
|
+
this._currentScope.setBindingType(nameValue, 1 /* NameBindingType.Global */);
|
1209
1213
|
}
|
1210
1214
|
});
|
1211
1215
|
return true;
|
@@ -1219,7 +1223,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1219
1223
|
node.nameList.forEach((name) => {
|
1220
1224
|
const nameValue = name.value;
|
1221
1225
|
// Is the binding inconsistent?
|
1222
|
-
if (this._currentScope.getBindingType(nameValue) === 1 /* Global */) {
|
1226
|
+
if (this._currentScope.getBindingType(nameValue) === 1 /* NameBindingType.Global */) {
|
1223
1227
|
this._addError(localize_1.Localizer.Diagnostic.globalRedefinition().format({ name: nameValue }), name);
|
1224
1228
|
}
|
1225
1229
|
const valueWithScope = this._currentScope.lookUpSymbolRecursive(nameValue);
|
@@ -1231,7 +1235,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1231
1235
|
this._addError(localize_1.Localizer.Diagnostic.nonLocalNoBinding().format({ name: nameValue }), name);
|
1232
1236
|
}
|
1233
1237
|
if (valueWithScope) {
|
1234
|
-
this._currentScope.setBindingType(nameValue, 0 /* Nonlocal */);
|
1238
|
+
this._currentScope.setBindingType(nameValue, 0 /* NameBindingType.Nonlocal */);
|
1235
1239
|
}
|
1236
1240
|
});
|
1237
1241
|
}
|
@@ -1256,7 +1260,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1256
1260
|
}
|
1257
1261
|
const symbol = this._bindNameToScope(this._currentScope, symbolNameNode);
|
1258
1262
|
if (symbol &&
|
1259
|
-
(this._currentScope.type === 3 /* Module */ || this._currentScope.type === 4 /* Builtin */) &&
|
1263
|
+
(this._currentScope.type === 3 /* ScopeType.Module */ || this._currentScope.type === 4 /* ScopeType.Builtin */) &&
|
1260
1264
|
(!node.alias ||
|
1261
1265
|
node.module.nameParts.length !== 1 ||
|
1262
1266
|
node.module.nameParts[0].value !== node.alias.value)) {
|
@@ -1347,7 +1351,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1347
1351
|
// alias it.
|
1348
1352
|
if (importedSymbol) {
|
1349
1353
|
const aliasDecl = {
|
1350
|
-
type: 8 /* Alias */,
|
1354
|
+
type: 8 /* DeclarationType.Alias */,
|
1351
1355
|
node,
|
1352
1356
|
path: resolvedPath,
|
1353
1357
|
loadSymbolsFromPath: true,
|
@@ -1367,7 +1371,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1367
1371
|
const implicitImport = importInfo.filteredImplicitImports.get(name);
|
1368
1372
|
if (implicitImport) {
|
1369
1373
|
const submoduleFallback = {
|
1370
|
-
type: 8 /* Alias */,
|
1374
|
+
type: 8 /* DeclarationType.Alias */,
|
1371
1375
|
node,
|
1372
1376
|
path: implicitImport.path,
|
1373
1377
|
loadSymbolsFromPath: true,
|
@@ -1377,7 +1381,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1377
1381
|
isInExceptSuite: this._isInExceptSuite,
|
1378
1382
|
};
|
1379
1383
|
const aliasDecl = {
|
1380
|
-
type: 8 /* Alias */,
|
1384
|
+
type: 8 /* DeclarationType.Alias */,
|
1381
1385
|
node,
|
1382
1386
|
path: resolvedPath,
|
1383
1387
|
loadSymbolsFromPath: true,
|
@@ -1422,8 +1426,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1422
1426
|
// All import statements of the form `from . import x` treat x
|
1423
1427
|
// as an externally-visible (not hidden) symbol.
|
1424
1428
|
if (node.module.nameParts.length > 0) {
|
1425
|
-
if (this._currentScope.type === 3 /* Module */ ||
|
1426
|
-
this._currentScope.type === 4 /* Builtin */) {
|
1429
|
+
if (this._currentScope.type === 3 /* ScopeType.Module */ ||
|
1430
|
+
this._currentScope.type === 4 /* ScopeType.Builtin */) {
|
1427
1431
|
if (!importSymbolNode.alias ||
|
1428
1432
|
importSymbolNode.alias.value !== importSymbolNode.name.value) {
|
1429
1433
|
if (this._fileInfo.isStubFile || this._fileInfo.isInPyTypedPackage) {
|
@@ -1445,7 +1449,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1445
1449
|
let loadSymbolsFromPath = true;
|
1446
1450
|
if (implicitImport) {
|
1447
1451
|
submoduleFallback = {
|
1448
|
-
type: 8 /* Alias */,
|
1452
|
+
type: 8 /* DeclarationType.Alias */,
|
1449
1453
|
node: importSymbolNode,
|
1450
1454
|
path: implicitImport.path,
|
1451
1455
|
loadSymbolsFromPath: true,
|
@@ -1469,7 +1473,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1469
1473
|
}
|
1470
1474
|
}
|
1471
1475
|
const aliasDecl = {
|
1472
|
-
type: 8 /* Alias */,
|
1476
|
+
type: 8 /* DeclarationType.Alias */,
|
1473
1477
|
node: importSymbolNode,
|
1474
1478
|
path: resolvedPath,
|
1475
1479
|
loadSymbolsFromPath,
|
@@ -1583,7 +1587,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1583
1587
|
return false;
|
1584
1588
|
}
|
1585
1589
|
visitUnaryOperation(node) {
|
1586
|
-
if (node.operator === 38 /* Not */ && this._currentFalseTarget && this._currentTrueTarget) {
|
1590
|
+
if (node.operator === 38 /* OperatorType.Not */ && this._currentFalseTarget && this._currentTrueTarget) {
|
1587
1591
|
// Swap the existing true/false targets.
|
1588
1592
|
this._bindConditional(node.expression, this._currentFalseTarget, this._currentTrueTarget);
|
1589
1593
|
}
|
@@ -1599,7 +1603,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1599
1603
|
return false;
|
1600
1604
|
}
|
1601
1605
|
visitBinaryOperation(node) {
|
1602
|
-
if (node.operator === 36 /* And */ || node.operator === 37 /* Or */) {
|
1606
|
+
if (node.operator === 36 /* OperatorType.And */ || node.operator === 37 /* OperatorType.Or */) {
|
1603
1607
|
let trueTarget = this._currentTrueTarget;
|
1604
1608
|
let falseTarget = this._currentFalseTarget;
|
1605
1609
|
let postRightLabel;
|
@@ -1608,7 +1612,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1608
1612
|
trueTarget = falseTarget = postRightLabel;
|
1609
1613
|
}
|
1610
1614
|
const preRightLabel = this._createBranchLabel();
|
1611
|
-
if (node.operator === 36 /* And */) {
|
1615
|
+
if (node.operator === 36 /* OperatorType.And */) {
|
1612
1616
|
this._bindConditional(node.leftExpression, preRightLabel, falseTarget);
|
1613
1617
|
}
|
1614
1618
|
else {
|
@@ -1634,10 +1638,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1634
1638
|
visitListComprehension(node) {
|
1635
1639
|
const enclosingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
1636
1640
|
// The first iterable is executed outside of the comprehension scope.
|
1637
|
-
if (node.forIfNodes.length > 0 && node.forIfNodes[0].nodeType === 33 /* ListComprehensionFor */) {
|
1641
|
+
if (node.forIfNodes.length > 0 && node.forIfNodes[0].nodeType === 33 /* ParseNodeType.ListComprehensionFor */) {
|
1638
1642
|
this.walk(node.forIfNodes[0].iterableExpression);
|
1639
1643
|
}
|
1640
|
-
this._createNewScope(0 /* ListComprehension */, this._getNonClassParentScope(), () => {
|
1644
|
+
this._createNewScope(0 /* ScopeType.ListComprehension */, this._getNonClassParentScope(), () => {
|
1641
1645
|
var _a;
|
1642
1646
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
1643
1647
|
const falseLabel = this._createBranchLabel();
|
@@ -1647,7 +1651,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1647
1651
|
for (let i = 0; i < node.forIfNodes.length; i++) {
|
1648
1652
|
const compr = node.forIfNodes[i];
|
1649
1653
|
const addedSymbols = new Map();
|
1650
|
-
if (compr.nodeType === 33 /* ListComprehensionFor */) {
|
1654
|
+
if (compr.nodeType === 33 /* ParseNodeType.ListComprehensionFor */) {
|
1651
1655
|
this._bindPossibleTupleNamedTarget(compr.targetExpression, addedSymbols);
|
1652
1656
|
this._addInferredTypeAssignmentForVariable(compr.targetExpression, compr);
|
1653
1657
|
// Async for is not allowed outside of an async function
|
@@ -1657,7 +1661,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1657
1661
|
// Allow if it's within a generator expression. Execution of
|
1658
1662
|
// generator expressions is deferred and therefore can be
|
1659
1663
|
// run within the context of an async function later.
|
1660
|
-
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 31 /* List */) {
|
1664
|
+
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 31 /* ParseNodeType.List */) {
|
1661
1665
|
this._addError(localize_1.Localizer.Diagnostic.asyncNotInAsyncFunction(), compr.asyncToken);
|
1662
1666
|
}
|
1663
1667
|
}
|
@@ -1666,7 +1670,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1666
1670
|
}
|
1667
1671
|
for (let i = 0; i < node.forIfNodes.length; i++) {
|
1668
1672
|
const compr = node.forIfNodes[i];
|
1669
|
-
if (compr.nodeType === 33 /* ListComprehensionFor */) {
|
1673
|
+
if (compr.nodeType === 33 /* ParseNodeType.ListComprehensionFor */) {
|
1670
1674
|
// We already walked the first iterable expression above,
|
1671
1675
|
// so skip it here.
|
1672
1676
|
if (i !== 0) {
|
@@ -1761,7 +1765,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1761
1765
|
this._createAssignmentTargetFlowNodes(node.target, /* walkTargets */ false, /* unbound */ false);
|
1762
1766
|
if (symbol) {
|
1763
1767
|
const declaration = {
|
1764
|
-
type: 1 /* Variable */,
|
1768
|
+
type: 1 /* DeclarationType.Variable */,
|
1765
1769
|
node: node.target,
|
1766
1770
|
isConstant: (0, symbolNameUtils_1.isConstantName)(node.target.value),
|
1767
1771
|
inferredTypeSource: node,
|
@@ -1796,7 +1800,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1796
1800
|
const entry = this._activeTypeParams.get(typeParamNode.name.value);
|
1797
1801
|
if (entry) {
|
1798
1802
|
const decls = entry.getDeclarations();
|
1799
|
-
(0, debug_1.assert)(decls && decls.length === 1 && decls[0].type === 3 /* TypeParameter */);
|
1803
|
+
(0, debug_1.assert)(decls && decls.length === 1 && decls[0].type === 3 /* DeclarationType.TypeParameter */);
|
1800
1804
|
if (decls[0].node === typeParamNode) {
|
1801
1805
|
this._activeTypeParams.delete(typeParamNode.name.value);
|
1802
1806
|
}
|
@@ -1807,13 +1811,13 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1807
1811
|
// We may not be able to use the current scope if it's a class scope.
|
1808
1812
|
// Walk up until we find a non-class scope instead.
|
1809
1813
|
let parentScope = this._currentScope;
|
1810
|
-
while (parentScope.type === 2 /* Class */) {
|
1814
|
+
while (parentScope.type === 2 /* ScopeType.Class */) {
|
1811
1815
|
parentScope = parentScope.parent;
|
1812
1816
|
}
|
1813
1817
|
return parentScope;
|
1814
1818
|
}
|
1815
1819
|
_addSlotsToCurrentScope(slotNameNodes) {
|
1816
|
-
(0, debug_1.assert)(this._currentScope.type === 2 /* Class */);
|
1820
|
+
(0, debug_1.assert)(this._currentScope.type === 2 /* ScopeType.Class */);
|
1817
1821
|
let slotsContainsDict = false;
|
1818
1822
|
for (const slotNameNode of slotNameNodes) {
|
1819
1823
|
const slotName = slotNameNode.strings[0].value;
|
@@ -1823,14 +1827,14 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1823
1827
|
}
|
1824
1828
|
let symbol = this._currentScope.lookUpSymbol(slotName);
|
1825
1829
|
if (!symbol) {
|
1826
|
-
symbol = this._currentScope.addSymbol(slotName, 1 /* InitiallyUnbound */ | 4 /* ClassMember */);
|
1830
|
+
symbol = this._currentScope.addSymbol(slotName, 1 /* SymbolFlags.InitiallyUnbound */ | 4 /* SymbolFlags.ClassMember */);
|
1827
1831
|
const honorPrivateNaming = this._fileInfo.diagnosticRuleSet.reportPrivateUsage !== 'none';
|
1828
1832
|
if ((0, symbolNameUtils_1.isPrivateOrProtectedName)(slotName) && honorPrivateNaming) {
|
1829
1833
|
symbol.setIsPrivateMember();
|
1830
1834
|
}
|
1831
1835
|
}
|
1832
1836
|
const declaration = {
|
1833
|
-
type: 1 /* Variable */,
|
1837
|
+
type: 1 /* DeclarationType.Variable */,
|
1834
1838
|
node: slotNameNode,
|
1835
1839
|
isConstant: (0, symbolNameUtils_1.isConstantName)(slotName),
|
1836
1840
|
isDefinedBySlots: true,
|
@@ -1850,10 +1854,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1850
1854
|
let prevNode;
|
1851
1855
|
let prevPrevNode;
|
1852
1856
|
while (curNode) {
|
1853
|
-
if (curNode.nodeType === 32 /* ListComprehension */) {
|
1857
|
+
if (curNode.nodeType === 32 /* ParseNodeType.ListComprehension */) {
|
1854
1858
|
if (ignoreOutermostIterable && curNode.forIfNodes.length > 0) {
|
1855
1859
|
const outermostCompr = curNode.forIfNodes[0];
|
1856
|
-
if (prevNode === outermostCompr && outermostCompr.nodeType === 33 /* ListComprehensionFor */) {
|
1860
|
+
if (prevNode === outermostCompr && outermostCompr.nodeType === 33 /* ParseNodeType.ListComprehensionFor */) {
|
1857
1861
|
if (prevPrevNode === outermostCompr.iterableExpression) {
|
1858
1862
|
return false;
|
1859
1863
|
}
|
@@ -1872,7 +1876,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1872
1876
|
this._createAssignmentTargetFlowNodes(target, /* walkTargets */ false, /* unbound */ false);
|
1873
1877
|
if (symbol) {
|
1874
1878
|
const declaration = {
|
1875
|
-
type: 1 /* Variable */,
|
1879
|
+
type: 1 /* DeclarationType.Variable */,
|
1876
1880
|
node: target,
|
1877
1881
|
isConstant: (0, symbolNameUtils_1.isConstantName)(target.value),
|
1878
1882
|
inferredTypeSource: target.parent,
|
@@ -1899,7 +1903,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1899
1903
|
return undefined;
|
1900
1904
|
}
|
1901
1905
|
// There should be only one declaration for the variable.
|
1902
|
-
const aliasDecl = varSymbol.getDeclarations().find((decl) => decl.type === 8 /* Alias */);
|
1906
|
+
const aliasDecl = varSymbol.getDeclarations().find((decl) => decl.type === 8 /* DeclarationType.Alias */);
|
1903
1907
|
const resolvedPath = (aliasDecl === null || aliasDecl === void 0 ? void 0 : aliasDecl.path) && aliasDecl.loadSymbolsFromPath
|
1904
1908
|
? aliasDecl.path
|
1905
1909
|
: ((_a = aliasDecl === null || aliasDecl === void 0 ? void 0 : aliasDecl.submoduleFallback) === null || _a === void 0 ? void 0 : _a.path) && aliasDecl.submoduleFallback.loadSymbolsFromPath
|
@@ -1939,7 +1943,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1939
1943
|
// python module loader.
|
1940
1944
|
const existingDecl = symbol
|
1941
1945
|
.getDeclarations()
|
1942
|
-
.find((decl) => decl.type === 8 /* Alias */ && decl.firstNamePart === firstNamePartValue);
|
1946
|
+
.find((decl) => decl.type === 8 /* DeclarationType.Alias */ && decl.firstNamePart === firstNamePartValue);
|
1943
1947
|
let newDecl;
|
1944
1948
|
let pathOfLastSubmodule;
|
1945
1949
|
if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib && importInfo.resolvedPaths.length > 0) {
|
@@ -1954,7 +1958,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1954
1958
|
}
|
1955
1959
|
else if (isResolved) {
|
1956
1960
|
newDecl = {
|
1957
|
-
type: 8 /* Alias */,
|
1961
|
+
type: 8 /* DeclarationType.Alias */,
|
1958
1962
|
node,
|
1959
1963
|
path: pathOfLastSubmodule,
|
1960
1964
|
loadSymbolsFromPath: false,
|
@@ -1970,7 +1974,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1970
1974
|
// bogus path so it gets an unknown type (rather than an unbound type) at
|
1971
1975
|
// analysis time.
|
1972
1976
|
newDecl = {
|
1973
|
-
type: 8 /* Alias */,
|
1977
|
+
type: 8 /* DeclarationType.Alias */,
|
1974
1978
|
node,
|
1975
1979
|
path: pathOfLastSubmodule,
|
1976
1980
|
loadSymbolsFromPath: true,
|
@@ -2172,12 +2176,12 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2172
2176
|
// positive or negative case).
|
2173
2177
|
_bindNeverCondition(node, target, isPositiveTest) {
|
2174
2178
|
const expressionList = [];
|
2175
|
-
if (node.nodeType === 55 /* UnaryOperation */ && node.operator === 38 /* Not */) {
|
2179
|
+
if (node.nodeType === 55 /* ParseNodeType.UnaryOperation */ && node.operator === 38 /* OperatorType.Not */) {
|
2176
2180
|
this._bindNeverCondition(node.expression, target, !isPositiveTest);
|
2177
2181
|
}
|
2178
|
-
else if (node.nodeType === 7 /* BinaryOperation */ &&
|
2179
|
-
(node.operator === 36 /* And */ || node.operator === 37 /* Or */)) {
|
2180
|
-
let isAnd = node.operator === 36 /* And */;
|
2182
|
+
else if (node.nodeType === 7 /* ParseNodeType.BinaryOperation */ &&
|
2183
|
+
(node.operator === 36 /* OperatorType.And */ || node.operator === 37 /* OperatorType.Or */)) {
|
2184
|
+
let isAnd = node.operator === 36 /* OperatorType.And */;
|
2181
2185
|
if (isPositiveTest) {
|
2182
2186
|
isAnd = !isAnd;
|
2183
2187
|
}
|
@@ -2214,7 +2218,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2214
2218
|
// that is a name. This avoids complexities with composite expressions like
|
2215
2219
|
// member access or index expressions.
|
2216
2220
|
if (this._isNarrowingExpression(node, expressionList, /* neverNarrowingExpressions */ true)) {
|
2217
|
-
const filteredExprList = expressionList.filter((expr) => expr.nodeType === 38 /* Name */);
|
2221
|
+
const filteredExprList = expressionList.filter((expr) => expr.nodeType === 38 /* ParseNodeType.Name */);
|
2218
2222
|
if (filteredExprList.length > 0) {
|
2219
2223
|
this._currentFlowNode = this._createFlowConditional(isPositiveTest ? codeFlowTypes_1.FlowFlags.TrueNeverCondition : codeFlowTypes_1.FlowFlags.FalseNeverCondition, this._currentFlowNode, node);
|
2220
2224
|
}
|
@@ -2264,7 +2268,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2264
2268
|
this._currentScopeCodeFlowExpressions.add(referenceKey);
|
2265
2269
|
});
|
2266
2270
|
// Select the first name expression.
|
2267
|
-
const filteredExprList = expressionList.filter((expr) => expr.nodeType === 38 /* Name */);
|
2271
|
+
const filteredExprList = expressionList.filter((expr) => expr.nodeType === 38 /* ParseNodeType.Name */);
|
2268
2272
|
const conditionalFlowNode = {
|
2269
2273
|
flags,
|
2270
2274
|
id: this._getUniqueFlowNodeId(),
|
@@ -2278,11 +2282,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2278
2282
|
// Indicates whether the expression is a NOT, AND or OR expression.
|
2279
2283
|
_isLogicalExpression(expression) {
|
2280
2284
|
switch (expression.nodeType) {
|
2281
|
-
case 55 /* UnaryOperation */: {
|
2282
|
-
return expression.operator === 38 /* Not */;
|
2285
|
+
case 55 /* ParseNodeType.UnaryOperation */: {
|
2286
|
+
return expression.operator === 38 /* OperatorType.Not */;
|
2283
2287
|
}
|
2284
|
-
case 7 /* BinaryOperation */: {
|
2285
|
-
return expression.operator === 36 /* And */ || expression.operator === 37 /* Or */;
|
2288
|
+
case 7 /* ParseNodeType.BinaryOperation */: {
|
2289
|
+
return expression.operator === 36 /* OperatorType.And */ || expression.operator === 37 /* OperatorType.Or */;
|
2286
2290
|
}
|
2287
2291
|
}
|
2288
2292
|
return false;
|
@@ -2297,13 +2301,13 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2297
2301
|
// these) or something more complex (binary operator, call, etc.).
|
2298
2302
|
_isNarrowingExpression(expression, expressionList, filterForNeverNarrowing = false, isComplexExpression = false) {
|
2299
2303
|
switch (expression.nodeType) {
|
2300
|
-
case 38 /* Name */:
|
2301
|
-
case 35 /* MemberAccess */:
|
2302
|
-
case 24 /* Index */: {
|
2304
|
+
case 38 /* ParseNodeType.Name */:
|
2305
|
+
case 35 /* ParseNodeType.MemberAccess */:
|
2306
|
+
case 24 /* ParseNodeType.Index */: {
|
2303
2307
|
if (filterForNeverNarrowing) {
|
2304
2308
|
// Never narrowing doesn't support member access or index
|
2305
2309
|
// expressions.
|
2306
|
-
if (expression.nodeType !== 38 /* Name */) {
|
2310
|
+
if (expression.nodeType !== 38 /* ParseNodeType.Name */) {
|
2307
2311
|
return false;
|
2308
2312
|
}
|
2309
2313
|
// Never narrowing doesn't support simple names (falsy
|
@@ -2319,7 +2323,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2319
2323
|
// If the expression is a member access expression, add its
|
2320
2324
|
// leftExpression to the expression list because that expression
|
2321
2325
|
// can be narrowed based on the attribute type.
|
2322
|
-
if (expression.nodeType === 35 /* MemberAccess */) {
|
2326
|
+
if (expression.nodeType === 35 /* ParseNodeType.MemberAccess */) {
|
2323
2327
|
if ((0, codeFlowTypes_1.isCodeFlowSupportedForReference)(expression.leftExpression)) {
|
2324
2328
|
expressionList.push(expression.leftExpression);
|
2325
2329
|
}
|
@@ -2327,10 +2331,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2327
2331
|
// If the expression is an index expression with a supported
|
2328
2332
|
// subscript, add its baseExpression to the expression list because
|
2329
2333
|
// that expression can be narrowed.
|
2330
|
-
if (expression.nodeType === 24 /* Index */ &&
|
2334
|
+
if (expression.nodeType === 24 /* ParseNodeType.Index */ &&
|
2331
2335
|
expression.items.length === 1 &&
|
2332
2336
|
!expression.trailingComma &&
|
2333
|
-
expression.items[0].argumentCategory === 0 /* Simple */) {
|
2337
|
+
expression.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */) {
|
2334
2338
|
if ((0, codeFlowTypes_1.isCodeFlowSupportedForReference)(expression.baseExpression)) {
|
2335
2339
|
expressionList.push(expression.baseExpression);
|
2336
2340
|
}
|
@@ -2340,30 +2344,30 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2340
2344
|
}
|
2341
2345
|
return false;
|
2342
2346
|
}
|
2343
|
-
case 4 /* AssignmentExpression */: {
|
2347
|
+
case 4 /* ParseNodeType.AssignmentExpression */: {
|
2344
2348
|
expressionList.push(expression.name);
|
2345
2349
|
this._isNarrowingExpression(expression.rightExpression, expressionList, filterForNeverNarrowing,
|
2346
2350
|
/* isComplexExpression */ true);
|
2347
2351
|
return true;
|
2348
2352
|
}
|
2349
|
-
case 7 /* BinaryOperation */: {
|
2350
|
-
const isOrIsNotOperator = expression.operator === 39 /* Is */ || expression.operator === 40 /* IsNot */;
|
2351
|
-
const equalsOrNotEqualsOperator = expression.operator === 12 /* Equals */ || expression.operator === 28 /* NotEquals */;
|
2353
|
+
case 7 /* ParseNodeType.BinaryOperation */: {
|
2354
|
+
const isOrIsNotOperator = expression.operator === 39 /* OperatorType.Is */ || expression.operator === 40 /* OperatorType.IsNot */;
|
2355
|
+
const equalsOrNotEqualsOperator = expression.operator === 12 /* OperatorType.Equals */ || expression.operator === 28 /* OperatorType.NotEquals */;
|
2352
2356
|
if (isOrIsNotOperator || equalsOrNotEqualsOperator) {
|
2353
2357
|
// Look for "X is None", "X is not None", "X == None", "X != None".
|
2354
2358
|
// These are commonly-used patterns used in control flow.
|
2355
|
-
if (expression.rightExpression.nodeType === 11 /* Constant */ &&
|
2356
|
-
expression.rightExpression.constType === 26 /* None */) {
|
2359
|
+
if (expression.rightExpression.nodeType === 11 /* ParseNodeType.Constant */ &&
|
2360
|
+
expression.rightExpression.constType === 26 /* KeywordType.None */) {
|
2357
2361
|
return this._isNarrowingExpression(expression.leftExpression, expressionList, filterForNeverNarrowing,
|
2358
2362
|
/* isComplexExpression */ true);
|
2359
2363
|
}
|
2360
2364
|
// Look for "type(X) is Y" or "type(X) is not Y".
|
2361
2365
|
if (isOrIsNotOperator &&
|
2362
|
-
expression.leftExpression.nodeType === 9 /* Call */ &&
|
2363
|
-
expression.leftExpression.leftExpression.nodeType === 38 /* Name */ &&
|
2366
|
+
expression.leftExpression.nodeType === 9 /* ParseNodeType.Call */ &&
|
2367
|
+
expression.leftExpression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
2364
2368
|
expression.leftExpression.leftExpression.value === 'type' &&
|
2365
2369
|
expression.leftExpression.arguments.length === 1 &&
|
2366
|
-
expression.leftExpression.arguments[0].argumentCategory === 0 /* Simple */) {
|
2370
|
+
expression.leftExpression.arguments[0].argumentCategory === 0 /* ArgumentCategory.Simple */) {
|
2367
2371
|
return this._isNarrowingExpression(expression.leftExpression.arguments[0].valueExpression, expressionList, filterForNeverNarrowing,
|
2368
2372
|
/* isComplexExpression */ true);
|
2369
2373
|
}
|
@@ -2374,38 +2378,38 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2374
2378
|
return isLeftNarrowing;
|
2375
2379
|
}
|
2376
2380
|
// Look for "<string> in Y" or "<string> not in Y".
|
2377
|
-
if (expression.operator === 41 /* In */ || expression.operator === 42 /* NotIn */) {
|
2378
|
-
if (expression.leftExpression.nodeType === 48 /* StringList */ &&
|
2381
|
+
if (expression.operator === 41 /* OperatorType.In */ || expression.operator === 42 /* OperatorType.NotIn */) {
|
2382
|
+
if (expression.leftExpression.nodeType === 48 /* ParseNodeType.StringList */ &&
|
2379
2383
|
this._isNarrowingExpression(expression.rightExpression, expressionList, filterForNeverNarrowing,
|
2380
2384
|
/* isComplexExpression */ true)) {
|
2381
2385
|
return true;
|
2382
2386
|
}
|
2383
2387
|
}
|
2384
2388
|
// Look for "X in Y" or "X not in Y".
|
2385
|
-
if (expression.operator === 41 /* In */ || expression.operator === 42 /* NotIn */) {
|
2389
|
+
if (expression.operator === 41 /* OperatorType.In */ || expression.operator === 42 /* OperatorType.NotIn */) {
|
2386
2390
|
return this._isNarrowingExpression(expression.leftExpression, expressionList, filterForNeverNarrowing,
|
2387
2391
|
/* isComplexExpression */ true);
|
2388
2392
|
}
|
2389
2393
|
return false;
|
2390
2394
|
}
|
2391
|
-
case 55 /* UnaryOperation */: {
|
2392
|
-
return (expression.operator === 38 /* Not */ &&
|
2395
|
+
case 55 /* ParseNodeType.UnaryOperation */: {
|
2396
|
+
return (expression.operator === 38 /* OperatorType.Not */ &&
|
2393
2397
|
this._isNarrowingExpression(expression.expression, expressionList, filterForNeverNarrowing,
|
2394
2398
|
/* isComplexExpression */ false));
|
2395
2399
|
}
|
2396
|
-
case 5 /* AugmentedAssignment */: {
|
2400
|
+
case 5 /* ParseNodeType.AugmentedAssignment */: {
|
2397
2401
|
return this._isNarrowingExpression(expression.rightExpression, expressionList, filterForNeverNarrowing,
|
2398
2402
|
/* isComplexExpression */ true);
|
2399
2403
|
}
|
2400
|
-
case 9 /* Call */: {
|
2401
|
-
if (expression.leftExpression.nodeType === 38 /* Name */ &&
|
2404
|
+
case 9 /* ParseNodeType.Call */: {
|
2405
|
+
if (expression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
2402
2406
|
(expression.leftExpression.value === 'isinstance' ||
|
2403
2407
|
expression.leftExpression.value === 'issubclass') &&
|
2404
2408
|
expression.arguments.length === 2) {
|
2405
2409
|
return this._isNarrowingExpression(expression.arguments[0].valueExpression, expressionList, filterForNeverNarrowing,
|
2406
2410
|
/* isComplexExpression */ true);
|
2407
2411
|
}
|
2408
|
-
if (expression.leftExpression.nodeType === 38 /* Name */ &&
|
2412
|
+
if (expression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
2409
2413
|
expression.leftExpression.value === 'callable' &&
|
2410
2414
|
expression.arguments.length === 1) {
|
2411
2415
|
return this._isNarrowingExpression(expression.arguments[0].valueExpression, expressionList, filterForNeverNarrowing,
|
@@ -2427,42 +2431,42 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2427
2431
|
}
|
2428
2432
|
_createAssignmentTargetFlowNodes(target, walkTargets, unbound) {
|
2429
2433
|
switch (target.nodeType) {
|
2430
|
-
case 38 /* Name */:
|
2431
|
-
case 35 /* MemberAccess */: {
|
2434
|
+
case 38 /* ParseNodeType.Name */:
|
2435
|
+
case 35 /* ParseNodeType.MemberAccess */: {
|
2432
2436
|
this._createFlowAssignment(target, unbound);
|
2433
2437
|
if (walkTargets) {
|
2434
2438
|
this.walk(target);
|
2435
2439
|
}
|
2436
2440
|
break;
|
2437
2441
|
}
|
2438
|
-
case 24 /* Index */: {
|
2442
|
+
case 24 /* ParseNodeType.Index */: {
|
2439
2443
|
this._createFlowAssignment(target, unbound);
|
2440
2444
|
if (walkTargets) {
|
2441
2445
|
this.walk(target);
|
2442
2446
|
}
|
2443
2447
|
break;
|
2444
2448
|
}
|
2445
|
-
case 52 /* Tuple */: {
|
2449
|
+
case 52 /* ParseNodeType.Tuple */: {
|
2446
2450
|
target.expressions.forEach((expr) => {
|
2447
2451
|
this._createAssignmentTargetFlowNodes(expr, walkTargets, unbound);
|
2448
2452
|
});
|
2449
2453
|
break;
|
2450
2454
|
}
|
2451
|
-
case 54 /* TypeAnnotation */: {
|
2455
|
+
case 54 /* ParseNodeType.TypeAnnotation */: {
|
2452
2456
|
this._createAssignmentTargetFlowNodes(target.valueExpression, /* walkTargets */ false, unbound);
|
2453
2457
|
if (walkTargets) {
|
2454
2458
|
this.walk(target);
|
2455
2459
|
}
|
2456
2460
|
break;
|
2457
2461
|
}
|
2458
|
-
case 56 /* Unpack */: {
|
2462
|
+
case 56 /* ParseNodeType.Unpack */: {
|
2459
2463
|
this._createAssignmentTargetFlowNodes(target.expression, /* walkTargets */ false, unbound);
|
2460
2464
|
if (walkTargets) {
|
2461
2465
|
this.walk(target);
|
2462
2466
|
}
|
2463
2467
|
break;
|
2464
2468
|
}
|
2465
|
-
case 31 /* List */: {
|
2469
|
+
case 31 /* ParseNodeType.List */: {
|
2466
2470
|
target.entries.forEach((entry) => {
|
2467
2471
|
this._createAssignmentTargetFlowNodes(entry, walkTargets, unbound);
|
2468
2472
|
});
|
@@ -2501,7 +2505,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2501
2505
|
}
|
2502
2506
|
_createFlowAssignment(node, unbound = false) {
|
2503
2507
|
let targetSymbolId = symbol_1.indeterminateSymbolId;
|
2504
|
-
if (node.nodeType === 38 /* Name */) {
|
2508
|
+
if (node.nodeType === 38 /* ParseNodeType.Name */) {
|
2505
2509
|
const symbolWithScope = this._currentScope.lookUpSymbolRecursive(node.value);
|
2506
2510
|
(0, debug_1.assert)(symbolWithScope !== undefined);
|
2507
2511
|
targetSymbolId = symbolWithScope.symbol.id;
|
@@ -2522,7 +2526,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2522
2526
|
}
|
2523
2527
|
// Assume that an assignment to a member access expression
|
2524
2528
|
// can potentially generate an exception.
|
2525
|
-
if (node.nodeType === 35 /* MemberAccess */) {
|
2529
|
+
if (node.nodeType === 35 /* ParseNodeType.MemberAccess */) {
|
2526
2530
|
this._addExceptTargets(flowNode);
|
2527
2531
|
}
|
2528
2532
|
this._currentFlowNode = flowNode;
|
@@ -2611,7 +2615,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2611
2615
|
// Is this name already bound to a scope other than the local one?
|
2612
2616
|
const bindingType = this._currentScope.getBindingType(name);
|
2613
2617
|
if (bindingType !== undefined) {
|
2614
|
-
const scopeToUse = bindingType === 0 /* Nonlocal */
|
2618
|
+
const scopeToUse = bindingType === 0 /* NameBindingType.Nonlocal */
|
2615
2619
|
? this._currentScope.parent
|
2616
2620
|
: this._currentScope.getGlobalScope().scope;
|
2617
2621
|
const symbolWithScope = scopeToUse.lookUpSymbolRecursive(name);
|
@@ -2623,15 +2627,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2623
2627
|
// Don't overwrite an existing symbol.
|
2624
2628
|
let symbol = scope.lookUpSymbol(name);
|
2625
2629
|
if (!symbol) {
|
2626
|
-
symbol = scope.addSymbol(name, 1 /* InitiallyUnbound */ | 4 /* ClassMember */);
|
2627
|
-
if (this._currentScope.type === 3 /* Module */ || this._currentScope.type === 4 /* Builtin */) {
|
2630
|
+
symbol = scope.addSymbol(name, 1 /* SymbolFlags.InitiallyUnbound */ | 4 /* SymbolFlags.ClassMember */);
|
2631
|
+
if (this._currentScope.type === 3 /* ScopeType.Module */ || this._currentScope.type === 4 /* ScopeType.Builtin */) {
|
2628
2632
|
if ((0, symbolNameUtils_1.isPrivateOrProtectedName)(name)) {
|
2629
2633
|
if ((0, symbolNameUtils_1.isPrivateName)(name)) {
|
2630
2634
|
// Private names are obscured, so they are always externally hidden.
|
2631
2635
|
symbol.setIsExternallyHidden();
|
2632
2636
|
}
|
2633
2637
|
else if (this._fileInfo.isStubFile || this._fileInfo.isInPyTypedPackage) {
|
2634
|
-
if (this._currentScope.type === 4 /* Builtin */) {
|
2638
|
+
if (this._currentScope.type === 4 /* ScopeType.Builtin */) {
|
2635
2639
|
// Don't include private-named symbols in the builtin scope.
|
2636
2640
|
symbol.setIsExternallyHidden();
|
2637
2641
|
}
|
@@ -2654,27 +2658,27 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2654
2658
|
}
|
2655
2659
|
_bindPossibleTupleNamedTarget(target, addedSymbols) {
|
2656
2660
|
switch (target.nodeType) {
|
2657
|
-
case 38 /* Name */: {
|
2661
|
+
case 38 /* ParseNodeType.Name */: {
|
2658
2662
|
this._bindNameToScope(this._currentScope, target, addedSymbols);
|
2659
2663
|
break;
|
2660
2664
|
}
|
2661
|
-
case 52 /* Tuple */: {
|
2665
|
+
case 52 /* ParseNodeType.Tuple */: {
|
2662
2666
|
target.expressions.forEach((expr) => {
|
2663
2667
|
this._bindPossibleTupleNamedTarget(expr, addedSymbols);
|
2664
2668
|
});
|
2665
2669
|
break;
|
2666
2670
|
}
|
2667
|
-
case 31 /* List */: {
|
2671
|
+
case 31 /* ParseNodeType.List */: {
|
2668
2672
|
target.entries.forEach((expr) => {
|
2669
2673
|
this._bindPossibleTupleNamedTarget(expr, addedSymbols);
|
2670
2674
|
});
|
2671
2675
|
break;
|
2672
2676
|
}
|
2673
|
-
case 54 /* TypeAnnotation */: {
|
2677
|
+
case 54 /* ParseNodeType.TypeAnnotation */: {
|
2674
2678
|
this._bindPossibleTupleNamedTarget(target.valueExpression, addedSymbols);
|
2675
2679
|
break;
|
2676
2680
|
}
|
2677
|
-
case 56 /* Unpack */: {
|
2681
|
+
case 56 /* ParseNodeType.Unpack */: {
|
2678
2682
|
this._bindPossibleTupleNamedTarget(target.expression, addedSymbols);
|
2679
2683
|
break;
|
2680
2684
|
}
|
@@ -2684,7 +2688,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2684
2688
|
const symbol = this._addSymbolToCurrentScope(nameValue, /* isInitiallyUnbound */ false);
|
2685
2689
|
if (symbol) {
|
2686
2690
|
symbol.addDeclaration({
|
2687
|
-
type: 0 /* Intrinsic */,
|
2691
|
+
type: 0 /* DeclarationType.Intrinsic */,
|
2688
2692
|
node,
|
2689
2693
|
intrinsicType: type,
|
2690
2694
|
path: this._fileInfo.filePath,
|
@@ -2699,15 +2703,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2699
2703
|
_addSymbolToCurrentScope(nameValue, isInitiallyUnbound) {
|
2700
2704
|
let symbol = this._currentScope.lookUpSymbol(nameValue);
|
2701
2705
|
if (!symbol) {
|
2702
|
-
let symbolFlags = 0 /* None */;
|
2706
|
+
let symbolFlags = 0 /* SymbolFlags.None */;
|
2703
2707
|
if (isInitiallyUnbound) {
|
2704
|
-
symbolFlags |= 1 /* InitiallyUnbound */;
|
2708
|
+
symbolFlags |= 1 /* SymbolFlags.InitiallyUnbound */;
|
2705
2709
|
}
|
2706
|
-
if (this._currentScope.type === 2 /* Class */) {
|
2707
|
-
symbolFlags |= 4 /* ClassMember */;
|
2710
|
+
if (this._currentScope.type === 2 /* ScopeType.Class */) {
|
2711
|
+
symbolFlags |= 4 /* SymbolFlags.ClassMember */;
|
2708
2712
|
}
|
2709
2713
|
if (this._fileInfo.isStubFile && (0, symbolNameUtils_1.isPrivateOrProtectedName)(nameValue)) {
|
2710
|
-
symbolFlags |= 2 /* ExternallyHidden */;
|
2714
|
+
symbolFlags |= 2 /* SymbolFlags.ExternallyHidden */;
|
2711
2715
|
}
|
2712
2716
|
// Add the symbol. Assume that symbols with a default type source ID
|
2713
2717
|
// are "implicit" symbols added to the scope. These are not initially unbound.
|
@@ -2720,7 +2724,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2720
2724
|
const newScope = new scope_1.Scope(scopeType, parentScope);
|
2721
2725
|
this._currentScope = newScope;
|
2722
2726
|
// If this scope is an execution scope, allocate a new reference map.
|
2723
|
-
const isExecutionScope = scopeType === 4 /* Builtin */ || scopeType === 3 /* Module */ || scopeType === 1 /* Function */;
|
2727
|
+
const isExecutionScope = scopeType === 4 /* ScopeType.Builtin */ || scopeType === 3 /* ScopeType.Module */ || scopeType === 1 /* ScopeType.Function */;
|
2724
2728
|
const prevExpressions = this._currentScopeCodeFlowExpressions;
|
2725
2729
|
if (isExecutionScope) {
|
2726
2730
|
this._currentScopeCodeFlowExpressions = new Set();
|
@@ -2732,12 +2736,12 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2732
2736
|
}
|
2733
2737
|
_addInferredTypeAssignmentForVariable(target, source, isPossibleTypeAlias = false) {
|
2734
2738
|
switch (target.nodeType) {
|
2735
|
-
case 38 /* Name */: {
|
2739
|
+
case 38 /* ParseNodeType.Name */: {
|
2736
2740
|
const name = target;
|
2737
2741
|
const symbolWithScope = this._currentScope.lookUpSymbolRecursive(name.value);
|
2738
2742
|
if (symbolWithScope && symbolWithScope.symbol) {
|
2739
2743
|
const declaration = {
|
2740
|
-
type: 1 /* Variable */,
|
2744
|
+
type: 1 /* DeclarationType.Variable */,
|
2741
2745
|
node: target,
|
2742
2746
|
isConstant: (0, symbolNameUtils_1.isConstantName)(target.value),
|
2743
2747
|
inferredTypeSource: source,
|
@@ -2753,13 +2757,13 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2753
2757
|
}
|
2754
2758
|
break;
|
2755
2759
|
}
|
2756
|
-
case 35 /* MemberAccess */: {
|
2760
|
+
case 35 /* ParseNodeType.MemberAccess */: {
|
2757
2761
|
const memberAccessInfo = this._getMemberAccessInfo(target);
|
2758
2762
|
if (memberAccessInfo) {
|
2759
2763
|
const name = target.memberName;
|
2760
2764
|
let symbol = memberAccessInfo.classScope.lookUpSymbol(name.value);
|
2761
2765
|
if (!symbol) {
|
2762
|
-
symbol = memberAccessInfo.classScope.addSymbol(name.value, 1 /* InitiallyUnbound */);
|
2766
|
+
symbol = memberAccessInfo.classScope.addSymbol(name.value, 1 /* SymbolFlags.InitiallyUnbound */);
|
2763
2767
|
const honorPrivateNaming = this._fileInfo.diagnosticRuleSet.reportPrivateUsage !== 'none';
|
2764
2768
|
if ((0, symbolNameUtils_1.isPrivateOrProtectedName)(name.value) && honorPrivateNaming) {
|
2765
2769
|
symbol.setIsPrivateMember();
|
@@ -2773,7 +2777,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2773
2777
|
if (!symbol.isClassMember() ||
|
2774
2778
|
!symbol
|
2775
2779
|
.getDeclarations()
|
2776
|
-
.some((decl) => decl.type === 5 /* Function */ && decl.isMethod)) {
|
2780
|
+
.some((decl) => decl.type === 5 /* DeclarationType.Function */ && decl.isMethod)) {
|
2777
2781
|
symbol.setIsInstanceMember();
|
2778
2782
|
}
|
2779
2783
|
}
|
@@ -2781,7 +2785,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2781
2785
|
symbol.setIsClassMember();
|
2782
2786
|
}
|
2783
2787
|
const declaration = {
|
2784
|
-
type: 1 /* Variable */,
|
2788
|
+
type: 1 /* DeclarationType.Variable */,
|
2785
2789
|
node: target.memberName,
|
2786
2790
|
isConstant: (0, symbolNameUtils_1.isConstantName)(name.value),
|
2787
2791
|
inferredTypeSource: source,
|
@@ -2796,21 +2800,21 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2796
2800
|
}
|
2797
2801
|
break;
|
2798
2802
|
}
|
2799
|
-
case 52 /* Tuple */: {
|
2803
|
+
case 52 /* ParseNodeType.Tuple */: {
|
2800
2804
|
target.expressions.forEach((expr) => {
|
2801
2805
|
this._addInferredTypeAssignmentForVariable(expr, source);
|
2802
2806
|
});
|
2803
2807
|
break;
|
2804
2808
|
}
|
2805
|
-
case 54 /* TypeAnnotation */: {
|
2809
|
+
case 54 /* ParseNodeType.TypeAnnotation */: {
|
2806
2810
|
this._addInferredTypeAssignmentForVariable(target.valueExpression, source);
|
2807
2811
|
break;
|
2808
2812
|
}
|
2809
|
-
case 56 /* Unpack */: {
|
2813
|
+
case 56 /* ParseNodeType.Unpack */: {
|
2810
2814
|
this._addInferredTypeAssignmentForVariable(target.expression, source);
|
2811
2815
|
break;
|
2812
2816
|
}
|
2813
|
-
case 31 /* List */: {
|
2817
|
+
case 31 /* ParseNodeType.List */: {
|
2814
2818
|
target.entries.forEach((entry) => {
|
2815
2819
|
this._addInferredTypeAssignmentForVariable(entry, source);
|
2816
2820
|
});
|
@@ -2826,7 +2830,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2826
2830
|
var _a, _b, _c;
|
2827
2831
|
let declarationHandled = false;
|
2828
2832
|
switch (target.nodeType) {
|
2829
|
-
case 38 /* Name */: {
|
2833
|
+
case 38 /* ParseNodeType.Name */: {
|
2830
2834
|
const name = target;
|
2831
2835
|
const symbolWithScope = this._currentScope.lookUpSymbolRecursive(name.value);
|
2832
2836
|
if (symbolWithScope && symbolWithScope.symbol) {
|
@@ -2848,10 +2852,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2848
2852
|
// body should also be considered a ClassVar.
|
2849
2853
|
if (finalInfo.isFinal) {
|
2850
2854
|
const containingClass = ParseTreeUtils.getEnclosingClassOrFunction(target);
|
2851
|
-
if (containingClass && containingClass.nodeType === 10 /* Class */) {
|
2855
|
+
if (containingClass && containingClass.nodeType === 10 /* ParseNodeType.Class */) {
|
2852
2856
|
// Make sure it's part of an assignment.
|
2853
|
-
if (((_a = target.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* Assignment */ ||
|
2854
|
-
((_c = (_b = target.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 3 /* Assignment */) {
|
2857
|
+
if (((_a = target.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* ParseNodeType.Assignment */ ||
|
2858
|
+
((_c = (_b = target.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 3 /* ParseNodeType.Assignment */) {
|
2855
2859
|
classVarInfo = {
|
2856
2860
|
isClassVar: true,
|
2857
2861
|
classVarTypeNode: undefined,
|
@@ -2860,7 +2864,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2860
2864
|
}
|
2861
2865
|
}
|
2862
2866
|
const declaration = {
|
2863
|
-
type: 1 /* Variable */,
|
2867
|
+
type: 1 /* DeclarationType.Variable */,
|
2864
2868
|
node: target,
|
2865
2869
|
isConstant: (0, symbolNameUtils_1.isConstantName)(name.value),
|
2866
2870
|
isFinal: finalInfo.isFinal,
|
@@ -2880,14 +2884,14 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2880
2884
|
symbolWithScope.symbol.setIsInstanceMember();
|
2881
2885
|
}
|
2882
2886
|
// Look for an 'InitVar' either by itself or wrapped in an 'Annotated'.
|
2883
|
-
if (typeAnnotation.nodeType === 24 /* Index */) {
|
2887
|
+
if (typeAnnotation.nodeType === 24 /* ParseNodeType.Index */) {
|
2884
2888
|
if (this._isDataclassesAnnotation(typeAnnotation.baseExpression, 'InitVar')) {
|
2885
2889
|
symbolWithScope.symbol.setIsInitVar();
|
2886
2890
|
}
|
2887
2891
|
else if (this._isTypingAnnotation(typeAnnotation.baseExpression, 'Annotated') &&
|
2888
2892
|
typeAnnotation.items.length > 0) {
|
2889
2893
|
const item0Expr = typeAnnotation.items[0].valueExpression;
|
2890
|
-
if (item0Expr.nodeType === 24 /* Index */ &&
|
2894
|
+
if (item0Expr.nodeType === 24 /* ParseNodeType.Index */ &&
|
2891
2895
|
this._isDataclassesAnnotation(item0Expr.baseExpression, 'InitVar')) {
|
2892
2896
|
symbolWithScope.symbol.setIsInitVar();
|
2893
2897
|
}
|
@@ -2897,7 +2901,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2897
2901
|
declarationHandled = true;
|
2898
2902
|
break;
|
2899
2903
|
}
|
2900
|
-
case 35 /* MemberAccess */: {
|
2904
|
+
case 35 /* ParseNodeType.MemberAccess */: {
|
2901
2905
|
// We need to determine whether this expression is declaring a class or
|
2902
2906
|
// instance variable. This is difficult because python doesn't provide
|
2903
2907
|
// a keyword for accessing "this". Instead, it uses naming conventions
|
@@ -2910,7 +2914,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2910
2914
|
const name = target.memberName;
|
2911
2915
|
let symbol = memberAccessInfo.classScope.lookUpSymbol(name.value);
|
2912
2916
|
if (!symbol) {
|
2913
|
-
symbol = memberAccessInfo.classScope.addSymbol(name.value, 1 /* InitiallyUnbound */);
|
2917
|
+
symbol = memberAccessInfo.classScope.addSymbol(name.value, 1 /* SymbolFlags.InitiallyUnbound */);
|
2914
2918
|
const honorPrivateNaming = this._fileInfo.diagnosticRuleSet.reportPrivateUsage !== 'none';
|
2915
2919
|
if ((0, symbolNameUtils_1.isPrivateOrProtectedName)(name.value) && honorPrivateNaming) {
|
2916
2920
|
symbol.setIsPrivateMember();
|
@@ -2924,7 +2928,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2924
2928
|
}
|
2925
2929
|
const finalInfo = this._isAnnotationFinal(typeAnnotation);
|
2926
2930
|
const declaration = {
|
2927
|
-
type: 1 /* Variable */,
|
2931
|
+
type: 1 /* DeclarationType.Variable */,
|
2928
2932
|
node: target.memberName,
|
2929
2933
|
isConstant: (0, symbolNameUtils_1.isConstantName)(name.value),
|
2930
2934
|
isDefinedByMemberAccess: true,
|
@@ -2959,17 +2963,17 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2959
2963
|
_isKnownAnnotation(typeAnnotation, name, importAliases, symbolAliases) {
|
2960
2964
|
let annotationNode = typeAnnotation;
|
2961
2965
|
// Is this a quoted annotation?
|
2962
|
-
if (annotationNode.nodeType === 48 /* StringList */ && annotationNode.typeAnnotation) {
|
2966
|
+
if (annotationNode.nodeType === 48 /* ParseNodeType.StringList */ && annotationNode.typeAnnotation) {
|
2963
2967
|
annotationNode = annotationNode.typeAnnotation;
|
2964
2968
|
}
|
2965
|
-
if (annotationNode.nodeType === 38 /* Name */) {
|
2969
|
+
if (annotationNode.nodeType === 38 /* ParseNodeType.Name */) {
|
2966
2970
|
const alias = symbolAliases.get(annotationNode.value);
|
2967
2971
|
if (alias === name) {
|
2968
2972
|
return true;
|
2969
2973
|
}
|
2970
2974
|
}
|
2971
|
-
else if (annotationNode.nodeType === 35 /* MemberAccess */) {
|
2972
|
-
if (annotationNode.leftExpression.nodeType === 38 /* Name */ &&
|
2975
|
+
else if (annotationNode.nodeType === 35 /* ParseNodeType.MemberAccess */) {
|
2976
|
+
if (annotationNode.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
2973
2977
|
annotationNode.memberName.value === name) {
|
2974
2978
|
const baseName = annotationNode.leftExpression.value;
|
2975
2979
|
return importAliases.some((alias) => alias === baseName);
|
@@ -3000,11 +3004,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3000
3004
|
if (this._isTypingAnnotation(typeAnnotation, 'Final')) {
|
3001
3005
|
isFinal = true;
|
3002
3006
|
}
|
3003
|
-
else if (typeAnnotation.nodeType === 24 /* Index */ && typeAnnotation.items.length === 1) {
|
3007
|
+
else if (typeAnnotation.nodeType === 24 /* ParseNodeType.Index */ && typeAnnotation.items.length === 1) {
|
3004
3008
|
// Recursively call to see if the base expression is "Final".
|
3005
3009
|
const finalInfo = this._isAnnotationFinal(typeAnnotation.baseExpression);
|
3006
3010
|
if (finalInfo.isFinal &&
|
3007
|
-
typeAnnotation.items[0].argumentCategory === 0 /* Simple */ &&
|
3011
|
+
typeAnnotation.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */ &&
|
3008
3012
|
!typeAnnotation.items[0].name &&
|
3009
3013
|
!typeAnnotation.trailingComma) {
|
3010
3014
|
isFinal = true;
|
@@ -3022,10 +3026,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3022
3026
|
let classVarTypeNode;
|
3023
3027
|
while (typeAnnotation) {
|
3024
3028
|
// Is this a quoted annotation?
|
3025
|
-
if (typeAnnotation.nodeType === 48 /* StringList */ && typeAnnotation.typeAnnotation) {
|
3029
|
+
if (typeAnnotation.nodeType === 48 /* ParseNodeType.StringList */ && typeAnnotation.typeAnnotation) {
|
3026
3030
|
typeAnnotation = typeAnnotation.typeAnnotation;
|
3027
3031
|
}
|
3028
|
-
if (typeAnnotation.nodeType === 24 /* Index */ &&
|
3032
|
+
if (typeAnnotation.nodeType === 24 /* ParseNodeType.Index */ &&
|
3029
3033
|
typeAnnotation.items.length > 0 &&
|
3030
3034
|
this._isTypingAnnotation(typeAnnotation.baseExpression, 'Annotated')) {
|
3031
3035
|
typeAnnotation = typeAnnotation.items[0].valueExpression;
|
@@ -3034,11 +3038,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3034
3038
|
isClassVar = true;
|
3035
3039
|
break;
|
3036
3040
|
}
|
3037
|
-
else if (typeAnnotation.nodeType === 24 /* Index */ && typeAnnotation.items.length === 1) {
|
3041
|
+
else if (typeAnnotation.nodeType === 24 /* ParseNodeType.Index */ && typeAnnotation.items.length === 1) {
|
3038
3042
|
// Recursively call to see if the base expression is "ClassVar".
|
3039
3043
|
const finalInfo = this._isAnnotationClassVar(typeAnnotation.baseExpression);
|
3040
3044
|
if (finalInfo.isClassVar &&
|
3041
|
-
typeAnnotation.items[0].argumentCategory === 0 /* Simple */ &&
|
3045
|
+
typeAnnotation.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */ &&
|
3042
3046
|
!typeAnnotation.items[0].name &&
|
3043
3047
|
!typeAnnotation.trailingComma) {
|
3044
3048
|
isClassVar = true;
|
@@ -3058,7 +3062,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3058
3062
|
_getMemberAccessInfo(node) {
|
3059
3063
|
// We handle only simple names on the left-hand side of the expression,
|
3060
3064
|
// not calls, nested member accesses, index expressions, etc.
|
3061
|
-
if (node.leftExpression.nodeType !== 38 /* Name */) {
|
3065
|
+
if (node.leftExpression.nodeType !== 38 /* ParseNodeType.Name */) {
|
3062
3066
|
return undefined;
|
3063
3067
|
}
|
3064
3068
|
const leftSymbolName = node.leftExpression.value;
|
@@ -3100,7 +3104,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3100
3104
|
// a decorator that tells us otherwise.
|
3101
3105
|
isInstanceMember = true;
|
3102
3106
|
for (const decorator of methodNode.decorators) {
|
3103
|
-
if (decorator.expression.nodeType === 38 /* Name */) {
|
3107
|
+
if (decorator.expression.nodeType === 38 /* ParseNodeType.Name */) {
|
3104
3108
|
const decoratorName = decorator.expression.value;
|
3105
3109
|
if (decoratorName === 'staticmethod') {
|
3106
3110
|
// A static method doesn't have a "self" or "cls" parameter.
|
@@ -3152,16 +3156,16 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3152
3156
|
return false;
|
3153
3157
|
}
|
3154
3158
|
let annotationNode;
|
3155
|
-
if (node.nodeType === 54 /* TypeAnnotation */) {
|
3159
|
+
if (node.nodeType === 54 /* ParseNodeType.TypeAnnotation */) {
|
3156
3160
|
annotationNode = node;
|
3157
3161
|
}
|
3158
3162
|
else {
|
3159
|
-
if (node.leftExpression.nodeType !== 54 /* TypeAnnotation */) {
|
3163
|
+
if (node.leftExpression.nodeType !== 54 /* ParseNodeType.TypeAnnotation */) {
|
3160
3164
|
return false;
|
3161
3165
|
}
|
3162
3166
|
annotationNode = node.leftExpression;
|
3163
3167
|
}
|
3164
|
-
if (annotationNode.valueExpression.nodeType !== 38 /* Name */) {
|
3168
|
+
if (annotationNode.valueExpression.nodeType !== 38 /* ParseNodeType.Name */) {
|
3165
3169
|
return false;
|
3166
3170
|
}
|
3167
3171
|
const assignedNameNode = annotationNode.valueExpression;
|
@@ -3195,7 +3199,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3195
3199
|
const symbol = this._bindNameToScope(this._currentScope, annotationNode.valueExpression);
|
3196
3200
|
if (symbol) {
|
3197
3201
|
symbol.addDeclaration({
|
3198
|
-
type: 7 /* SpecialBuiltInClass */,
|
3202
|
+
type: 7 /* DeclarationType.SpecialBuiltInClass */,
|
3199
3203
|
node: annotationNode,
|
3200
3204
|
path: this._fileInfo.filePath,
|
3201
3205
|
range: (0, positionUtils_1.convertTextRangeToRange)(annotationNode, this._fileInfo.lines),
|
@@ -3233,7 +3237,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3233
3237
|
this._addError(localize_1.Localizer.Diagnostic.yieldOutsideFunction(), node);
|
3234
3238
|
}
|
3235
3239
|
}
|
3236
|
-
else if (functionNode.isAsync && node.nodeType === 61 /* YieldFrom */) {
|
3240
|
+
else if (functionNode.isAsync && node.nodeType === 61 /* ParseNodeType.YieldFrom */) {
|
3237
3241
|
// PEP 525 indicates that 'yield from' is not allowed in an
|
3238
3242
|
// async function.
|
3239
3243
|
this._addError(localize_1.Localizer.Diagnostic.yieldFromOutsideAsync(), node);
|
@@ -3337,7 +3341,7 @@ class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
3337
3341
|
this._currentScope = currentScope;
|
3338
3342
|
}
|
3339
3343
|
visitClass(node) {
|
3340
|
-
const newScope = this._createNewScope(2 /* Class */, () => {
|
3344
|
+
const newScope = this._createNewScope(2 /* ScopeType.Class */, () => {
|
3341
3345
|
this.walk(node.suite);
|
3342
3346
|
});
|
3343
3347
|
if (!AnalyzerNodeInfo.getScope(node)) {
|
@@ -3346,7 +3350,7 @@ class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
3346
3350
|
return false;
|
3347
3351
|
}
|
3348
3352
|
visitFunction(node) {
|
3349
|
-
const newScope = this._createNewScope(1 /* Function */, () => {
|
3353
|
+
const newScope = this._createNewScope(1 /* ScopeType.Function */, () => {
|
3350
3354
|
this.walk(node.suite);
|
3351
3355
|
});
|
3352
3356
|
if (!AnalyzerNodeInfo.getScope(node)) {
|