@zzzen/pyright-internal 1.2.0-dev.20260809 → 1.2.0-dev.20260823
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/analyzerNodeInfo.d.ts +119 -24
- package/dist/analyzer/analyzerNodeInfo.js +408 -89
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.d.ts +6 -3
- package/dist/analyzer/binder.js +157 -70
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +5 -2
- package/dist/analyzer/checker.js +92 -34
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -1
- package/dist/analyzer/codeFlowEngine.js +12 -10
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.d.ts +2 -1
- package/dist/analyzer/codeFlowUtils.js +2 -3
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +47 -7
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +18 -8
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +6 -4
- package/dist/analyzer/dataClasses.js +119 -75
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +2 -1
- package/dist/analyzer/declarationUtils.js +2 -2
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.d.ts +5 -4
- package/dist/analyzer/decorators.js +38 -21
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.d.ts +5 -4
- package/dist/analyzer/enums.js +11 -10
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +5 -3
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +3 -1
- package/dist/analyzer/importStatementUtils.js +14 -7
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.d.ts +2 -1
- package/dist/analyzer/namedTuples.js +3 -4
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +3 -2
- package/dist/analyzer/operations.js +8 -8
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +2 -2
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +13 -11
- package/dist/analyzer/parseTreeUtils.js +62 -36
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.d.ts +7 -2
- package/dist/analyzer/parseTreeWalker.js +29 -175
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +4 -3
- package/dist/analyzer/patternMatching.js +47 -43
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +12 -0
- package/dist/analyzer/program.js +235 -29
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.d.ts +4 -3
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -2
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.d.ts +3 -0
- package/dist/analyzer/scope.js +10 -0
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.d.ts +4 -3
- package/dist/analyzer/scopeUtils.js +8 -8
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/sentinel.d.ts +2 -1
- package/dist/analyzer/sentinel.js +2 -3
- package/dist/analyzer/sentinel.js.map +1 -1
- package/dist/analyzer/service.js +28 -10
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceEnumerator.d.ts +5 -0
- package/dist/analyzer/sourceEnumerator.js +57 -3
- package/dist/analyzer/sourceEnumerator.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +12 -6
- package/dist/analyzer/sourceFile.js +73 -50
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
- package/dist/analyzer/sourceFileInfoUtils.js +8 -0
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +4 -1
- package/dist/analyzer/sourceMapper.js +14 -8
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +4 -1
- package/dist/analyzer/symbol.js +8 -0
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/testWalker.js +2 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +2 -1
- package/dist/analyzer/tracePrinter.js +2 -2
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +3 -2
- package/dist/analyzer/tuples.js +5 -5
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.d.ts +6 -2
- package/dist/analyzer/typeCacheUtils.js +16 -37
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +5 -7
- package/dist/analyzer/typeDocStringUtils.js +229 -132
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +2 -0
- package/dist/analyzer/typeEvaluator.js +1280 -302
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +2 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +3 -2
- package/dist/analyzer/typeGuards.js +37 -33
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +12 -9
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +3 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +4 -3
- package/dist/analyzer/typedDicts.js +15 -14
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +11 -1
- package/dist/analyzer/types.js +48 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/collectionUtils.js +15 -6
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -0
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +4 -1
- package/dist/common/configOptions.js +68 -12
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +1 -0
- package/dist/common/envVarUtils.js +41 -10
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +3 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/extraPathGlob.d.ts +12 -0
- package/dist/common/extraPathGlob.js +315 -0
- package/dist/common/extraPathGlob.js.map +1 -0
- package/dist/common/host.d.ts +2 -0
- package/dist/common/host.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +2 -1
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/pathConsts.d.ts +1 -0
- package/dist/common/pathConsts.js +11 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/common/processUtils.d.ts +4 -2
- package/dist/common/processUtils.js +3 -0
- package/dist/common/processUtils.js.map +1 -1
- package/dist/common/stringUtils.d.ts +6 -0
- package/dist/common/stringUtils.js +87 -5
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.d.ts +3 -1
- package/dist/common/textEditTracker.js +8 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRangeCollection.d.ts +1 -0
- package/dist/common/textRangeCollection.js +32 -1
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +3 -0
- package/dist/common/uri/uriUtils.js +65 -15
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/fileSystemMapping.d.ts +10 -0
- package/dist/fileSystemMapping.js +176 -0
- package/dist/fileSystemMapping.js.map +1 -0
- package/dist/languageService/analyzerServiceExecutor.js +2 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +1 -0
- package/dist/languageService/autoImporter.js +32 -5
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +7 -0
- package/dist/languageService/callHierarchyProvider.js +97 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +30 -8
- package/dist/languageService/completionProvider.js +298 -93
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.js +7 -6
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +2 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +3 -1
- package/dist/languageService/documentSymbolCollector.js +78 -14
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +3 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +28 -1
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +2 -1
- package/dist/languageService/hoverProvider.js +48 -16
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.d.ts +3 -1
- package/dist/languageService/importSorter.js +4 -2
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/importStatementCandidates.js +4 -2
- package/dist/languageService/importStatementCandidates.js.map +1 -1
- package/dist/languageService/quickActions.js +2 -1
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js +12 -5
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +3 -0
- package/dist/languageService/signatureHelpProvider.js +56 -18
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +2 -1
- package/dist/languageService/symbolIndexer.js +7 -7
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +1 -1
- package/dist/languageService/tooltipUtils.js +103 -35
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +3 -2
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +12 -0
- package/dist/localization/localize.js +14 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +11 -0
- package/dist/localization/package.nls.de.json +11 -0
- package/dist/localization/package.nls.en-us.json +18 -0
- package/dist/localization/package.nls.es.json +11 -0
- package/dist/localization/package.nls.fr.json +11 -0
- package/dist/localization/package.nls.it.json +11 -0
- package/dist/localization/package.nls.ja.json +11 -0
- package/dist/localization/package.nls.ko.json +11 -0
- package/dist/localization/package.nls.pl.json +11 -0
- package/dist/localization/package.nls.pt-br.json +11 -0
- package/dist/localization/package.nls.qps-ploc.json +11 -0
- package/dist/localization/package.nls.ru.json +11 -0
- package/dist/localization/package.nls.tr.json +11 -0
- package/dist/localization/package.nls.zh-cn.json +12 -1
- package/dist/localization/package.nls.zh-tw.json +13 -2
- package/dist/parser/parseNodes.d.ts +85 -80
- package/dist/parser/parseNodes.js +182 -159
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parseTreeUtils.d.ts +3 -0
- package/dist/parser/parseTreeUtils.js +209 -0
- package/dist/parser/parseTreeUtils.js.map +1 -0
- package/dist/parser/parser.d.ts +16 -6
- package/dist/parser/parser.js +210 -144
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringAnnotationInfo.d.ts +16 -0
- package/dist/parser/stringAnnotationInfo.js +26 -0
- package/dist/parser/stringAnnotationInfo.js.map +1 -0
- package/dist/readonlyAugmentedFileSystem.d.ts +2 -9
- package/dist/readonlyAugmentedFileSystem.js +17 -144
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tests/analyzerNodeInfo.test.d.ts +1 -0
- package/dist/tests/analyzerNodeInfo.test.js +113 -0
- package/dist/tests/analyzerNodeInfo.test.js.map +1 -0
- package/dist/tests/collectionUtils.test.js +46 -0
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/completions.test.js +34 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +131 -6
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/extraPathGlob.test.d.ts +1 -0
- package/dist/tests/extraPathGlob.test.js +434 -0
- package/dist/tests/extraPathGlob.test.js.map +1 -0
- package/dist/tests/fileSystemMapping.test.d.ts +1 -0
- package/dist/tests/fileSystemMapping.test.js +458 -0
- package/dist/tests/fileSystemMapping.test.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js +14 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js +7 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js +41 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +2 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +5 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js +4 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js +48 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +8 -2
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +5 -2
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js +2 -2
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +1 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/hoverProvider.test.js +38 -0
- package/dist/tests/hoverProvider.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +6 -3
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +38 -0
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +88 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +60 -3
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js +23 -0
- package/dist/tests/positionUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +41 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/service.test.js +77 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceEnumeratorSymlink.test.d.ts +1 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js +203 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js.map +1 -0
- package/dist/tests/stringUtils.test.js +84 -0
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symlinkAliasInvalidation.test.d.ts +1 -0
- package/dist/tests/symlinkAliasInvalidation.test.js +471 -0
- package/dist/tests/symlinkAliasInvalidation.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +2 -0
- package/dist/tests/testUtils.js +7 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/textRangeCollection.test.d.ts +1 -0
- package/dist/tests/textRangeCollection.test.js +137 -0
- package/dist/tests/textRangeCollection.test.js.map +1 -0
- package/dist/tests/typeCacheUtils.test.d.ts +1 -0
- package/dist/tests/typeCacheUtils.test.js +69 -0
- package/dist/tests/typeCacheUtils.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.js +24 -3
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +8 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +12 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +33 -1
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +29 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +318 -4
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/typeServer/typeCache.test.d.ts +1 -0
- package/dist/tests/typeServer/typeCache.test.js +69 -0
- package/dist/tests/typeServer/typeCache.test.js.map +1 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js +18 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js.map +1 -1
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/{analyzer/parseTreeCleaner.js → tests/types.test.js} +23 -25
- package/dist/tests/types.test.js.map +1 -0
- package/dist/tests/uri.test.js +51 -0
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/typeServer/notebookDocumentHandler.d.ts +9 -2
- package/dist/typeServer/notebookDocumentHandler.js +16 -6
- package/dist/typeServer/notebookDocumentHandler.js.map +1 -1
- package/dist/typeServer/programWrapper.d.ts +1 -0
- package/dist/typeServer/programWrapper.js +28 -15
- package/dist/typeServer/programWrapper.js.map +1 -1
- package/dist/typeServer/protocol/tspSupplemental.d.ts +1 -1
- package/dist/typeServer/protocol/tspSupplemental.js +2 -2
- package/dist/typeServer/server.d.ts +13 -2
- package/dist/typeServer/server.js +36 -23
- package/dist/typeServer/server.js.map +1 -1
- package/dist/typeServer/typeCache.d.ts +8 -4
- package/dist/typeServer/typeCache.js +33 -5
- package/dist/typeServer/typeCache.js.map +1 -1
- package/dist/typeServer/typeEvalUtils.d.ts +2 -1
- package/dist/typeServer/typeEvalUtils.js +7 -3
- package/dist/typeServer/typeEvalUtils.js.map +1 -1
- package/dist/typeServer/typeServerFileSystem.d.ts +10 -9
- package/dist/typeServer/typeServerFileSystem.js +16 -12
- package/dist/typeServer/typeServerFileSystem.js.map +1 -1
- package/package.json +7 -5
- package/dist/analyzer/parseTreeCleaner.d.ts +0 -8
- package/dist/analyzer/parseTreeCleaner.js.map +0 -1
package/dist/analyzer/binder.js
CHANGED
|
@@ -58,7 +58,6 @@ const positionUtils_1 = require("../common/positionUtils");
|
|
|
58
58
|
const textRange_1 = require("../common/textRange");
|
|
59
59
|
const uri_1 = require("../common/uri/uri");
|
|
60
60
|
const localize_1 = require("../localization/localize");
|
|
61
|
-
const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
|
62
61
|
const codeFlowTypes_1 = require("./codeFlowTypes");
|
|
63
62
|
const declaration_1 = require("./declaration");
|
|
64
63
|
const importStatementUtils_1 = require("./importStatementUtils");
|
|
@@ -68,13 +67,70 @@ const scope_1 = require("./scope");
|
|
|
68
67
|
const StaticExpressions = __importStar(require("./staticExpressions"));
|
|
69
68
|
const symbol_1 = require("./symbol");
|
|
70
69
|
const symbolNameUtils_1 = require("./symbolNameUtils");
|
|
70
|
+
function isStaticClassAssignmentTarget(target) {
|
|
71
|
+
switch (target.nodeType) {
|
|
72
|
+
case 38 /* ParseNodeType.Name */:
|
|
73
|
+
return true;
|
|
74
|
+
case 54 /* ParseNodeType.TypeAnnotation */:
|
|
75
|
+
return isStaticClassAssignmentTarget(target.d.valueExpr);
|
|
76
|
+
case 52 /* ParseNodeType.Tuple */:
|
|
77
|
+
case 34 /* ParseNodeType.List */:
|
|
78
|
+
return target.d.items.every((item) => isStaticClassAssignmentTarget(item));
|
|
79
|
+
case 56 /* ParseNodeType.Unpack */:
|
|
80
|
+
return isStaticClassAssignmentTarget(target.d.expr);
|
|
81
|
+
default:
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getCalledBuiltInName(scope, expression, visitedSymbols = new Set()) {
|
|
86
|
+
if (expression.nodeType === 38 /* ParseNodeType.Name */) {
|
|
87
|
+
const symbolWithScope = scope.lookUpSymbolRecursive(expression.d.value);
|
|
88
|
+
if (!symbolWithScope || visitedSymbols.has(symbolWithScope.symbol)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
visitedSymbols.add(symbolWithScope.symbol);
|
|
92
|
+
if (symbolWithScope.scope.type === 5 /* ScopeType.Builtin */) {
|
|
93
|
+
return expression.d.value;
|
|
94
|
+
}
|
|
95
|
+
const declarations = symbolWithScope.symbol.getDeclarations();
|
|
96
|
+
const declaration = declarations[declarations.length - 1];
|
|
97
|
+
if (declaration?.type === 1 /* DeclarationType.Variable */ &&
|
|
98
|
+
(declaration.inferredTypeSource?.nodeType === 38 /* ParseNodeType.Name */ ||
|
|
99
|
+
declaration.inferredTypeSource?.nodeType === 35 /* ParseNodeType.MemberAccess */)) {
|
|
100
|
+
return getCalledBuiltInName(scope, declaration.inferredTypeSource, visitedSymbols);
|
|
101
|
+
}
|
|
102
|
+
if (declaration?.type === 8 /* DeclarationType.Alias */ &&
|
|
103
|
+
declaration.moduleName === 'builtins' &&
|
|
104
|
+
declaration.symbolName) {
|
|
105
|
+
return declaration.symbolName;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (expression.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
|
|
109
|
+
expression.d.leftExpr.nodeType === 38 /* ParseNodeType.Name */) {
|
|
110
|
+
const symbolWithScope = scope.lookUpSymbolRecursive(expression.d.leftExpr.d.value);
|
|
111
|
+
const declarations = symbolWithScope?.symbol.getDeclarations() ?? [];
|
|
112
|
+
const declaration = declarations[declarations.length - 1];
|
|
113
|
+
if (declaration?.type === 8 /* DeclarationType.Alias */ &&
|
|
114
|
+
declaration.moduleName === 'builtins' &&
|
|
115
|
+
!declaration.symbolName) {
|
|
116
|
+
return expression.d.member.d.value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
function doesCallExposeClassNamespace(scope, node) {
|
|
122
|
+
const builtInName = getCalledBuiltInName(scope, node.d.leftExpr);
|
|
123
|
+
return (builtInName === 'exec' ||
|
|
124
|
+
(builtInName === 'eval' && node.d.args.length === 1) ||
|
|
125
|
+
((builtInName === 'locals' || builtInName === 'vars') && node.d.args.length === 0));
|
|
126
|
+
}
|
|
71
127
|
// For each flow node within an execution context, we'll add a small
|
|
72
128
|
// amount to the complexity factor. Without this, the complexity
|
|
73
129
|
// calculation fails to take into account large numbers of non-cyclical
|
|
74
130
|
// flow nodes. This number is somewhat arbitrary and is tuned empirically.
|
|
75
131
|
const flowNodeComplexityContribution = 0.025;
|
|
76
132
|
class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
77
|
-
constructor(fileInfo, _moduleSymbolOnly
|
|
133
|
+
constructor(fileInfo, _moduleSymbolOnly, _cellChainIndex, nodeInfo) {
|
|
78
134
|
super();
|
|
79
135
|
this._moduleSymbolOnly = _moduleSymbolOnly;
|
|
80
136
|
this._cellChainIndex = _cellChainIndex;
|
|
@@ -119,6 +175,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
119
175
|
// the current function.
|
|
120
176
|
this._codeFlowComplexity = 0;
|
|
121
177
|
this._fileInfo = fileInfo;
|
|
178
|
+
this._nodeInfo = nodeInfo;
|
|
122
179
|
}
|
|
123
180
|
bindModule(node) {
|
|
124
181
|
// We'll assume that if there is no builtins scope provided, we must be
|
|
@@ -128,8 +185,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
128
185
|
this._addTypingImportAliasesFromBuiltinsScope();
|
|
129
186
|
this._createNewScope(isBuiltInModule ? 5 /* ScopeType.Builtin */ : 4 /* ScopeType.Module */, this._fileInfo.builtinsScope,
|
|
130
187
|
/* proxyScope */ undefined, chainedModuleLevelScopeLookup, () => {
|
|
131
|
-
|
|
132
|
-
|
|
188
|
+
this._nodeInfo.setScope(node, this._currentScope);
|
|
189
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
133
190
|
// Bind implicit names.
|
|
134
191
|
// List taken from https://docs.python.org/3/reference/import.html#__name__
|
|
135
192
|
this._addImplicitSymbolToCurrentScope('__name__', node, 'str');
|
|
@@ -147,9 +204,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
147
204
|
this._currentFlowNode = this._createStartFlowNode();
|
|
148
205
|
this._walkStatementsAndReportUnreachable(node.d.statements);
|
|
149
206
|
// Associate the code flow node at the end of the module with the module.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
207
|
+
this._nodeInfo.setAfterFlowNode(node, this._currentFlowNode);
|
|
208
|
+
this._nodeInfo.setCodeFlowExpressions(node, this._currentScopeCodeFlowExpressions);
|
|
209
|
+
this._nodeInfo.setCodeFlowComplexity(node, this._codeFlowComplexity);
|
|
153
210
|
});
|
|
154
211
|
// Perform all analysis that was deferred during the first pass.
|
|
155
212
|
this._bindDeferred();
|
|
@@ -191,17 +248,17 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
191
248
|
}
|
|
192
249
|
});
|
|
193
250
|
if (this._dunderAllNames) {
|
|
194
|
-
|
|
251
|
+
this._nodeInfo.setDunderAllInfo(node, {
|
|
195
252
|
names: this._dunderAllNames,
|
|
196
253
|
stringNodes: this._dunderAllStringNodes,
|
|
197
254
|
usesUnsupportedDunderAllForm: this._usesUnsupportedDunderAllForm,
|
|
198
255
|
});
|
|
199
256
|
}
|
|
200
257
|
else {
|
|
201
|
-
|
|
258
|
+
this._nodeInfo.setDunderAllInfo(node, /* names */ undefined);
|
|
202
259
|
}
|
|
203
260
|
// Set __all__ flags on the module symbols.
|
|
204
|
-
const scope =
|
|
261
|
+
const scope = this._nodeInfo.getScope(node);
|
|
205
262
|
if (scope && this._dunderAllNames) {
|
|
206
263
|
for (const name of this._dunderAllNames) {
|
|
207
264
|
scope.symbolTable.get(name)?.setIsInDunderAll();
|
|
@@ -219,7 +276,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
219
276
|
return false;
|
|
220
277
|
}
|
|
221
278
|
visitModuleName(node) {
|
|
222
|
-
const importResult =
|
|
279
|
+
const importResult = this._nodeInfo.getImportInfo(node);
|
|
223
280
|
(0, debug_1.assert)(importResult !== undefined);
|
|
224
281
|
if (importResult.isNativeLib) {
|
|
225
282
|
return true;
|
|
@@ -278,17 +335,17 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
278
335
|
symbol.addDeclaration(classDeclaration);
|
|
279
336
|
}
|
|
280
337
|
// Stash the declaration in the parse node for later access.
|
|
281
|
-
|
|
338
|
+
this._nodeInfo.setDeclaration(node, classDeclaration);
|
|
282
339
|
let typeParamScope;
|
|
283
340
|
if (node.d.typeParams) {
|
|
284
341
|
this.walk(node.d.typeParams);
|
|
285
|
-
typeParamScope =
|
|
342
|
+
typeParamScope = this._nodeInfo.getScope(node.d.typeParams);
|
|
286
343
|
}
|
|
287
344
|
this.walkMultiple(node.d.arguments);
|
|
288
345
|
this._createNewScope(3 /* ScopeType.Class */, typeParamScope ?? this._getNonClassParentScope(),
|
|
289
346
|
/* proxyScope */ undefined,
|
|
290
347
|
/* chainedModuleLevelScopeLookup */ undefined, () => {
|
|
291
|
-
|
|
348
|
+
this._nodeInfo.setScope(node, this._currentScope);
|
|
292
349
|
this._addImplicitSymbolToCurrentScope('__doc__', node, 'str | None');
|
|
293
350
|
this._addImplicitSymbolToCurrentScope('__module__', node, 'str');
|
|
294
351
|
this._dunderSlotsEntries = undefined;
|
|
@@ -330,7 +387,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
330
387
|
}
|
|
331
388
|
visitFunction(node) {
|
|
332
389
|
this._createVariableAnnotationFlowNode();
|
|
333
|
-
|
|
390
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
334
391
|
const symbol = this._bindNameToScope(this._currentScope, node.d.name);
|
|
335
392
|
const containingClassNode = ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true);
|
|
336
393
|
const functionDeclaration = {
|
|
@@ -347,7 +404,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
347
404
|
symbol.addDeclaration(functionDeclaration);
|
|
348
405
|
}
|
|
349
406
|
// Stash the declaration in the parse node for later access.
|
|
350
|
-
|
|
407
|
+
this._nodeInfo.setDeclaration(node, functionDeclaration);
|
|
351
408
|
// Walk the default values prior to the type parameters.
|
|
352
409
|
node.d.params.forEach((param) => {
|
|
353
410
|
if (param.d.defaultValue) {
|
|
@@ -357,7 +414,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
357
414
|
let typeParamScope;
|
|
358
415
|
if (node.d.typeParams) {
|
|
359
416
|
this.walk(node.d.typeParams);
|
|
360
|
-
typeParamScope =
|
|
417
|
+
typeParamScope = this._nodeInfo.getScope(node.d.typeParams);
|
|
361
418
|
}
|
|
362
419
|
this.walkMultiple(node.d.decorators);
|
|
363
420
|
node.d.params.forEach((param) => {
|
|
@@ -379,7 +436,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
379
436
|
this._createNewScope(2 /* ScopeType.Function */, typeParamScope ?? this._getNonClassParentScope(),
|
|
380
437
|
/* proxyScope */ undefined,
|
|
381
438
|
/* chainedModuleLevelScopeLookup */ undefined, () => {
|
|
382
|
-
|
|
439
|
+
this._nodeInfo.setScope(node, this._currentScope);
|
|
383
440
|
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
|
384
441
|
if (enclosingClass) {
|
|
385
442
|
// Add the implicit "__class__" symbol described in PEP 3135.
|
|
@@ -402,7 +459,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
402
459
|
isInExceptSuite: this._isInExceptSuite,
|
|
403
460
|
};
|
|
404
461
|
symbol.addDeclaration(paramDeclaration);
|
|
405
|
-
|
|
462
|
+
this._nodeInfo.setDeclaration(paramNode.d.name, paramDeclaration);
|
|
406
463
|
}
|
|
407
464
|
this._createFlowAssignment(paramNode.d.name);
|
|
408
465
|
}
|
|
@@ -414,15 +471,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
414
471
|
this._targetFunctionDeclaration = undefined;
|
|
415
472
|
// Associate the code flow node at the end of the suite with
|
|
416
473
|
// the suite.
|
|
417
|
-
|
|
474
|
+
this._nodeInfo.setAfterFlowNode(node.d.suite, this._currentFlowNode);
|
|
418
475
|
// Compute the final return flow node and associate it with
|
|
419
476
|
// the function's parse node. If this node is unreachable, then
|
|
420
477
|
// the function never returns.
|
|
421
478
|
this._addAntecedent(this._currentReturnTarget, this._currentFlowNode);
|
|
422
479
|
const returnFlowNode = this._finishFlowLabel(this._currentReturnTarget);
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
480
|
+
this._nodeInfo.setAfterFlowNode(node, returnFlowNode);
|
|
481
|
+
this._nodeInfo.setCodeFlowExpressions(node, this._currentScopeCodeFlowExpressions);
|
|
482
|
+
this._nodeInfo.setCodeFlowComplexity(node, this._codeFlowComplexity);
|
|
426
483
|
});
|
|
427
484
|
});
|
|
428
485
|
this._createAssignmentTargetFlowNodes(node.d.name, /* walkTargets */ false, /* unbound */ false);
|
|
@@ -431,7 +488,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
431
488
|
}
|
|
432
489
|
visitLambda(node) {
|
|
433
490
|
this._createVariableAnnotationFlowNode();
|
|
434
|
-
|
|
491
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
435
492
|
// Analyze the parameter defaults in the context of the parent's scope
|
|
436
493
|
// before we add any names from the function's scope.
|
|
437
494
|
node.d.params.forEach((param) => {
|
|
@@ -442,7 +499,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
442
499
|
this._createNewScope(2 /* ScopeType.Function */, this._getNonClassParentScope(),
|
|
443
500
|
/* proxyScope */ undefined,
|
|
444
501
|
/* chainedModuleLevelScopeLookup */ undefined, () => {
|
|
445
|
-
|
|
502
|
+
this._nodeInfo.setScope(node, this._currentScope);
|
|
446
503
|
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
|
447
504
|
if (enclosingClass) {
|
|
448
505
|
// Lambdas create the same implicit __class__ closure as named functions.
|
|
@@ -464,28 +521,31 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
464
521
|
isInExceptSuite: this._isInExceptSuite,
|
|
465
522
|
};
|
|
466
523
|
symbol.addDeclaration(paramDeclaration);
|
|
467
|
-
|
|
524
|
+
this._nodeInfo.setDeclaration(paramNode.d.name, paramDeclaration);
|
|
468
525
|
}
|
|
469
526
|
this._createFlowAssignment(paramNode.d.name);
|
|
470
527
|
this.walk(paramNode.d.name);
|
|
471
|
-
|
|
528
|
+
this._nodeInfo.setFlowNode(paramNode, this._currentFlowNode);
|
|
472
529
|
}
|
|
473
530
|
});
|
|
474
531
|
// Walk the expression that make up the lambda body.
|
|
475
532
|
this.walk(node.d.expr);
|
|
476
|
-
|
|
533
|
+
this._nodeInfo.setCodeFlowExpressions(node, this._currentScopeCodeFlowExpressions);
|
|
477
534
|
});
|
|
478
535
|
});
|
|
479
536
|
// We'll walk the child nodes in a deferred manner.
|
|
480
537
|
return false;
|
|
481
538
|
}
|
|
482
539
|
visitCall(node) {
|
|
540
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */ && doesCallExposeClassNamespace(this._currentScope, node)) {
|
|
541
|
+
this._currentScope.hasPotentiallyDynamicSymbolTable = true;
|
|
542
|
+
}
|
|
483
543
|
this._disableTrueFalseTargets(() => {
|
|
484
544
|
this.walk(node.d.leftExpr);
|
|
485
545
|
const sortedArgs = ParseTreeUtils.getArgsByRuntimeOrder(node);
|
|
486
546
|
sortedArgs.forEach((argNode) => {
|
|
487
547
|
if (this._currentFlowNode) {
|
|
488
|
-
|
|
548
|
+
this._nodeInfo.setFlowNode(argNode, this._currentFlowNode);
|
|
489
549
|
}
|
|
490
550
|
this.walk(argNode);
|
|
491
551
|
});
|
|
@@ -590,7 +650,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
590
650
|
isInExceptSuite: this._isInExceptSuite,
|
|
591
651
|
};
|
|
592
652
|
symbol.addDeclaration(paramDeclaration);
|
|
593
|
-
|
|
653
|
+
this._nodeInfo.setDeclaration(name, paramDeclaration);
|
|
594
654
|
if (typeParamsSeen.has(name.d.value)) {
|
|
595
655
|
this._addSyntaxError(localize_1.LocMessage.typeParameterExistingTypeParameter().format({ name: name.d.value }), name);
|
|
596
656
|
}
|
|
@@ -603,7 +663,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
603
663
|
this.walk(param.d.defaultExpr);
|
|
604
664
|
}
|
|
605
665
|
});
|
|
606
|
-
|
|
666
|
+
this._nodeInfo.setScope(node, typeParamScope);
|
|
607
667
|
return false;
|
|
608
668
|
}
|
|
609
669
|
visitTypeAlias(node) {
|
|
@@ -612,7 +672,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
612
672
|
let typeParamScope;
|
|
613
673
|
if (node.d.typeParams) {
|
|
614
674
|
this.walk(node.d.typeParams);
|
|
615
|
-
typeParamScope =
|
|
675
|
+
typeParamScope = this._nodeInfo.getScope(node.d.typeParams);
|
|
616
676
|
}
|
|
617
677
|
const typeAliasDeclaration = {
|
|
618
678
|
type: 4 /* DeclarationType.TypeAlias */,
|
|
@@ -628,7 +688,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
628
688
|
symbol.addDeclaration(typeAliasDeclaration);
|
|
629
689
|
}
|
|
630
690
|
// Stash the declaration in the parse node for later access.
|
|
631
|
-
|
|
691
|
+
this._nodeInfo.setDeclaration(node, typeAliasDeclaration);
|
|
632
692
|
this._createAssignmentTargetFlowNodes(node.d.name, /* walkTargets */ true, /* unbound */ false);
|
|
633
693
|
const prevScope = this._currentScope;
|
|
634
694
|
this._currentScope = typeParamScope ?? this._currentScope;
|
|
@@ -766,9 +826,23 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
766
826
|
}
|
|
767
827
|
});
|
|
768
828
|
}
|
|
829
|
+
else if (expr.nodeType === 18 /* ParseNodeType.Dictionary */) {
|
|
830
|
+
expr.d.items.forEach((dictionaryEntryNode) => {
|
|
831
|
+
if (dictionaryEntryNode.nodeType === 20 /* ParseNodeType.DictionaryKeyEntry */ &&
|
|
832
|
+
dictionaryEntryNode.d.keyExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
|
|
833
|
+
dictionaryEntryNode.d.keyExpr.d.strings.length === 1 &&
|
|
834
|
+
dictionaryEntryNode.d.keyExpr.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
|
|
835
|
+
this._dunderSlotsEntries.push(dictionaryEntryNode.d.keyExpr);
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
isExpressionUnderstood = false;
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
}
|
|
769
842
|
else {
|
|
770
843
|
isExpressionUnderstood = false;
|
|
771
844
|
}
|
|
845
|
+
this._currentScope.setHasNonEmptySlots(this._dunderSlotsEntries.some((entry) => entry.d.strings[0].d.value !== '__dict__'));
|
|
772
846
|
if (!isExpressionUnderstood) {
|
|
773
847
|
this._dunderSlotsEntries = undefined;
|
|
774
848
|
}
|
|
@@ -783,7 +857,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
783
857
|
// Evaluate the operand expression.
|
|
784
858
|
this.walk(node.d.rightExpr);
|
|
785
859
|
});
|
|
786
|
-
const evaluationNode = ParseTreeUtils.getEvaluationNodeForAssignmentExpression(node);
|
|
860
|
+
const evaluationNode = ParseTreeUtils.getEvaluationNodeForAssignmentExpression(node, this._nodeInfo);
|
|
787
861
|
if (!evaluationNode) {
|
|
788
862
|
this._addSyntaxError(localize_1.LocMessage.assignmentExprContext(), node);
|
|
789
863
|
this.walk(node.d.name);
|
|
@@ -793,7 +867,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
793
867
|
// because of the behavior defined in PEP 572. Targets of assignment
|
|
794
868
|
// expressions don't bind to a list comprehension's scope but instead
|
|
795
869
|
// bind to its containing scope.
|
|
796
|
-
const containerScope =
|
|
870
|
+
const containerScope = this._nodeInfo.getScope(evaluationNode);
|
|
797
871
|
// If we're in a list comprehension (possibly nested), make sure that
|
|
798
872
|
// local for targets don't collide with the target of the assignment
|
|
799
873
|
// expression.
|
|
@@ -997,10 +1071,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
997
1071
|
this._targetFunctionDeclaration.returnStatements.push(node);
|
|
998
1072
|
}
|
|
999
1073
|
if (node.d.expr) {
|
|
1000
|
-
|
|
1074
|
+
this._nodeInfo.setFlowNode(node.d.expr, this._currentFlowNode);
|
|
1001
1075
|
this.walk(node.d.expr);
|
|
1002
1076
|
}
|
|
1003
|
-
|
|
1077
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
1004
1078
|
if (this._currentReturnTarget) {
|
|
1005
1079
|
this._addAntecedent(this._currentReturnTarget, this._currentFlowNode);
|
|
1006
1080
|
}
|
|
@@ -1026,15 +1100,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1026
1100
|
}
|
|
1027
1101
|
visitMemberAccess(node) {
|
|
1028
1102
|
this.walk(node.d.leftExpr);
|
|
1029
|
-
|
|
1103
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
1030
1104
|
return false;
|
|
1031
1105
|
}
|
|
1032
1106
|
visitName(node) {
|
|
1033
|
-
|
|
1107
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
1034
1108
|
return false;
|
|
1035
1109
|
}
|
|
1036
1110
|
visitIndex(node) {
|
|
1037
|
-
|
|
1111
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
1038
1112
|
this.walk(node.d.leftExpr);
|
|
1039
1113
|
// If we're within an 'Annotated' type annotation, set the flag.
|
|
1040
1114
|
const wasInAnnotatedAnnotation = this._isInAnnotatedAnnotation;
|
|
@@ -1056,7 +1130,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1056
1130
|
// Determine if the test condition is always true or always false. If so,
|
|
1057
1131
|
// we can treat either the then or the else clause as unconditional.
|
|
1058
1132
|
const constExprValue = StaticExpressions.evaluateStaticBoolLikeExpression(node.d.testExpr, this._fileInfo.executionEnvironment, this._fileInfo.definedConstants, this._typingImportAliases, this._sysImportAliases);
|
|
1059
|
-
|
|
1133
|
+
this._nodeInfo.setStaticConditionValue(node, constExprValue);
|
|
1060
1134
|
this._bindConditional(node.d.testExpr, thenLabel, elseLabel);
|
|
1061
1135
|
// Handle the if clause.
|
|
1062
1136
|
this._currentFlowNode =
|
|
@@ -1295,7 +1369,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1295
1369
|
}
|
|
1296
1370
|
visitAwait(node) {
|
|
1297
1371
|
// Make sure this is within an async lambda or function.
|
|
1298
|
-
const execScopeNode = ParseTreeUtils.getExecutionScopeNode(node);
|
|
1372
|
+
const execScopeNode = ParseTreeUtils.getExecutionScopeNode(node, this._nodeInfo);
|
|
1299
1373
|
if (execScopeNode?.nodeType !== 31 /* ParseNodeType.Function */ || !execScopeNode.d.isAsync) {
|
|
1300
1374
|
if (this._fileInfo.ipythonMode && execScopeNode?.nodeType === 36 /* ParseNodeType.Module */) {
|
|
1301
1375
|
// Top level await is allowed in ipython mode.
|
|
@@ -1392,7 +1466,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1392
1466
|
this._potentialHiddenSymbols.set(symbolName, symbol);
|
|
1393
1467
|
}
|
|
1394
1468
|
}
|
|
1395
|
-
const importInfo =
|
|
1469
|
+
const importInfo = this._nodeInfo.getImportInfo(node.d.module);
|
|
1396
1470
|
(0, debug_1.assert)(importInfo !== undefined);
|
|
1397
1471
|
if (symbol) {
|
|
1398
1472
|
this._createAliasDeclarationForMultipartImportName(node, node.d.alias, importInfo, symbol);
|
|
@@ -1414,9 +1488,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1414
1488
|
}
|
|
1415
1489
|
visitImportFrom(node) {
|
|
1416
1490
|
const typingSymbolsOfInterest = ['Final', 'ClassVar', 'Annotated'];
|
|
1417
|
-
const dataclassesSymbolsOfInterest = ['InitVar'];
|
|
1418
|
-
const importInfo =
|
|
1419
|
-
|
|
1491
|
+
const dataclassesSymbolsOfInterest = ['InitVar', 'KW_ONLY'];
|
|
1492
|
+
const importInfo = this._nodeInfo.getImportInfo(node.d.module);
|
|
1493
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
1420
1494
|
let resolvedPath = uri_1.Uri.empty();
|
|
1421
1495
|
if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib) {
|
|
1422
1496
|
resolvedPath = importInfo.resolvedUris[importInfo.resolvedUris.length - 1];
|
|
@@ -1556,7 +1630,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1556
1630
|
node.d.imports.forEach((importSymbolNode) => {
|
|
1557
1631
|
const importedName = importSymbolNode.d.name.d.value;
|
|
1558
1632
|
const nameNode = importSymbolNode.d.alias || importSymbolNode.d.name;
|
|
1559
|
-
|
|
1633
|
+
this._nodeInfo.setFlowNode(importSymbolNode, this._currentFlowNode);
|
|
1560
1634
|
const symbol = this._bindNameToScope(this._currentScope, nameNode);
|
|
1561
1635
|
if (symbol) {
|
|
1562
1636
|
// All import statements of the form `from . import x` treat x
|
|
@@ -1785,7 +1859,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1785
1859
|
this._createNewScope(1 /* ScopeType.Comprehension */, this._getNonClassParentScope(),
|
|
1786
1860
|
/* proxyScope */ undefined,
|
|
1787
1861
|
/* chainedModuleLevelScopeLookup */ undefined, () => {
|
|
1788
|
-
|
|
1862
|
+
this._nodeInfo.setScope(node, this._currentScope);
|
|
1789
1863
|
const falseLabel = this._createBranchLabel();
|
|
1790
1864
|
// We'll walk the forIfNodes list twice. The first time we'll
|
|
1791
1865
|
// bind targets of for statements. The second time we'll walk
|
|
@@ -2123,7 +2197,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2123
2197
|
}
|
|
2124
2198
|
_createAliasDeclarationForMultipartImportName(node, importAlias, importInfo, symbol) {
|
|
2125
2199
|
const firstNamePartValue = node.d.module.d.nameParts[0].d.value;
|
|
2126
|
-
|
|
2200
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
2127
2201
|
let uriOfFirstSubmodule;
|
|
2128
2202
|
if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib && importInfo.resolvedUris.length > 0) {
|
|
2129
2203
|
uriOfFirstSubmodule = importInfo.resolvedUris[0];
|
|
@@ -2199,7 +2273,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2199
2273
|
}
|
|
2200
2274
|
// See if there is import info for this part of the path. This allows us
|
|
2201
2275
|
// to implicitly import all of the modules in a multi-part module name.
|
|
2202
|
-
const implicitImportInfo =
|
|
2276
|
+
const implicitImportInfo = this._nodeInfo.getImportInfo(node.d.module.d.nameParts[0]);
|
|
2203
2277
|
if (implicitImportInfo && implicitImportInfo.resolvedUris.length) {
|
|
2204
2278
|
newDecl.uri = implicitImportInfo.resolvedUris[0];
|
|
2205
2279
|
newDecl.loadSymbolsFromPath = true;
|
|
@@ -2254,7 +2328,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2254
2328
|
// is import info for this part of the path. This allows us to implicitly
|
|
2255
2329
|
// import all of the modules in a multi-part module name (e.g. "import a.b.c"
|
|
2256
2330
|
// imports "a" and "a.b" and "a.b.c").
|
|
2257
|
-
const implicitImportInfo =
|
|
2331
|
+
const implicitImportInfo = this._nodeInfo.getImportInfo(node.d.module.d.nameParts[i]);
|
|
2258
2332
|
if (implicitImportInfo && implicitImportInfo.resolvedUris.length) {
|
|
2259
2333
|
loaderActions.uri = implicitImportInfo.resolvedUris[i];
|
|
2260
2334
|
loaderActions.loadSymbolsFromPath = true;
|
|
@@ -2271,7 +2345,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2271
2345
|
_walkStatementsAndReportUnreachable(statements) {
|
|
2272
2346
|
let foundUnreachableStatement = false;
|
|
2273
2347
|
for (const statement of statements) {
|
|
2274
|
-
|
|
2348
|
+
this._nodeInfo.setFlowNode(statement, this._currentFlowNode);
|
|
2275
2349
|
if (!foundUnreachableStatement) {
|
|
2276
2350
|
foundUnreachableStatement = this._isCodeUnreachable();
|
|
2277
2351
|
}
|
|
@@ -2292,7 +2366,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2292
2366
|
// subtree, we need to create dummy scopes for them. The type analyzer
|
|
2293
2367
|
// depends on scopes being present.
|
|
2294
2368
|
if (!this._moduleSymbolOnly) {
|
|
2295
|
-
const dummyScopeGenerator = new DummyScopeGenerator(this._currentScope);
|
|
2369
|
+
const dummyScopeGenerator = new DummyScopeGenerator(this._currentScope, this._nodeInfo);
|
|
2296
2370
|
dummyScopeGenerator.walk(statement);
|
|
2297
2371
|
}
|
|
2298
2372
|
}
|
|
@@ -2768,8 +2842,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2768
2842
|
// introduced in except clauses. If there is no use the previous flow node
|
|
2769
2843
|
// associated, use the previous flow node (applies in the del case).
|
|
2770
2844
|
// Otherwise, the node will be evaluated as unbound at this point in the flow.
|
|
2771
|
-
if (!unbound ||
|
|
2772
|
-
|
|
2845
|
+
if (!unbound || this._nodeInfo.getFlowNode(node) === undefined) {
|
|
2846
|
+
this._nodeInfo.setFlowNode(node, unbound ? prevFlowNode : this._currentFlowNode);
|
|
2773
2847
|
}
|
|
2774
2848
|
}
|
|
2775
2849
|
_createFlowWildcardImport(node, names) {
|
|
@@ -2784,7 +2858,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2784
2858
|
this._addExceptTargets(flowNode);
|
|
2785
2859
|
this._currentFlowNode = flowNode;
|
|
2786
2860
|
}
|
|
2787
|
-
|
|
2861
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
2788
2862
|
}
|
|
2789
2863
|
_createFlowExhaustedMatch(node) {
|
|
2790
2864
|
if (!this._isCodeUnreachable()) {
|
|
@@ -2797,7 +2871,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2797
2871
|
};
|
|
2798
2872
|
this._currentFlowNode = flowNode;
|
|
2799
2873
|
}
|
|
2800
|
-
|
|
2874
|
+
this._nodeInfo.setAfterFlowNode(node, this._currentFlowNode);
|
|
2801
2875
|
}
|
|
2802
2876
|
_isCodeUnreachable() {
|
|
2803
2877
|
return !!(this._currentFlowNode.flags &
|
|
@@ -2893,6 +2967,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2893
2967
|
return undefined;
|
|
2894
2968
|
}
|
|
2895
2969
|
_bindPossibleTupleNamedTarget(target, addedSymbols) {
|
|
2970
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */ && !isStaticClassAssignmentTarget(target)) {
|
|
2971
|
+
this._currentScope.hasPotentiallyDynamicSymbolTable = true;
|
|
2972
|
+
}
|
|
2896
2973
|
switch (target.nodeType) {
|
|
2897
2974
|
case 38 /* ParseNodeType.Name */: {
|
|
2898
2975
|
this._bindNameToScope(this._currentScope, target, addedSymbols);
|
|
@@ -2986,7 +3063,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2986
3063
|
// state so that hits from later cells are correctly marked.
|
|
2987
3064
|
return (name, context) => {
|
|
2988
3065
|
for (const moduleNode of cellChainIndex.getLaterModuleNodes(fileUri) ?? []) {
|
|
2989
|
-
const moduleScope =
|
|
3066
|
+
const moduleScope = this._nodeInfo.getScope(moduleNode);
|
|
2990
3067
|
if (!moduleScope) {
|
|
2991
3068
|
continue;
|
|
2992
3069
|
}
|
|
@@ -3183,6 +3260,15 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3183
3260
|
}
|
|
3184
3261
|
}
|
|
3185
3262
|
}
|
|
3263
|
+
if (this._isDataclassesAnnotation(typeAnnotation, 'KW_ONLY')) {
|
|
3264
|
+
symbolWithScope.symbol.setIsDataClassKeywordOnly();
|
|
3265
|
+
}
|
|
3266
|
+
else if (typeAnnotation.nodeType === 27 /* ParseNodeType.Index */ &&
|
|
3267
|
+
this._isTypingAnnotation(typeAnnotation.d.leftExpr, 'Annotated') &&
|
|
3268
|
+
typeAnnotation.d.items.length > 0 &&
|
|
3269
|
+
this._isDataclassesAnnotation(typeAnnotation.d.items[0].d.valueExpr, 'KW_ONLY')) {
|
|
3270
|
+
symbolWithScope.symbol.setIsDataClassKeywordOnly();
|
|
3271
|
+
}
|
|
3186
3272
|
}
|
|
3187
3273
|
declarationHandled = true;
|
|
3188
3274
|
break;
|
|
@@ -3249,8 +3335,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3249
3335
|
_isKnownAnnotation(typeAnnotation, name, importAliases, symbolAliases) {
|
|
3250
3336
|
let annotationNode = typeAnnotation;
|
|
3251
3337
|
// Is this a quoted annotation?
|
|
3252
|
-
if (annotationNode.nodeType === 48 /* ParseNodeType.StringList */
|
|
3253
|
-
annotationNode =
|
|
3338
|
+
if (annotationNode.nodeType === 48 /* ParseNodeType.StringList */) {
|
|
3339
|
+
annotationNode = this._nodeInfo.getStringAnnotation(annotationNode) ?? annotationNode;
|
|
3254
3340
|
}
|
|
3255
3341
|
if (annotationNode.nodeType === 38 /* ParseNodeType.Name */) {
|
|
3256
3342
|
const alias = symbolAliases.get(annotationNode.d.value);
|
|
@@ -3322,8 +3408,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3322
3408
|
let classVarTypeNode;
|
|
3323
3409
|
while (typeAnnotation) {
|
|
3324
3410
|
// Is this a quoted annotation?
|
|
3325
|
-
if (typeAnnotation.nodeType === 48 /* ParseNodeType.StringList */
|
|
3326
|
-
typeAnnotation =
|
|
3411
|
+
if (typeAnnotation.nodeType === 48 /* ParseNodeType.StringList */) {
|
|
3412
|
+
typeAnnotation = this._nodeInfo.getStringAnnotation(typeAnnotation) ?? typeAnnotation;
|
|
3327
3413
|
}
|
|
3328
3414
|
if (typeAnnotation.nodeType === 27 /* ParseNodeType.Index */ &&
|
|
3329
3415
|
typeAnnotation.d.items.length > 0 &&
|
|
@@ -3422,7 +3508,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3422
3508
|
}
|
|
3423
3509
|
}
|
|
3424
3510
|
}
|
|
3425
|
-
const classScope =
|
|
3511
|
+
const classScope = this._nodeInfo.getScope(classNode);
|
|
3426
3512
|
(0, debug_1.assert)(classScope !== undefined);
|
|
3427
3513
|
return {
|
|
3428
3514
|
classNode,
|
|
@@ -3629,7 +3715,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3629
3715
|
if (symbol) {
|
|
3630
3716
|
symbol.addDeclaration(specialBuiltInClassDeclaration);
|
|
3631
3717
|
}
|
|
3632
|
-
|
|
3718
|
+
this._nodeInfo.setDeclaration(node, specialBuiltInClassDeclaration);
|
|
3633
3719
|
return true;
|
|
3634
3720
|
}
|
|
3635
3721
|
_deferBinding(callback) {
|
|
@@ -3673,7 +3759,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3673
3759
|
if (node.d.expr) {
|
|
3674
3760
|
this.walk(node.d.expr);
|
|
3675
3761
|
}
|
|
3676
|
-
|
|
3762
|
+
this._nodeInfo.setFlowNode(node, this._currentFlowNode);
|
|
3677
3763
|
}
|
|
3678
3764
|
_getUniqueFlowNodeId() {
|
|
3679
3765
|
this._codeFlowComplexity += flowNodeComplexityContribution;
|
|
@@ -3752,16 +3838,17 @@ exports.ReturnFinder = ReturnFinder;
|
|
|
3752
3838
|
// will still evaluate these types, and it depends on the presence
|
|
3753
3839
|
// of a scope.
|
|
3754
3840
|
class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
3755
|
-
constructor(currentScope) {
|
|
3841
|
+
constructor(currentScope, _nodeInfo) {
|
|
3756
3842
|
super();
|
|
3843
|
+
this._nodeInfo = _nodeInfo;
|
|
3757
3844
|
this._currentScope = currentScope;
|
|
3758
3845
|
}
|
|
3759
3846
|
visitClass(node) {
|
|
3760
3847
|
const newScope = this._createNewScope(3 /* ScopeType.Class */, () => {
|
|
3761
3848
|
this.walk(node.d.suite);
|
|
3762
3849
|
});
|
|
3763
|
-
if (!
|
|
3764
|
-
|
|
3850
|
+
if (!this._nodeInfo.getScope(node)) {
|
|
3851
|
+
this._nodeInfo.setScope(node, newScope);
|
|
3765
3852
|
}
|
|
3766
3853
|
return false;
|
|
3767
3854
|
}
|
|
@@ -3769,8 +3856,8 @@ class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3769
3856
|
const newScope = this._createNewScope(2 /* ScopeType.Function */, () => {
|
|
3770
3857
|
this.walk(node.d.suite);
|
|
3771
3858
|
});
|
|
3772
|
-
if (!
|
|
3773
|
-
|
|
3859
|
+
if (!this._nodeInfo.getScope(node)) {
|
|
3860
|
+
this._nodeInfo.setScope(node, newScope);
|
|
3774
3861
|
}
|
|
3775
3862
|
return false;
|
|
3776
3863
|
}
|