@zzzen/pyright-internal 1.1.254
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/aliasDeclarationUtils.d.ts +9 -0
- package/dist/analyzer/aliasDeclarationUtils.js +128 -0
- package/dist/analyzer/aliasDeclarationUtils.js.map +1 -0
- package/dist/analyzer/analysis.d.ts +18 -0
- package/dist/analyzer/analysis.js +81 -0
- package/dist/analyzer/analysis.js.map +1 -0
- package/dist/analyzer/analyzerFileInfo.d.ts +39 -0
- package/dist/analyzer/analyzerFileInfo.js +17 -0
- package/dist/analyzer/analyzerFileInfo.js.map +1 -0
- package/dist/analyzer/analyzerNodeInfo.d.ts +32 -0
- package/dist/analyzer/analyzerNodeInfo.js +138 -0
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -0
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +54 -0
- package/dist/analyzer/backgroundAnalysisProgram.js +222 -0
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -0
- package/dist/analyzer/binder.d.ts +149 -0
- package/dist/analyzer/binder.js +3195 -0
- package/dist/analyzer/binder.js.map +1 -0
- package/dist/analyzer/checker.d.ts +116 -0
- package/dist/analyzer/checker.js +3828 -0
- package/dist/analyzer/checker.js.map +1 -0
- package/dist/analyzer/circularDependency.d.ts +7 -0
- package/dist/analyzer/circularDependency.js +51 -0
- package/dist/analyzer/circularDependency.js.map +1 -0
- package/dist/analyzer/codeFlowEngine.d.ts +21 -0
- package/dist/analyzer/codeFlowEngine.js +1132 -0
- package/dist/analyzer/codeFlowEngine.js.map +1 -0
- package/dist/analyzer/codeFlowTypes.d.ts +82 -0
- package/dist/analyzer/codeFlowTypes.js +134 -0
- package/dist/analyzer/codeFlowTypes.js.map +1 -0
- package/dist/analyzer/codeFlowUtils.d.ts +2 -0
- package/dist/analyzer/codeFlowUtils.js +348 -0
- package/dist/analyzer/codeFlowUtils.js.map +1 -0
- package/dist/analyzer/commentUtils.d.ts +4 -0
- package/dist/analyzer/commentUtils.js +131 -0
- package/dist/analyzer/commentUtils.js.map +1 -0
- package/dist/analyzer/constraintSolver.d.ts +7 -0
- package/dist/analyzer/constraintSolver.js +605 -0
- package/dist/analyzer/constraintSolver.js.map +1 -0
- package/dist/analyzer/constructorTransform.d.ts +4 -0
- package/dist/analyzer/constructorTransform.js +219 -0
- package/dist/analyzer/constructorTransform.js.map +1 -0
- package/dist/analyzer/dataClasses.d.ts +9 -0
- package/dist/analyzer/dataClasses.js +762 -0
- package/dist/analyzer/dataClasses.js.map +1 -0
- package/dist/analyzer/declaration.d.ts +90 -0
- package/dist/analyzer/declaration.js +42 -0
- package/dist/analyzer/declaration.js.map +1 -0
- package/dist/analyzer/declarationUtils.d.ts +12 -0
- package/dist/analyzer/declarationUtils.js +212 -0
- package/dist/analyzer/declarationUtils.js.map +1 -0
- package/dist/analyzer/docStringConversion.d.ts +2 -0
- package/dist/analyzer/docStringConversion.js +699 -0
- package/dist/analyzer/docStringConversion.js.map +1 -0
- package/dist/analyzer/docStringUtils.d.ts +3 -0
- package/dist/analyzer/docStringUtils.js +103 -0
- package/dist/analyzer/docStringUtils.js.map +1 -0
- package/dist/analyzer/functionTransform.d.ts +4 -0
- package/dist/analyzer/functionTransform.js +96 -0
- package/dist/analyzer/functionTransform.js.map +1 -0
- package/dist/analyzer/importResolver.d.ts +97 -0
- package/dist/analyzer/importResolver.js +1617 -0
- package/dist/analyzer/importResolver.js.map +1 -0
- package/dist/analyzer/importResult.d.ts +33 -0
- package/dist/analyzer/importResult.js +11 -0
- package/dist/analyzer/importResult.js.map +1 -0
- package/dist/analyzer/importStatementUtils.d.ts +46 -0
- package/dist/analyzer/importStatementUtils.js +618 -0
- package/dist/analyzer/importStatementUtils.js.map +1 -0
- package/dist/analyzer/namedTuples.d.ts +5 -0
- package/dist/analyzer/namedTuples.js +342 -0
- package/dist/analyzer/namedTuples.js.map +1 -0
- package/dist/analyzer/packageTypeReport.d.ts +52 -0
- package/dist/analyzer/packageTypeReport.js +45 -0
- package/dist/analyzer/packageTypeReport.js.map +1 -0
- package/dist/analyzer/packageTypeVerifier.d.ts +37 -0
- package/dist/analyzer/packageTypeVerifier.js +908 -0
- package/dist/analyzer/packageTypeVerifier.js.map +1 -0
- package/dist/analyzer/parentDirectoryCache.d.ts +23 -0
- package/dist/analyzer/parentDirectoryCache.js +71 -0
- package/dist/analyzer/parentDirectoryCache.js.map +1 -0
- package/dist/analyzer/parseTreeCleaner.d.ts +8 -0
- package/dist/analyzer/parseTreeCleaner.js +51 -0
- package/dist/analyzer/parseTreeCleaner.js.map +1 -0
- package/dist/analyzer/parseTreeUtils.d.ts +98 -0
- package/dist/analyzer/parseTreeUtils.js +1753 -0
- package/dist/analyzer/parseTreeUtils.js.map +1 -0
- package/dist/analyzer/parseTreeWalker.d.ts +81 -0
- package/dist/analyzer/parseTreeWalker.js +437 -0
- package/dist/analyzer/parseTreeWalker.js.map +1 -0
- package/dist/analyzer/patternMatching.d.ts +6 -0
- package/dist/analyzer/patternMatching.js +866 -0
- package/dist/analyzer/patternMatching.js.map +1 -0
- package/dist/analyzer/program.d.ts +158 -0
- package/dist/analyzer/program.js +1902 -0
- package/dist/analyzer/program.js.map +1 -0
- package/dist/analyzer/properties.d.ts +10 -0
- package/dist/analyzer/properties.js +368 -0
- package/dist/analyzer/properties.js.map +1 -0
- package/dist/analyzer/protocols.d.ts +8 -0
- package/dist/analyzer/protocols.js +409 -0
- package/dist/analyzer/protocols.js.map +1 -0
- package/dist/analyzer/pyTypedUtils.d.ts +6 -0
- package/dist/analyzer/pyTypedUtils.js +42 -0
- package/dist/analyzer/pyTypedUtils.js.map +1 -0
- package/dist/analyzer/pythonPathUtils.d.ts +14 -0
- package/dist/analyzer/pythonPathUtils.js +173 -0
- package/dist/analyzer/pythonPathUtils.js.map +1 -0
- package/dist/analyzer/scope.d.ts +39 -0
- package/dist/analyzer/scope.js +110 -0
- package/dist/analyzer/scope.js.map +1 -0
- package/dist/analyzer/scopeUtils.d.ts +6 -0
- package/dist/analyzer/scopeUtils.js +72 -0
- package/dist/analyzer/scopeUtils.js.map +1 -0
- package/dist/analyzer/service.d.ts +144 -0
- package/dist/analyzer/service.js +1197 -0
- package/dist/analyzer/service.js.map +1 -0
- package/dist/analyzer/sourceFile.d.ts +123 -0
- package/dist/analyzer/sourceFile.js +908 -0
- package/dist/analyzer/sourceFile.js.map +1 -0
- package/dist/analyzer/sourceMapper.d.ts +47 -0
- package/dist/analyzer/sourceMapper.js +543 -0
- package/dist/analyzer/sourceMapper.js.map +1 -0
- package/dist/analyzer/staticExpressions.d.ts +4 -0
- package/dist/analyzer/staticExpressions.js +242 -0
- package/dist/analyzer/staticExpressions.js.map +1 -0
- package/dist/analyzer/symbol.d.ts +50 -0
- package/dist/analyzer/symbol.js +160 -0
- package/dist/analyzer/symbol.js.map +1 -0
- package/dist/analyzer/symbolNameUtils.d.ts +8 -0
- package/dist/analyzer/symbolNameUtils.js +53 -0
- package/dist/analyzer/symbolNameUtils.js.map +1 -0
- package/dist/analyzer/symbolUtils.d.ts +7 -0
- package/dist/analyzer/symbolUtils.js +46 -0
- package/dist/analyzer/symbolUtils.js.map +1 -0
- package/dist/analyzer/testWalker.d.ts +14 -0
- package/dist/analyzer/testWalker.js +92 -0
- package/dist/analyzer/testWalker.js.map +1 -0
- package/dist/analyzer/tracePrinter.d.ts +11 -0
- package/dist/analyzer/tracePrinter.js +222 -0
- package/dist/analyzer/tracePrinter.js.map +1 -0
- package/dist/analyzer/typeCache.d.ts +40 -0
- package/dist/analyzer/typeCache.js +134 -0
- package/dist/analyzer/typeCache.js.map +1 -0
- package/dist/analyzer/typeDocStringUtils.d.ts +12 -0
- package/dist/analyzer/typeDocStringUtils.js +293 -0
- package/dist/analyzer/typeDocStringUtils.js.map +1 -0
- package/dist/analyzer/typeEvaluator.d.ts +18 -0
- package/dist/analyzer/typeEvaluator.js +16598 -0
- package/dist/analyzer/typeEvaluator.js.map +1 -0
- package/dist/analyzer/typeEvaluatorTypes.d.ts +220 -0
- package/dist/analyzer/typeEvaluatorTypes.js +16 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -0
- package/dist/analyzer/typeEvaluatorWithTracker.d.ts +6 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js +121 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -0
- package/dist/analyzer/typeGuards.d.ts +6 -0
- package/dist/analyzer/typeGuards.js +1293 -0
- package/dist/analyzer/typeGuards.js.map +1 -0
- package/dist/analyzer/typePrinter.d.ts +17 -0
- package/dist/analyzer/typePrinter.js +603 -0
- package/dist/analyzer/typePrinter.js.map +1 -0
- package/dist/analyzer/typeStubWriter.d.ts +48 -0
- package/dist/analyzer/typeStubWriter.js +605 -0
- package/dist/analyzer/typeStubWriter.js.map +1 -0
- package/dist/analyzer/typeUtils.d.ts +134 -0
- package/dist/analyzer/typeUtils.js +2380 -0
- package/dist/analyzer/typeUtils.js.map +1 -0
- package/dist/analyzer/typeVarContext.d.ts +50 -0
- package/dist/analyzer/typeVarContext.js +250 -0
- package/dist/analyzer/typeVarContext.js.map +1 -0
- package/dist/analyzer/typedDicts.d.ts +12 -0
- package/dist/analyzer/typedDicts.js +695 -0
- package/dist/analyzer/typedDicts.js.map +1 -0
- package/dist/analyzer/types.d.ts +484 -0
- package/dist/analyzer/types.js +1844 -0
- package/dist/analyzer/types.js.map +1 -0
- package/dist/backgroundAnalysis.d.ts +14 -0
- package/dist/backgroundAnalysis.js +42 -0
- package/dist/backgroundAnalysis.js.map +1 -0
- package/dist/backgroundAnalysisBase.d.ts +83 -0
- package/dist/backgroundAnalysisBase.js +429 -0
- package/dist/backgroundAnalysisBase.js.map +1 -0
- package/dist/backgroundThreadBase.d.ts +34 -0
- package/dist/backgroundThreadBase.js +134 -0
- package/dist/backgroundThreadBase.js.map +1 -0
- package/dist/commands/commandController.d.ts +13 -0
- package/dist/commands/commandController.js +48 -0
- package/dist/commands/commandController.js.map +1 -0
- package/dist/commands/commandResult.d.ts +9 -0
- package/dist/commands/commandResult.js +19 -0
- package/dist/commands/commandResult.js.map +1 -0
- package/dist/commands/commands.d.ts +7 -0
- package/dist/commands/commands.js +11 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/commands/createTypeStub.d.ts +8 -0
- package/dist/commands/createTypeStub.js +50 -0
- package/dist/commands/createTypeStub.js.map +1 -0
- package/dist/commands/quickActionCommand.d.ts +8 -0
- package/dist/commands/quickActionCommand.js +31 -0
- package/dist/commands/quickActionCommand.js.map +1 -0
- package/dist/commands/restartServer.d.ts +8 -0
- package/dist/commands/restartServer.js +20 -0
- package/dist/commands/restartServer.js.map +1 -0
- package/dist/common/cancellationUtils.d.ts +16 -0
- package/dist/common/cancellationUtils.js +60 -0
- package/dist/common/cancellationUtils.js.map +1 -0
- package/dist/common/chokidarFileWatcherProvider.d.ts +9 -0
- package/dist/common/chokidarFileWatcherProvider.js +88 -0
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -0
- package/dist/common/collectionUtils.d.ts +114 -0
- package/dist/common/collectionUtils.js +292 -0
- package/dist/common/collectionUtils.js.map +1 -0
- package/dist/common/commandLineOptions.d.ts +41 -0
- package/dist/common/commandLineOptions.js +46 -0
- package/dist/common/commandLineOptions.js.map +1 -0
- package/dist/common/configOptions.d.ts +144 -0
- package/dist/common/configOptions.js +908 -0
- package/dist/common/configOptions.js.map +1 -0
- package/dist/common/console.d.ts +61 -0
- package/dist/common/console.js +191 -0
- package/dist/common/console.js.map +1 -0
- package/dist/common/core.d.ts +67 -0
- package/dist/common/core.js +118 -0
- package/dist/common/core.js.map +1 -0
- package/dist/common/crypto.d.ts +1 -0
- package/dist/common/crypto.js +37 -0
- package/dist/common/crypto.js.map +1 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/debug.js +131 -0
- package/dist/common/debug.js.map +1 -0
- package/dist/common/deferred.d.ts +11 -0
- package/dist/common/deferred.js +62 -0
- package/dist/common/deferred.js.map +1 -0
- package/dist/common/diagnostic.d.ts +59 -0
- package/dist/common/diagnostic.js +134 -0
- package/dist/common/diagnostic.js.map +1 -0
- package/dist/common/diagnosticRules.d.ts +67 -0
- package/dist/common/diagnosticRules.js +83 -0
- package/dist/common/diagnosticRules.js.map +1 -0
- package/dist/common/diagnosticSink.d.ts +34 -0
- package/dist/common/diagnosticSink.js +110 -0
- package/dist/common/diagnosticSink.js.map +1 -0
- package/dist/common/editAction.d.ts +29 -0
- package/dist/common/editAction.js +11 -0
- package/dist/common/editAction.js.map +1 -0
- package/dist/common/extensibility.d.ts +11 -0
- package/dist/common/extensibility.js +10 -0
- package/dist/common/extensibility.js.map +1 -0
- package/dist/common/extensions.d.ts +3 -0
- package/dist/common/extensions.js +15 -0
- package/dist/common/extensions.js.map +1 -0
- package/dist/common/fileBasedCancellationUtils.d.ts +11 -0
- package/dist/common/fileBasedCancellationUtils.js +259 -0
- package/dist/common/fileBasedCancellationUtils.js.map +1 -0
- package/dist/common/fileSystem.d.ts +72 -0
- package/dist/common/fileSystem.js +69 -0
- package/dist/common/fileSystem.js.map +1 -0
- package/dist/common/fullAccessHost.d.ts +19 -0
- package/dist/common/fullAccessHost.js +193 -0
- package/dist/common/fullAccessHost.js.map +1 -0
- package/dist/common/host.d.ts +21 -0
- package/dist/common/host.js +30 -0
- package/dist/common/host.js.map +1 -0
- package/dist/common/logTracker.d.ts +15 -0
- package/dist/common/logTracker.js +129 -0
- package/dist/common/logTracker.js.map +1 -0
- package/dist/common/lspUtils.d.ts +3 -0
- package/dist/common/lspUtils.js +20 -0
- package/dist/common/lspUtils.js.map +1 -0
- package/dist/common/memUtils.d.ts +3 -0
- package/dist/common/memUtils.js +37 -0
- package/dist/common/memUtils.js.map +1 -0
- package/dist/common/pathConsts.d.ts +8 -0
- package/dist/common/pathConsts.js +19 -0
- package/dist/common/pathConsts.js.map +1 -0
- package/dist/common/pathUtils.d.ts +170 -0
- package/dist/common/pathUtils.js +762 -0
- package/dist/common/pathUtils.js.map +1 -0
- package/dist/common/positionUtils.d.ts +7 -0
- package/dist/common/positionUtils.js +71 -0
- package/dist/common/positionUtils.js.map +1 -0
- package/dist/common/progressReporter.d.ts +15 -0
- package/dist/common/progressReporter.js +44 -0
- package/dist/common/progressReporter.js.map +1 -0
- package/dist/common/pythonVersion.d.ts +20 -0
- package/dist/common/pythonVersion.js +71 -0
- package/dist/common/pythonVersion.js.map +1 -0
- package/dist/common/realFileSystem.d.ts +8 -0
- package/dist/common/realFileSystem.js +368 -0
- package/dist/common/realFileSystem.js.map +1 -0
- package/dist/common/stringUtils.d.ts +47 -0
- package/dist/common/stringUtils.js +160 -0
- package/dist/common/stringUtils.js.map +1 -0
- package/dist/common/textEditUtils.d.ts +3 -0
- package/dist/common/textEditUtils.js +29 -0
- package/dist/common/textEditUtils.js.map +1 -0
- package/dist/common/textRange.d.ts +47 -0
- package/dist/common/textRange.js +211 -0
- package/dist/common/textRange.js.map +1 -0
- package/dist/common/textRangeCollection.d.ts +13 -0
- package/dist/common/textRangeCollection.js +108 -0
- package/dist/common/textRangeCollection.js.map +1 -0
- package/dist/common/timing.d.ts +31 -0
- package/dist/common/timing.js +100 -0
- package/dist/common/timing.js.map +1 -0
- package/dist/common/uriParser.d.ts +12 -0
- package/dist/common/uriParser.js +25 -0
- package/dist/common/uriParser.js.map +1 -0
- package/dist/common/workspaceEditUtils.d.ts +7 -0
- package/dist/common/workspaceEditUtils.js +63 -0
- package/dist/common/workspaceEditUtils.js.map +1 -0
- package/dist/languageServerBase.d.ts +211 -0
- package/dist/languageServerBase.js +923 -0
- package/dist/languageServerBase.js.map +1 -0
- package/dist/languageService/analyzerServiceExecutor.d.ts +8 -0
- package/dist/languageService/analyzerServiceExecutor.js +97 -0
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -0
- package/dist/languageService/autoImporter.d.ts +84 -0
- package/dist/languageService/autoImporter.js +635 -0
- package/dist/languageService/autoImporter.js.map +1 -0
- package/dist/languageService/callHierarchyProvider.d.ts +12 -0
- package/dist/languageService/callHierarchyProvider.js +368 -0
- package/dist/languageService/callHierarchyProvider.js.map +1 -0
- package/dist/languageService/codeActionProvider.d.ts +6 -0
- package/dist/languageService/codeActionProvider.js +53 -0
- package/dist/languageService/codeActionProvider.js.map +1 -0
- package/dist/languageService/completionProvider.d.ts +147 -0
- package/dist/languageService/completionProvider.js +2220 -0
- package/dist/languageService/completionProvider.js.map +1 -0
- package/dist/languageService/definitionProvider.d.ts +17 -0
- package/dist/languageService/definitionProvider.js +206 -0
- package/dist/languageService/definitionProvider.js.map +1 -0
- package/dist/languageService/documentHighlightProvider.d.ts +7 -0
- package/dist/languageService/documentHighlightProvider.js +63 -0
- package/dist/languageService/documentHighlightProvider.js.map +1 -0
- package/dist/languageService/documentSymbolCollector.d.ts +37 -0
- package/dist/languageService/documentSymbolCollector.js +344 -0
- package/dist/languageService/documentSymbolCollector.js.map +1 -0
- package/dist/languageService/documentSymbolProvider.d.ts +37 -0
- package/dist/languageService/documentSymbolProvider.js +308 -0
- package/dist/languageService/documentSymbolProvider.js.map +1 -0
- package/dist/languageService/hoverProvider.d.ts +25 -0
- package/dist/languageService/hoverProvider.js +366 -0
- package/dist/languageService/hoverProvider.js.map +1 -0
- package/dist/languageService/importAdder.d.ts +24 -0
- package/dist/languageService/importAdder.js +296 -0
- package/dist/languageService/importAdder.js.map +1 -0
- package/dist/languageService/importSorter.d.ts +15 -0
- package/dist/languageService/importSorter.js +152 -0
- package/dist/languageService/importSorter.js.map +1 -0
- package/dist/languageService/indentationUtils.d.ts +4 -0
- package/dist/languageService/indentationUtils.js +597 -0
- package/dist/languageService/indentationUtils.js.map +1 -0
- package/dist/languageService/quickActions.d.ts +4 -0
- package/dist/languageService/quickActions.js +97 -0
- package/dist/languageService/quickActions.js.map +1 -0
- package/dist/languageService/referencesProvider.d.ts +36 -0
- package/dist/languageService/referencesProvider.js +236 -0
- package/dist/languageService/referencesProvider.js.map +1 -0
- package/dist/languageService/renameModuleProvider.d.ts +58 -0
- package/dist/languageService/renameModuleProvider.js +884 -0
- package/dist/languageService/renameModuleProvider.js.map +1 -0
- package/dist/languageService/signatureHelpProvider.d.ts +26 -0
- package/dist/languageService/signatureHelpProvider.js +180 -0
- package/dist/languageService/signatureHelpProvider.js.map +1 -0
- package/dist/languageService/tooltipUtils.d.ts +9 -0
- package/dist/languageService/tooltipUtils.js +129 -0
- package/dist/languageService/tooltipUtils.js.map +1 -0
- package/dist/localization/localize.d.ts +1324 -0
- package/dist/localization/localize.js +788 -0
- package/dist/localization/localize.js.map +1 -0
- package/dist/localization/package.nls.de.json +1 -0
- package/dist/localization/package.nls.en-us.json +636 -0
- package/dist/localization/package.nls.es.json +1 -0
- package/dist/localization/package.nls.fr.json +1 -0
- package/dist/localization/package.nls.ja.json +1 -0
- package/dist/localization/package.nls.ru.json +1 -0
- package/dist/localization/package.nls.zh-cn.json +1 -0
- package/dist/localization/package.nls.zh-tw.json +1 -0
- package/dist/nodeMain.d.ts +1 -0
- package/dist/nodeMain.js +21 -0
- package/dist/nodeMain.js.map +1 -0
- package/dist/nodeServer.d.ts +3 -0
- package/dist/nodeServer.js +31 -0
- package/dist/nodeServer.js.map +1 -0
- package/dist/parser/characterStream.d.ts +27 -0
- package/dist/parser/characterStream.js +120 -0
- package/dist/parser/characterStream.js.map +1 -0
- package/dist/parser/characters.d.ts +17 -0
- package/dist/parser/characters.js +240 -0
- package/dist/parser/characters.js.map +1 -0
- package/dist/parser/parseNodes.d.ts +750 -0
- package/dist/parser/parseNodes.js +1406 -0
- package/dist/parser/parseNodes.js.map +1 -0
- package/dist/parser/parser.d.ts +191 -0
- package/dist/parser/parser.js +3806 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/stringTokenUtils.d.ts +25 -0
- package/dist/parser/stringTokenUtils.js +455 -0
- package/dist/parser/stringTokenUtils.js.map +1 -0
- package/dist/parser/tokenizer.d.ts +71 -0
- package/dist/parser/tokenizer.js +1111 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/tokenizerTypes.d.ts +223 -0
- package/dist/parser/tokenizerTypes.js +164 -0
- package/dist/parser/tokenizerTypes.js.map +1 -0
- package/dist/parser/unicode.d.ts +23 -0
- package/dist/parser/unicode.js +2899 -0
- package/dist/parser/unicode.js.map +1 -0
- package/dist/pyright.d.ts +1 -0
- package/dist/pyright.js +645 -0
- package/dist/pyright.js.map +1 -0
- package/dist/pyrightFileSystem.d.ts +28 -0
- package/dist/pyrightFileSystem.js +196 -0
- package/dist/pyrightFileSystem.js.map +1 -0
- package/dist/readonlyAugmentedFileSystem.d.ts +40 -0
- package/dist/readonlyAugmentedFileSystem.js +155 -0
- package/dist/readonlyAugmentedFileSystem.js.map +1 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +232 -0
- package/dist/server.js.map +1 -0
- package/dist/tests/chainedSourceFiles.test.d.ts +1 -0
- package/dist/tests/chainedSourceFiles.test.js +153 -0
- package/dist/tests/chainedSourceFiles.test.js.map +1 -0
- package/dist/tests/checker.test.d.ts +1 -0
- package/dist/tests/checker.test.js +346 -0
- package/dist/tests/checker.test.js.map +1 -0
- package/dist/tests/collectionUtils.test.d.ts +1 -0
- package/dist/tests/collectionUtils.test.js +153 -0
- package/dist/tests/collectionUtils.test.js.map +1 -0
- package/dist/tests/common.test.d.ts +1 -0
- package/dist/tests/common.test.js +125 -0
- package/dist/tests/common.test.js.map +1 -0
- package/dist/tests/config.test.d.ts +1 -0
- package/dist/tests/config.test.js +230 -0
- package/dist/tests/config.test.js.map +1 -0
- package/dist/tests/debug.test.d.ts +1 -0
- package/dist/tests/debug.test.js +102 -0
- package/dist/tests/debug.test.js.map +1 -0
- package/dist/tests/deferred.test.d.ts +1 -0
- package/dist/tests/deferred.test.js +65 -0
- package/dist/tests/deferred.test.js.map +1 -0
- package/dist/tests/diagnosticOverrides.test.d.ts +1 -0
- package/dist/tests/diagnosticOverrides.test.js +108 -0
- package/dist/tests/diagnosticOverrides.test.js.map +1 -0
- package/dist/tests/docStringConversion.test.d.ts +1 -0
- package/dist/tests/docStringConversion.test.js +695 -0
- package/dist/tests/docStringConversion.test.js.map +1 -0
- package/dist/tests/docStringUtils.test.d.ts +1 -0
- package/dist/tests/docStringUtils.test.js +70 -0
- package/dist/tests/docStringUtils.test.js.map +1 -0
- package/dist/tests/documentSymbolCollector.test.d.ts +1 -0
- package/dist/tests/documentSymbolCollector.test.js +635 -0
- package/dist/tests/documentSymbolCollector.test.js.map +1 -0
- package/dist/tests/filesystem.test.d.ts +1 -0
- package/dist/tests/filesystem.test.js +194 -0
- package/dist/tests/filesystem.test.js.map +1 -0
- package/dist/tests/fourSlashParser.test.d.ts +1 -0
- package/dist/tests/fourSlashParser.test.js +281 -0
- package/dist/tests/fourSlashParser.test.js.map +1 -0
- package/dist/tests/fourSlashRunner.test.d.ts +1 -0
- package/dist/tests/fourSlashRunner.test.js +52 -0
- package/dist/tests/fourSlashRunner.test.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js +42 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js +13 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js +35 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js +128 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js +43 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js +116 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.js +21 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js +54 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js +245 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js +162 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js +132 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.js +37 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.comment.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.comment.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.comment.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.js +18 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js +26 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js +15 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js +36 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js +147 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js +131 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +73 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +58 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +154 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +143 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +109 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.js +44 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.js +12 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fourslash.js +51 -0
- package/dist/tests/fourslash/completions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.js +32 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +96 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.d.ts +0 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inList.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inList.fourslash.js +32 -0
- package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.included.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.included.fourslash.js +12 -0
- package/dist/tests/fourslash/completions.included.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +54 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js +26 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js +49 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js +101 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js +105 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js +67 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js +75 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.literals.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.literals.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.js +71 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js +17 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js +57 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.js +37 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.importStub.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.importStub.js +49 -0
- package/dist/tests/fourslash/completions.override.default.importStub.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.js +60 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js +63 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override2.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.params.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.params.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.js +15 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.js +34 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.private.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.private.fourslash.js +61 -0
- package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.property.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.property.fourslash.js +28 -0
- package/dist/tests/fourslash/completions.property.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js +64 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.self.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.self.fourslash.js +43 -0
- package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js +71 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js +78 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.js +9 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.js +33 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +109 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.with.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.with.fourslash.js +25 -0
- package/dist/tests/fourslash/completions.with.fourslash.js.map +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js +64 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js +24 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js +93 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js +19 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js +123 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js +79 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js +154 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js +42 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +34 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js +213 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js +154 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js +29 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js +30 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js +26 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js +28 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js +33 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js +26 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js +59 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js +59 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js +94 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js +79 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js +106 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js +24 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js +66 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js +26 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js +36 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.fourslash.js +30 -0
- package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js +30 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js +46 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js +60 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js +54 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js +41 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js +83 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js +32 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js +22 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js +29 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js +33 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js +36 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js +44 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js +31 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js +22 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +301 -0
- package/dist/tests/fourslash/fourslash.js +25 -0
- package/dist/tests/fourslash/fourslash.js.map +1 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js +30 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js +63 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js +14 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.js +47 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +77 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js +22 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +22 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js +21 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +25 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js +18 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js +12 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +24 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.js +23 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.import.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.import.fourslash.js +10 -0
- package/dist/tests/fourslash/hover.import.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +61 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js +51 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +40 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js +43 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js +44 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js +84 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js +88 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.init.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.init.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js +49 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js +39 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.js +39 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js +14 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.js +50 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js +35 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +73 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js +63 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js +72 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js +61 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js +35 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js +35 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.js +24 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.js.map +1 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.js +13 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js +18 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.js +13 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js +31 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js +44 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js +35 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js +35 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.js +18 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js +34 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js.map +1 -0
- package/dist/tests/fourslash/noerrors.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/noerrors.fourslash.js +9 -0
- package/dist/tests/fourslash/noerrors.fourslash.js.map +1 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.js +17 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.js.map +1 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.js +21 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.js +23 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js +23 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.fourslash.js +26 -0
- package/dist/tests/fourslash/rename.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.library.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.library.fourslash.js +26 -0
- package/dist/tests/fourslash/rename.library.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js +29 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +2 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.js +19 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js +33 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js +39 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.string.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.string.fourslash.js +25 -0
- package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js +62 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.js +97 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.js +22 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.js +42 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js +49 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js +115 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.overload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.overload.fourslash.js +63 -0
- package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.simple.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js +104 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashParser.d.ts +10 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js +347 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.d.ts +81 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js +65 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -0
- package/dist/tests/harness/fourslash/runner.d.ts +20 -0
- package/dist/tests/harness/fourslash/runner.js +93 -0
- package/dist/tests/harness/fourslash/runner.js.map +1 -0
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +40 -0
- package/dist/tests/harness/fourslash/testLanguageService.js +120 -0
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.d.ts +11 -0
- package/dist/tests/harness/fourslash/testState.Consts.js +50 -0
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.d.ts +232 -0
- package/dist/tests/harness/fourslash/testState.js +1381 -0
- package/dist/tests/harness/fourslash/testState.js.map +1 -0
- package/dist/tests/harness/testAccessHost.d.ts +8 -0
- package/dist/tests/harness/testAccessHost.js +26 -0
- package/dist/tests/harness/testAccessHost.js.map +1 -0
- package/dist/tests/harness/testHost.d.ts +16 -0
- package/dist/tests/harness/testHost.js +161 -0
- package/dist/tests/harness/testHost.js.map +1 -0
- package/dist/tests/harness/utils.d.ts +74 -0
- package/dist/tests/harness/utils.js +328 -0
- package/dist/tests/harness/utils.js.map +1 -0
- package/dist/tests/harness/vfs/factory.d.ts +32 -0
- package/dist/tests/harness/vfs/factory.js +173 -0
- package/dist/tests/harness/vfs/factory.js.map +1 -0
- package/dist/tests/harness/vfs/filesystem.d.ts +430 -0
- package/dist/tests/harness/vfs/filesystem.js +1455 -0
- package/dist/tests/harness/vfs/filesystem.js.map +1 -0
- package/dist/tests/harness/vfs/pathValidation.d.ts +24 -0
- package/dist/tests/harness/vfs/pathValidation.js +123 -0
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -0
- package/dist/tests/importAdder.test.d.ts +1 -0
- package/dist/tests/importAdder.test.js +1192 -0
- package/dist/tests/importAdder.test.js.map +1 -0
- package/dist/tests/importResolver.test.d.ts +1 -0
- package/dist/tests/importResolver.test.js +450 -0
- package/dist/tests/importResolver.test.js.map +1 -0
- package/dist/tests/importStatementUtils.test.d.ts +1 -0
- package/dist/tests/importStatementUtils.test.js +371 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -0
- package/dist/tests/indentationUtils.ptvs.test.d.ts +1 -0
- package/dist/tests/indentationUtils.ptvs.test.js +324 -0
- package/dist/tests/indentationUtils.ptvs.test.js.map +1 -0
- package/dist/tests/indentationUtils.reindent.test.d.ts +1 -0
- package/dist/tests/indentationUtils.reindent.test.js +332 -0
- package/dist/tests/indentationUtils.reindent.test.js.map +1 -0
- package/dist/tests/indentationUtils.test.d.ts +1 -0
- package/dist/tests/indentationUtils.test.js +375 -0
- package/dist/tests/indentationUtils.test.js.map +1 -0
- package/dist/tests/ipythonMode.test.d.ts +1 -0
- package/dist/tests/ipythonMode.test.js +303 -0
- package/dist/tests/ipythonMode.test.js.map +1 -0
- package/dist/tests/localizer.test.d.ts +1 -0
- package/dist/tests/localizer.test.js +64 -0
- package/dist/tests/localizer.test.js.map +1 -0
- package/dist/tests/parseTreeUtils.test.d.ts +1 -0
- package/dist/tests/parseTreeUtils.test.js +228 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -0
- package/dist/tests/parser.test.d.ts +1 -0
- package/dist/tests/parser.test.js +101 -0
- package/dist/tests/parser.test.js.map +1 -0
- package/dist/tests/pathUtils.test.d.ts +1 -0
- package/dist/tests/pathUtils.test.js +253 -0
- package/dist/tests/pathUtils.test.js.map +1 -0
- package/dist/tests/pyrightFileSystem.test.d.ts +1 -0
- package/dist/tests/pyrightFileSystem.test.js +152 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -0
- package/dist/tests/renameModule.folder.test.d.ts +1 -0
- package/dist/tests/renameModule.folder.test.js +229 -0
- package/dist/tests/renameModule.folder.test.js.map +1 -0
- package/dist/tests/renameModule.fromImports.test.d.ts +1 -0
- package/dist/tests/renameModule.fromImports.test.js +790 -0
- package/dist/tests/renameModule.fromImports.test.js.map +1 -0
- package/dist/tests/renameModule.imports.test.d.ts +1 -0
- package/dist/tests/renameModule.imports.test.js +380 -0
- package/dist/tests/renameModule.imports.test.js.map +1 -0
- package/dist/tests/renameModule.misc.test.d.ts +1 -0
- package/dist/tests/renameModule.misc.test.js +615 -0
- package/dist/tests/renameModule.misc.test.js.map +1 -0
- package/dist/tests/renameModule.relativePath.test.d.ts +1 -0
- package/dist/tests/renameModule.relativePath.test.js +231 -0
- package/dist/tests/renameModule.relativePath.test.js.map +1 -0
- package/dist/tests/renameModuleTestUtils.d.ts +4 -0
- package/dist/tests/renameModuleTestUtils.js +148 -0
- package/dist/tests/renameModuleTestUtils.js.map +1 -0
- package/dist/tests/sourceFile.test.d.ts +1 -0
- package/dist/tests/sourceFile.test.js +25 -0
- package/dist/tests/sourceFile.test.js.map +1 -0
- package/dist/tests/stringUtils.test.d.ts +1 -0
- package/dist/tests/stringUtils.test.js +69 -0
- package/dist/tests/stringUtils.test.js.map +1 -0
- package/dist/tests/symbolNameUtils.test.d.ts +1 -0
- package/dist/tests/symbolNameUtils.test.js +83 -0
- package/dist/tests/symbolNameUtils.test.js.map +1 -0
- package/dist/tests/testState.test.d.ts +1 -0
- package/dist/tests/testState.test.js +521 -0
- package/dist/tests/testState.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +27 -0
- package/dist/tests/testUtils.js +213 -0
- package/dist/tests/testUtils.js.map +1 -0
- package/dist/tests/tokenizer.test.d.ts +1 -0
- package/dist/tests/tokenizer.test.js +1277 -0
- package/dist/tests/tokenizer.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.d.ts +1 -0
- package/dist/tests/typeEvaluator1.test.js +1023 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -0
- package/dist/tests/typeEvaluator2.test.d.ts +1 -0
- package/dist/tests/typeEvaluator2.test.js +869 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -0
- package/dist/tests/typeEvaluator3.test.d.ts +1 -0
- package/dist/tests/typeEvaluator3.test.js +915 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -0
- package/dist/tests/typeEvaluator4.test.d.ts +1 -0
- package/dist/tests/typeEvaluator4.test.js +901 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -0
- package/dist/tests/updateSymbolReference.test.d.ts +1 -0
- package/dist/tests/updateSymbolReference.test.js +980 -0
- package/dist/tests/updateSymbolReference.test.js.map +1 -0
- package/dist/tests/zipfs.test.d.ts +1 -0
- package/dist/tests/zipfs.test.js +112 -0
- package/dist/tests/zipfs.test.js.map +1 -0
- package/dist/workspaceMap.d.ts +6 -0
- package/dist/workspaceMap.js +73 -0
- package/dist/workspaceMap.js.map +1 -0
- package/package.json +45 -0
@@ -0,0 +1,2380 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
* typeUtils.ts
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
5
|
+
* Licensed under the MIT license.
|
6
|
+
* Author: Eric Traut
|
7
|
+
*
|
8
|
+
* Collection of functions that operate on Type objects.
|
9
|
+
*/
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
+
exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = exports.lookUpClassMember = exports.lookUpObjectMember = exports.getProtocolSymbols = exports.transformExpectedTypeForConstructor = exports.applySolvedTypeVars = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.getTypeVarScopeId = exports.transformPossibleRecursiveTypeAlias = exports.isTypeAliasRecursive = exports.isTypeAliasPlaceholder = exports.getTypeCondition = exports.addConditionToType = exports.stripLiteralValue = exports.getFullNameOfType = exports.derivesFromAnyOrUnknown = exports.isUnionableType = exports.preserveUnknown = exports.areTypesSame = exports.doForEachSubtype = exports.mapSubtypes = exports.isOptionalType = exports.getParameterListDetails = exports.ParameterSource = void 0;
|
12
|
+
exports.convertParamSpecValueToType = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.removeParamSpecVariadicsFromFunction = exports.removeParamSpecVariadicsFromSignature = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = void 0;
|
13
|
+
const collectionUtils_1 = require("../common/collectionUtils");
|
14
|
+
const debug_1 = require("../common/debug");
|
15
|
+
const symbol_1 = require("./symbol");
|
16
|
+
const symbolNameUtils_1 = require("./symbolNameUtils");
|
17
|
+
const symbolUtils_1 = require("./symbolUtils");
|
18
|
+
const types_1 = require("./types");
|
19
|
+
const typeVarContext_1 = require("./typeVarContext");
|
20
|
+
var ParameterSource;
|
21
|
+
(function (ParameterSource) {
|
22
|
+
ParameterSource[ParameterSource["PositionOnly"] = 0] = "PositionOnly";
|
23
|
+
ParameterSource[ParameterSource["PositionOrKeyword"] = 1] = "PositionOrKeyword";
|
24
|
+
ParameterSource[ParameterSource["KeywordOnly"] = 2] = "KeywordOnly";
|
25
|
+
})(ParameterSource = exports.ParameterSource || (exports.ParameterSource = {}));
|
26
|
+
// Examines the input parameters within a function signature and creates a
|
27
|
+
// "virtual list" of parameters, stripping out any markers and expanding
|
28
|
+
// any *args with unpacked tuples.
|
29
|
+
function getParameterListDetails(type) {
|
30
|
+
const result = {
|
31
|
+
firstPositionOrKeywordIndex: 0,
|
32
|
+
positionParamCount: 0,
|
33
|
+
positionOnlyParamCount: 0,
|
34
|
+
params: [],
|
35
|
+
hasUnpackedVariadicTypeVar: false,
|
36
|
+
hasUnpackedTypedDict: false,
|
37
|
+
};
|
38
|
+
let positionOnlyIndex = type.details.parameters.findIndex((p) => p.category === 0 /* Simple */ && !p.name);
|
39
|
+
// Handle the old (pre Python 3.8) way of specifying positional-only
|
40
|
+
// parameters by naming them with "__".
|
41
|
+
if (positionOnlyIndex < 0) {
|
42
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
43
|
+
const p = type.details.parameters[i];
|
44
|
+
if (p.category !== 0 /* Simple */) {
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
if (!p.name) {
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
if ((0, symbolNameUtils_1.isDunderName)(p.name) || !p.name.startsWith('__')) {
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
positionOnlyIndex = i + 1;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
if (positionOnlyIndex >= 0) {
|
57
|
+
result.firstPositionOrKeywordIndex = positionOnlyIndex;
|
58
|
+
}
|
59
|
+
for (let i = 0; i < positionOnlyIndex; i++) {
|
60
|
+
if (type.details.parameters[i].hasDefault) {
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
result.positionOnlyParamCount++;
|
64
|
+
}
|
65
|
+
let sawKeywordOnlySeparator = false;
|
66
|
+
const addVirtualParameter = (param, index, typeOverride, defaultArgTypeOverride) => {
|
67
|
+
if (param.name) {
|
68
|
+
let source;
|
69
|
+
if (param.category === 1 /* VarArgList */) {
|
70
|
+
source = ParameterSource.PositionOnly;
|
71
|
+
}
|
72
|
+
else if (sawKeywordOnlySeparator) {
|
73
|
+
source = ParameterSource.KeywordOnly;
|
74
|
+
}
|
75
|
+
else if (positionOnlyIndex >= 0 && index < positionOnlyIndex) {
|
76
|
+
source = ParameterSource.PositionOnly;
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
source = ParameterSource.PositionOrKeyword;
|
80
|
+
}
|
81
|
+
result.params.push({
|
82
|
+
param,
|
83
|
+
index,
|
84
|
+
type: typeOverride !== null && typeOverride !== void 0 ? typeOverride : types_1.FunctionType.getEffectiveParameterType(type, index),
|
85
|
+
defaultArgType: defaultArgTypeOverride,
|
86
|
+
source,
|
87
|
+
});
|
88
|
+
}
|
89
|
+
};
|
90
|
+
type.details.parameters.forEach((param, index) => {
|
91
|
+
var _a, _b;
|
92
|
+
if (param.category === 1 /* VarArgList */) {
|
93
|
+
// If this is an unpacked tuple, expand the entries.
|
94
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
95
|
+
if (param.name && (0, types_1.isUnpackedClass)(paramType) && paramType.tupleTypeArguments) {
|
96
|
+
paramType.tupleTypeArguments.forEach((tupleArg, index) => {
|
97
|
+
const category = (0, types_1.isVariadicTypeVar)(tupleArg.type) || tupleArg.isUnbounded
|
98
|
+
? 1 /* VarArgList */
|
99
|
+
: 0 /* Simple */;
|
100
|
+
if (category === 1 /* VarArgList */) {
|
101
|
+
result.argsIndex = result.params.length;
|
102
|
+
}
|
103
|
+
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
104
|
+
result.hasUnpackedVariadicTypeVar = true;
|
105
|
+
}
|
106
|
+
addVirtualParameter({
|
107
|
+
category,
|
108
|
+
name: `${param.name}[${index.toString()}]`,
|
109
|
+
isNameSynthesized: true,
|
110
|
+
type: tupleArg.type,
|
111
|
+
hasDeclaredType: true,
|
112
|
+
}, index, tupleArg.type);
|
113
|
+
});
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
if (param.name && result.argsIndex === undefined) {
|
117
|
+
result.argsIndex = result.params.length;
|
118
|
+
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
119
|
+
result.hasUnpackedVariadicTypeVar = true;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
// Normally, a VarArgList parameter (either named or as an unnamed separator)
|
123
|
+
// would signify the start of keyword-only parameters. However, we can construct
|
124
|
+
// callable signatures that defy this rule by using Callable and TypeVarTuples
|
125
|
+
// or unpacked tuples.
|
126
|
+
if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
|
127
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
128
|
+
if (param.name) {
|
129
|
+
result.firstKeywordOnlyIndex++;
|
130
|
+
}
|
131
|
+
sawKeywordOnlySeparator = true;
|
132
|
+
}
|
133
|
+
addVirtualParameter(param, index);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
else if (param.category === 2 /* VarArgDictionary */) {
|
137
|
+
sawKeywordOnlySeparator = true;
|
138
|
+
// Is this an unpacked TypedDict? If so, expand the entries.
|
139
|
+
if ((0, types_1.isClassInstance)(param.type) && (0, types_1.isUnpackedClass)(param.type) && param.type.details.typedDictEntries) {
|
140
|
+
if (result.firstKeywordOnlyIndex === undefined) {
|
141
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
142
|
+
}
|
143
|
+
param.type.details.typedDictEntries.forEach((entry, name) => {
|
144
|
+
addVirtualParameter({
|
145
|
+
category: 0 /* Simple */,
|
146
|
+
name,
|
147
|
+
type: entry.valueType,
|
148
|
+
hasDeclaredType: true,
|
149
|
+
hasDefault: !entry.isRequired,
|
150
|
+
}, index, entry.valueType);
|
151
|
+
});
|
152
|
+
result.hasUnpackedTypedDict = true;
|
153
|
+
}
|
154
|
+
else if (param.name) {
|
155
|
+
if (result.kwargsIndex === undefined) {
|
156
|
+
result.kwargsIndex = result.params.length;
|
157
|
+
}
|
158
|
+
if (result.firstKeywordOnlyIndex === undefined) {
|
159
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
160
|
+
}
|
161
|
+
addVirtualParameter(param, index);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
else if (param.category === 0 /* Simple */) {
|
165
|
+
if (param.name && !sawKeywordOnlySeparator) {
|
166
|
+
result.positionParamCount++;
|
167
|
+
}
|
168
|
+
addVirtualParameter(param, index,
|
169
|
+
/* typeOverride */ undefined, ((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs)
|
170
|
+
? (_b = type.specializedTypes) === null || _b === void 0 ? void 0 : _b.parameterDefaultArgs[index]
|
171
|
+
: undefined);
|
172
|
+
}
|
173
|
+
});
|
174
|
+
return result;
|
175
|
+
}
|
176
|
+
exports.getParameterListDetails = getParameterListDetails;
|
177
|
+
function isOptionalType(type) {
|
178
|
+
if ((0, types_1.isUnion)(type)) {
|
179
|
+
return (0, types_1.findSubtype)(type, (subtype) => (0, types_1.isNoneInstance)(subtype)) !== undefined;
|
180
|
+
}
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
exports.isOptionalType = isOptionalType;
|
184
|
+
// Calls a callback for each subtype and combines the results
|
185
|
+
// into a final type.
|
186
|
+
function mapSubtypes(type, callback) {
|
187
|
+
if ((0, types_1.isUnion)(type)) {
|
188
|
+
const newSubtypes = [];
|
189
|
+
let typeChanged = false;
|
190
|
+
type.subtypes.forEach((subtype) => {
|
191
|
+
const transformedType = callback(subtype);
|
192
|
+
if (transformedType) {
|
193
|
+
if (transformedType !== subtype) {
|
194
|
+
newSubtypes.push(addConditionToType(transformedType, getTypeCondition(type)));
|
195
|
+
typeChanged = true;
|
196
|
+
}
|
197
|
+
else {
|
198
|
+
newSubtypes.push(subtype);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
else {
|
202
|
+
typeChanged = true;
|
203
|
+
}
|
204
|
+
});
|
205
|
+
if (!typeChanged) {
|
206
|
+
return type;
|
207
|
+
}
|
208
|
+
const newType = (0, types_1.combineTypes)(newSubtypes);
|
209
|
+
// Do our best to retain type aliases.
|
210
|
+
if (newType.category === 9 /* Union */) {
|
211
|
+
types_1.UnionType.addTypeAliasSource(newType, type);
|
212
|
+
}
|
213
|
+
return newType;
|
214
|
+
}
|
215
|
+
const transformedSubtype = callback(type);
|
216
|
+
if (!transformedSubtype) {
|
217
|
+
return types_1.NeverType.createNever();
|
218
|
+
}
|
219
|
+
return transformedSubtype;
|
220
|
+
}
|
221
|
+
exports.mapSubtypes = mapSubtypes;
|
222
|
+
function doForEachSubtype(type, callback) {
|
223
|
+
if ((0, types_1.isUnion)(type)) {
|
224
|
+
type.subtypes.forEach((subtype, index) => {
|
225
|
+
callback(subtype, index);
|
226
|
+
});
|
227
|
+
}
|
228
|
+
else {
|
229
|
+
callback(type, 0);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
exports.doForEachSubtype = doForEachSubtype;
|
233
|
+
// Determines if all of the types in the array are the same.
|
234
|
+
function areTypesSame(types, ignorePseudoGeneric) {
|
235
|
+
if (types.length < 2) {
|
236
|
+
return true;
|
237
|
+
}
|
238
|
+
for (let i = 1; i < types.length; i++) {
|
239
|
+
if (!(0, types_1.isTypeSame)(types[0], types[i], ignorePseudoGeneric)) {
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
}
|
243
|
+
return true;
|
244
|
+
}
|
245
|
+
exports.areTypesSame = areTypesSame;
|
246
|
+
// If either type is "Unknown" (versus Any), propagate the Unknown. Preserve
|
247
|
+
// the incomplete flag on the unknown if present. The caller should verify that
|
248
|
+
// one or the other type is Unknown or Any.
|
249
|
+
function preserveUnknown(type1, type2) {
|
250
|
+
if ((0, types_1.isUnknown)(type1) && type1.isIncomplete) {
|
251
|
+
return type1;
|
252
|
+
}
|
253
|
+
else if ((0, types_1.isUnknown)(type2) && type2.isIncomplete) {
|
254
|
+
return type2;
|
255
|
+
}
|
256
|
+
else if ((0, types_1.isUnknown)(type1) || (0, types_1.isUnknown)(type2)) {
|
257
|
+
return types_1.UnknownType.create();
|
258
|
+
}
|
259
|
+
else {
|
260
|
+
return types_1.AnyType.create();
|
261
|
+
}
|
262
|
+
}
|
263
|
+
exports.preserveUnknown = preserveUnknown;
|
264
|
+
// Determines whether the specified type is a type that can be
|
265
|
+
// combined with other types for a union.
|
266
|
+
function isUnionableType(subtypes) {
|
267
|
+
let typeFlags = 2 /* Instance */ | 1 /* Instantiable */;
|
268
|
+
for (const subtype of subtypes) {
|
269
|
+
typeFlags &= subtype.flags;
|
270
|
+
}
|
271
|
+
// All subtypes need to be instantiable. Some types (like Any
|
272
|
+
// and None) are both instances and instantiable. It's OK to
|
273
|
+
// include some of these, but at least one subtype needs to
|
274
|
+
// be definitively instantiable (not an instance).
|
275
|
+
return (typeFlags & 1 /* Instantiable */) !== 0 && (typeFlags & 2 /* Instance */) === 0;
|
276
|
+
}
|
277
|
+
exports.isUnionableType = isUnionableType;
|
278
|
+
function derivesFromAnyOrUnknown(type) {
|
279
|
+
let anyOrUnknown = false;
|
280
|
+
doForEachSubtype(type, (subtype) => {
|
281
|
+
if ((0, types_1.isAnyOrUnknown)(type)) {
|
282
|
+
anyOrUnknown = true;
|
283
|
+
}
|
284
|
+
else if ((0, types_1.isInstantiableClass)(subtype)) {
|
285
|
+
if (types_1.ClassType.hasUnknownBaseClass(subtype)) {
|
286
|
+
anyOrUnknown = true;
|
287
|
+
}
|
288
|
+
}
|
289
|
+
else if ((0, types_1.isClassInstance)(subtype)) {
|
290
|
+
if (types_1.ClassType.hasUnknownBaseClass(subtype)) {
|
291
|
+
anyOrUnknown = true;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
});
|
295
|
+
return anyOrUnknown;
|
296
|
+
}
|
297
|
+
exports.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
|
298
|
+
function getFullNameOfType(type) {
|
299
|
+
var _a;
|
300
|
+
if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.fullName) {
|
301
|
+
return type.typeAliasInfo.fullName;
|
302
|
+
}
|
303
|
+
switch (type.category) {
|
304
|
+
case 2 /* Any */:
|
305
|
+
case 1 /* Unknown */:
|
306
|
+
return 'typing.Any';
|
307
|
+
case 3 /* None */:
|
308
|
+
return 'builtins.None';
|
309
|
+
case 7 /* Class */:
|
310
|
+
return type.details.fullName;
|
311
|
+
case 5 /* Function */:
|
312
|
+
return type.details.fullName;
|
313
|
+
case 8 /* Module */:
|
314
|
+
return type.moduleName;
|
315
|
+
case 6 /* OverloadedFunction */:
|
316
|
+
return type.overloads[0].details.fullName;
|
317
|
+
}
|
318
|
+
return undefined;
|
319
|
+
}
|
320
|
+
exports.getFullNameOfType = getFullNameOfType;
|
321
|
+
function stripLiteralValue(type) {
|
322
|
+
if ((0, types_1.isClass)(type)) {
|
323
|
+
if (type.literalValue !== undefined) {
|
324
|
+
type = types_1.ClassType.cloneWithLiteral(type, /* value */ undefined);
|
325
|
+
}
|
326
|
+
return type;
|
327
|
+
}
|
328
|
+
if ((0, types_1.isUnion)(type)) {
|
329
|
+
return mapSubtypes(type, (subtype) => {
|
330
|
+
return stripLiteralValue(subtype);
|
331
|
+
});
|
332
|
+
}
|
333
|
+
return type;
|
334
|
+
}
|
335
|
+
exports.stripLiteralValue = stripLiteralValue;
|
336
|
+
function addConditionToType(type, condition) {
|
337
|
+
if (!condition) {
|
338
|
+
return type;
|
339
|
+
}
|
340
|
+
switch (type.category) {
|
341
|
+
case 0 /* Unbound */:
|
342
|
+
case 1 /* Unknown */:
|
343
|
+
case 2 /* Any */:
|
344
|
+
case 4 /* Never */:
|
345
|
+
case 8 /* Module */:
|
346
|
+
case 10 /* TypeVar */:
|
347
|
+
return type;
|
348
|
+
case 3 /* None */:
|
349
|
+
case 5 /* Function */:
|
350
|
+
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
|
351
|
+
case 6 /* OverloadedFunction */:
|
352
|
+
return types_1.OverloadedFunctionType.create(type.overloads.map((t) => addConditionToType(t, condition)));
|
353
|
+
case 7 /* Class */:
|
354
|
+
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
|
355
|
+
case 9 /* Union */:
|
356
|
+
return (0, types_1.combineTypes)(type.subtypes.map((t) => addConditionToType(t, condition)));
|
357
|
+
}
|
358
|
+
}
|
359
|
+
exports.addConditionToType = addConditionToType;
|
360
|
+
function getTypeCondition(type) {
|
361
|
+
switch (type.category) {
|
362
|
+
case 0 /* Unbound */:
|
363
|
+
case 1 /* Unknown */:
|
364
|
+
case 2 /* Any */:
|
365
|
+
case 4 /* Never */:
|
366
|
+
case 8 /* Module */:
|
367
|
+
case 10 /* TypeVar */:
|
368
|
+
case 6 /* OverloadedFunction */:
|
369
|
+
case 9 /* Union */:
|
370
|
+
return undefined;
|
371
|
+
case 3 /* None */:
|
372
|
+
case 7 /* Class */:
|
373
|
+
case 5 /* Function */:
|
374
|
+
return type.condition;
|
375
|
+
}
|
376
|
+
}
|
377
|
+
exports.getTypeCondition = getTypeCondition;
|
378
|
+
// Indicates whether the specified type is a recursive type alias
|
379
|
+
// placeholder that has not yet been resolved.
|
380
|
+
function isTypeAliasPlaceholder(type) {
|
381
|
+
if (!(0, types_1.isTypeVar)(type)) {
|
382
|
+
return false;
|
383
|
+
}
|
384
|
+
return !!type.details.recursiveTypeAliasName && !type.details.boundType;
|
385
|
+
}
|
386
|
+
exports.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
387
|
+
// Determines whether the type alias placeholder is used directly
|
388
|
+
// within the specified type. It's OK if it's used indirectly as
|
389
|
+
// a type argument.
|
390
|
+
function isTypeAliasRecursive(typeAliasPlaceholder, type) {
|
391
|
+
if (type.category !== 9 /* Union */) {
|
392
|
+
if (type === typeAliasPlaceholder) {
|
393
|
+
return true;
|
394
|
+
}
|
395
|
+
// Handle the specific case where the type alias directly refers to itself.
|
396
|
+
// In this case, the type will be unbound because it could not be resolved.
|
397
|
+
return ((0, types_1.isUnbound)(type) &&
|
398
|
+
type.typeAliasInfo &&
|
399
|
+
type.typeAliasInfo.name === typeAliasPlaceholder.details.recursiveTypeAliasName);
|
400
|
+
}
|
401
|
+
return (0, types_1.findSubtype)(type, (subtype) => (0, types_1.isTypeSame)(typeAliasPlaceholder, subtype)) !== undefined;
|
402
|
+
}
|
403
|
+
exports.isTypeAliasRecursive = isTypeAliasRecursive;
|
404
|
+
function transformPossibleRecursiveTypeAlias(type) {
|
405
|
+
var _a;
|
406
|
+
if (type) {
|
407
|
+
if ((0, types_1.isTypeVar)(type) && type.details.recursiveTypeAliasName && type.details.boundType) {
|
408
|
+
const unspecializedType = types_1.TypeBase.isInstance(type)
|
409
|
+
? convertToInstance(type.details.boundType)
|
410
|
+
: type.details.boundType;
|
411
|
+
if (!((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) || !type.details.recursiveTypeParameters) {
|
412
|
+
return unspecializedType;
|
413
|
+
}
|
414
|
+
const typeVarContext = buildTypeVarContext(type.details.recursiveTypeParameters, type.typeAliasInfo.typeArguments, getTypeVarScopeId(type));
|
415
|
+
return applySolvedTypeVars(unspecializedType, typeVarContext);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
return type;
|
419
|
+
}
|
420
|
+
exports.transformPossibleRecursiveTypeAlias = transformPossibleRecursiveTypeAlias;
|
421
|
+
function getTypeVarScopeId(type) {
|
422
|
+
if ((0, types_1.isClass)(type)) {
|
423
|
+
return type.details.typeVarScopeId;
|
424
|
+
}
|
425
|
+
if ((0, types_1.isFunction)(type)) {
|
426
|
+
return type.details.typeVarScopeId;
|
427
|
+
}
|
428
|
+
if ((0, types_1.isTypeVar)(type)) {
|
429
|
+
return type.scopeId;
|
430
|
+
}
|
431
|
+
return undefined;
|
432
|
+
}
|
433
|
+
exports.getTypeVarScopeId = getTypeVarScopeId;
|
434
|
+
// Determines whether the type derives from tuple. If so, it returns
|
435
|
+
// the specialized tuple type.
|
436
|
+
function getSpecializedTupleType(type) {
|
437
|
+
let classType;
|
438
|
+
if ((0, types_1.isInstantiableClass)(type)) {
|
439
|
+
classType = type;
|
440
|
+
}
|
441
|
+
else if ((0, types_1.isClassInstance)(type)) {
|
442
|
+
classType = types_1.ClassType.cloneAsInstantiable(type);
|
443
|
+
}
|
444
|
+
if (!classType) {
|
445
|
+
return undefined;
|
446
|
+
}
|
447
|
+
// See if this class derives from Tuple or tuple. If it does, we'll assume that it
|
448
|
+
// hasn't been overridden in a way that changes the behavior of the tuple class.
|
449
|
+
const tupleClass = classType.details.mro.find((mroClass) => (0, types_1.isInstantiableClass)(mroClass) && isTupleClass(mroClass));
|
450
|
+
if (!tupleClass || !(0, types_1.isInstantiableClass)(tupleClass)) {
|
451
|
+
return undefined;
|
452
|
+
}
|
453
|
+
if (types_1.ClassType.isSameGenericClass(classType, tupleClass)) {
|
454
|
+
return classType;
|
455
|
+
}
|
456
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(classType);
|
457
|
+
return applySolvedTypeVars(tupleClass, typeVarContext);
|
458
|
+
}
|
459
|
+
exports.getSpecializedTupleType = getSpecializedTupleType;
|
460
|
+
function isLiteralType(type) {
|
461
|
+
return types_1.TypeBase.isInstance(type) && type.literalValue !== undefined;
|
462
|
+
}
|
463
|
+
exports.isLiteralType = isLiteralType;
|
464
|
+
function isLiteralTypeOrUnion(type) {
|
465
|
+
if ((0, types_1.isClassInstance)(type)) {
|
466
|
+
return type.literalValue !== undefined;
|
467
|
+
}
|
468
|
+
if ((0, types_1.isUnion)(type)) {
|
469
|
+
return !(0, types_1.findSubtype)(type, (subtype) => !(0, types_1.isClassInstance)(subtype) || subtype.literalValue === undefined);
|
470
|
+
}
|
471
|
+
return false;
|
472
|
+
}
|
473
|
+
exports.isLiteralTypeOrUnion = isLiteralTypeOrUnion;
|
474
|
+
function containsLiteralType(type, includeTypeArgs = false, recursionCount = 0) {
|
475
|
+
var _a;
|
476
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
477
|
+
return false;
|
478
|
+
}
|
479
|
+
recursionCount++;
|
480
|
+
if ((0, types_1.isClassInstance)(type) && isLiteralType(type)) {
|
481
|
+
return true;
|
482
|
+
}
|
483
|
+
if (includeTypeArgs && (0, types_1.isClass)(type)) {
|
484
|
+
const typeArgs = ((_a = type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.map((t) => t.type)) || type.typeArguments;
|
485
|
+
if (typeArgs) {
|
486
|
+
return typeArgs.some((typeArg) => containsLiteralType(typeArg, includeTypeArgs, recursionCount));
|
487
|
+
}
|
488
|
+
}
|
489
|
+
if ((0, types_1.isUnion)(type)) {
|
490
|
+
return type.subtypes.some((subtype) => containsLiteralType(subtype, includeTypeArgs, recursionCount));
|
491
|
+
}
|
492
|
+
if ((0, types_1.isOverloadedFunction)(type)) {
|
493
|
+
return type.overloads.some((overload) => containsLiteralType(overload, includeTypeArgs, recursionCount));
|
494
|
+
}
|
495
|
+
if ((0, types_1.isFunction)(type)) {
|
496
|
+
const returnType = types_1.FunctionType.getSpecializedReturnType(type);
|
497
|
+
if (returnType && containsLiteralType(returnType, includeTypeArgs, recursionCount)) {
|
498
|
+
return true;
|
499
|
+
}
|
500
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
501
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, i);
|
502
|
+
if (containsLiteralType(paramType, includeTypeArgs, recursionCount)) {
|
503
|
+
return true;
|
504
|
+
}
|
505
|
+
}
|
506
|
+
}
|
507
|
+
return false;
|
508
|
+
}
|
509
|
+
exports.containsLiteralType = containsLiteralType;
|
510
|
+
// If all of the subtypes are literals with the same built-in class (e.g.
|
511
|
+
// all 'int' or all 'str'), this function returns the name of that type. If
|
512
|
+
// some of the subtypes are not literals or the literal classes don't match,
|
513
|
+
// it returns undefined.
|
514
|
+
function getLiteralTypeClassName(type) {
|
515
|
+
if ((0, types_1.isClassInstance)(type)) {
|
516
|
+
if (type.literalValue !== undefined && types_1.ClassType.isBuiltIn(type)) {
|
517
|
+
return type.details.name;
|
518
|
+
}
|
519
|
+
return undefined;
|
520
|
+
}
|
521
|
+
if ((0, types_1.isUnion)(type)) {
|
522
|
+
let className;
|
523
|
+
let foundMismatch = false;
|
524
|
+
doForEachSubtype(type, (subtype) => {
|
525
|
+
const subtypeLiteralTypeName = getLiteralTypeClassName(subtype);
|
526
|
+
if (!subtypeLiteralTypeName) {
|
527
|
+
foundMismatch = true;
|
528
|
+
}
|
529
|
+
else if (!className) {
|
530
|
+
className = subtypeLiteralTypeName;
|
531
|
+
}
|
532
|
+
});
|
533
|
+
return foundMismatch ? undefined : className;
|
534
|
+
}
|
535
|
+
return undefined;
|
536
|
+
}
|
537
|
+
exports.getLiteralTypeClassName = getLiteralTypeClassName;
|
538
|
+
function getUnionSubtypeCount(type) {
|
539
|
+
if ((0, types_1.isUnion)(type)) {
|
540
|
+
return type.subtypes.length;
|
541
|
+
}
|
542
|
+
return 1;
|
543
|
+
}
|
544
|
+
exports.getUnionSubtypeCount = getUnionSubtypeCount;
|
545
|
+
function isEllipsisType(type) {
|
546
|
+
return (0, types_1.isAny)(type) && type.isEllipsis;
|
547
|
+
}
|
548
|
+
exports.isEllipsisType = isEllipsisType;
|
549
|
+
function isProperty(type) {
|
550
|
+
return (0, types_1.isClassInstance)(type) && types_1.ClassType.isPropertyClass(type);
|
551
|
+
}
|
552
|
+
exports.isProperty = isProperty;
|
553
|
+
function isDescriptorInstance(type, requireSetter = false) {
|
554
|
+
if ((0, types_1.isUnion)(type)) {
|
555
|
+
return type.subtypes.every((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
|
556
|
+
}
|
557
|
+
return isMaybeDescriptorInstance(type, requireSetter);
|
558
|
+
}
|
559
|
+
exports.isDescriptorInstance = isDescriptorInstance;
|
560
|
+
function isMaybeDescriptorInstance(type, requireSetter = false) {
|
561
|
+
if ((0, types_1.isUnion)(type)) {
|
562
|
+
return type.subtypes.some((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
|
563
|
+
}
|
564
|
+
if (!(0, types_1.isClassInstance)(type)) {
|
565
|
+
return false;
|
566
|
+
}
|
567
|
+
if (!type.details.fields.has('__get__')) {
|
568
|
+
return false;
|
569
|
+
}
|
570
|
+
if (requireSetter && !type.details.fields.has('__set__')) {
|
571
|
+
return false;
|
572
|
+
}
|
573
|
+
return true;
|
574
|
+
}
|
575
|
+
exports.isMaybeDescriptorInstance = isMaybeDescriptorInstance;
|
576
|
+
function isTupleClass(type) {
|
577
|
+
return types_1.ClassType.isBuiltIn(type, 'tuple');
|
578
|
+
}
|
579
|
+
exports.isTupleClass = isTupleClass;
|
580
|
+
// Indicates whether the type is a tuple class of
|
581
|
+
// the form tuple[x, ...] where the number of elements
|
582
|
+
// in the tuple is unknown.
|
583
|
+
function isUnboundedTupleClass(type) {
|
584
|
+
return type.tupleTypeArguments && type.tupleTypeArguments.some((t) => t.isUnbounded);
|
585
|
+
}
|
586
|
+
exports.isUnboundedTupleClass = isUnboundedTupleClass;
|
587
|
+
// Partially specializes a type within the context of a specified
|
588
|
+
// (presumably specialized) class. Optionally specializes the `Self`
|
589
|
+
// type variables, replacing them with selfClass.
|
590
|
+
function partiallySpecializeType(type, contextClassType, selfClass, typeClassType) {
|
591
|
+
// If the context class is not specialized (or doesn't need specialization),
|
592
|
+
// then there's no need to do any more work.
|
593
|
+
if (types_1.ClassType.isUnspecialized(contextClassType)) {
|
594
|
+
return type;
|
595
|
+
}
|
596
|
+
// Partially specialize the type using the specialized class type vars.
|
597
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(contextClassType, /* makeConcrete */ undefined);
|
598
|
+
if (selfClass) {
|
599
|
+
populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass);
|
600
|
+
}
|
601
|
+
return applySolvedTypeVars(type, typeVarContext,
|
602
|
+
/* unknownIfNotFound */ undefined,
|
603
|
+
/* useNarrowBoundOnly */ undefined,
|
604
|
+
/* eliminateUnsolvedInUnions */ undefined, typeClassType);
|
605
|
+
}
|
606
|
+
exports.partiallySpecializeType = partiallySpecializeType;
|
607
|
+
function populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass) {
|
608
|
+
const synthesizedSelfTypeVar = synthesizeTypeVarForSelfCls(contextClassType, /* isClsParam */ false);
|
609
|
+
typeVarContext.setTypeVarType(synthesizedSelfTypeVar, convertToInstance(selfClass));
|
610
|
+
}
|
611
|
+
exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
|
612
|
+
// Specializes a (potentially generic) type by substituting
|
613
|
+
// type variables from a type var map.
|
614
|
+
function applySolvedTypeVars(type, typeVarContext, unknownIfNotFound = false, useNarrowBoundOnly = false, eliminateUnsolvedInUnions = false, typeClassType) {
|
615
|
+
// Use a shortcut if the typeVarContext is empty and no transform is necessary.
|
616
|
+
if (typeVarContext.isEmpty() && !unknownIfNotFound && !eliminateUnsolvedInUnions) {
|
617
|
+
return type;
|
618
|
+
}
|
619
|
+
const transformer = new ApplySolvedTypeVarsTransformer(typeVarContext, unknownIfNotFound, useNarrowBoundOnly, eliminateUnsolvedInUnions, typeClassType);
|
620
|
+
return transformer.apply(type);
|
621
|
+
}
|
622
|
+
exports.applySolvedTypeVars = applySolvedTypeVars;
|
623
|
+
// During bidirectional type inference for constructors, an "executed type"
|
624
|
+
// is used to prepopulate the type var map. This is problematic when the
|
625
|
+
// expected type uses TypeVars that are not part of the context of the
|
626
|
+
// class we are constructing. We'll replace these type variables with dummy
|
627
|
+
// type variables that are scoped to the appropriate context.
|
628
|
+
function transformExpectedTypeForConstructor(expectedType, typeVarContext, liveTypeVarScopes) {
|
629
|
+
const isTypeVarLive = (typeVar) => liveTypeVarScopes.some((scopeId) => typeVar.scopeId === scopeId);
|
630
|
+
// Handle "naked TypeVars" (i.e. the expectedType is a TypeVar itself)
|
631
|
+
// specially. Return undefined to indicate that it's an out-of-scope
|
632
|
+
// TypeVar.
|
633
|
+
if ((0, types_1.isTypeVar)(expectedType)) {
|
634
|
+
if (isTypeVarLive(expectedType)) {
|
635
|
+
return expectedType;
|
636
|
+
}
|
637
|
+
return undefined;
|
638
|
+
}
|
639
|
+
const transformer = new ExpectedConstructorTypeTransformer(typeVarContext, liveTypeVarScopes);
|
640
|
+
return transformer.apply(expectedType);
|
641
|
+
}
|
642
|
+
exports.transformExpectedTypeForConstructor = transformExpectedTypeForConstructor;
|
643
|
+
// Given a protocol class, this function returns a set of all the
|
644
|
+
// symbols (indexed by symbol name) that are part of that protocol
|
645
|
+
// and its protocol parent classes. If a same-named symbol appears
|
646
|
+
// in a parent and a child, the child overrides the parent.
|
647
|
+
function getProtocolSymbols(classType) {
|
648
|
+
const symbolMap = new Map();
|
649
|
+
if (types_1.ClassType.isProtocolClass(classType)) {
|
650
|
+
getProtocolSymbolsRecursive(classType, symbolMap);
|
651
|
+
}
|
652
|
+
return symbolMap;
|
653
|
+
}
|
654
|
+
exports.getProtocolSymbols = getProtocolSymbols;
|
655
|
+
function getProtocolSymbolsRecursive(classType, symbolMap, recursionCount = 0) {
|
656
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
657
|
+
return;
|
658
|
+
}
|
659
|
+
classType.details.baseClasses.forEach((baseClass) => {
|
660
|
+
if ((0, types_1.isClass)(baseClass) && types_1.ClassType.isProtocolClass(baseClass)) {
|
661
|
+
getProtocolSymbolsRecursive(baseClass, symbolMap, recursionCount + 1);
|
662
|
+
}
|
663
|
+
});
|
664
|
+
classType.details.fields.forEach((symbol, name) => {
|
665
|
+
if (!symbol.isIgnoredForProtocolMatch()) {
|
666
|
+
symbolMap.set(name, {
|
667
|
+
symbol,
|
668
|
+
classType,
|
669
|
+
isInstanceMember: symbol.isInstanceMember(),
|
670
|
+
isClassMember: symbol.isClassMember(),
|
671
|
+
isClassVar: symbol.isClassVar(),
|
672
|
+
isTypeDeclared: symbol.hasTypedDeclarations(),
|
673
|
+
skippedUndeclaredType: false,
|
674
|
+
});
|
675
|
+
}
|
676
|
+
});
|
677
|
+
}
|
678
|
+
function lookUpObjectMember(objectType, memberName, flags = 0 /* Default */) {
|
679
|
+
if ((0, types_1.isClassInstance)(objectType)) {
|
680
|
+
return lookUpClassMember(objectType, memberName, flags);
|
681
|
+
}
|
682
|
+
return undefined;
|
683
|
+
}
|
684
|
+
exports.lookUpObjectMember = lookUpObjectMember;
|
685
|
+
// Looks up a member in a class using the multiple-inheritance rules
|
686
|
+
// defined by Python.
|
687
|
+
function lookUpClassMember(classType, memberName, flags = 0 /* Default */) {
|
688
|
+
var _a;
|
689
|
+
const memberItr = getClassMemberIterator(classType, memberName, flags);
|
690
|
+
return (_a = memberItr.next()) === null || _a === void 0 ? void 0 : _a.value;
|
691
|
+
}
|
692
|
+
exports.lookUpClassMember = lookUpClassMember;
|
693
|
+
// Iterates members in a class matching memberName using the multiple-inheritance rules.
|
694
|
+
// For more details, see this note on method resolution
|
695
|
+
// order: https://www.python.org/download/releases/2.3/mro/.
|
696
|
+
// As it traverses the inheritance tree, it applies partial specialization
|
697
|
+
// to the the base class and member. For example, if ClassA inherits from
|
698
|
+
// ClassB[str] which inherits from Dict[_T1, int], a search for '__iter__'
|
699
|
+
// would return a class type of Dict[str, int] and a symbolType of
|
700
|
+
// (self) -> Iterator[str].
|
701
|
+
function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */) {
|
702
|
+
const declaredTypesOnly = (flags & 16 /* DeclaredTypesOnly */) !== 0;
|
703
|
+
let skippedUndeclaredType = false;
|
704
|
+
if ((0, types_1.isClass)(classType)) {
|
705
|
+
let classFlags = 0 /* Default */;
|
706
|
+
if (flags & 1 /* SkipOriginalClass */) {
|
707
|
+
classFlags = classFlags | 1 /* SkipOriginalClass */;
|
708
|
+
}
|
709
|
+
if (flags & 2 /* SkipBaseClasses */) {
|
710
|
+
classFlags = classFlags | 2 /* SkipBaseClasses */;
|
711
|
+
}
|
712
|
+
if (flags & 4 /* SkipObjectBaseClass */) {
|
713
|
+
classFlags = classFlags | 4 /* SkipObjectBaseClass */;
|
714
|
+
}
|
715
|
+
if (flags & 32 /* SkipTypeBaseClass */) {
|
716
|
+
classFlags = classFlags | 8 /* SkipTypeBaseClass */;
|
717
|
+
}
|
718
|
+
const classItr = getClassIterator(classType, classFlags);
|
719
|
+
for (const [mroClass, specializedMroClass] of classItr) {
|
720
|
+
if (!(0, types_1.isInstantiableClass)(mroClass)) {
|
721
|
+
if (!declaredTypesOnly) {
|
722
|
+
// The class derives from an unknown type, so all bets are off
|
723
|
+
// when trying to find a member. Return an unknown symbol.
|
724
|
+
const cm = {
|
725
|
+
symbol: symbol_1.Symbol.createWithType(0 /* None */, types_1.UnknownType.create()),
|
726
|
+
isInstanceMember: false,
|
727
|
+
isClassMember: true,
|
728
|
+
isClassVar: false,
|
729
|
+
classType: types_1.UnknownType.create(),
|
730
|
+
isTypeDeclared: false,
|
731
|
+
skippedUndeclaredType: false,
|
732
|
+
};
|
733
|
+
yield cm;
|
734
|
+
}
|
735
|
+
continue;
|
736
|
+
}
|
737
|
+
if (!(0, types_1.isInstantiableClass)(specializedMroClass)) {
|
738
|
+
continue;
|
739
|
+
}
|
740
|
+
const memberFields = specializedMroClass.details.fields;
|
741
|
+
// Look at instance members first if requested.
|
742
|
+
if ((flags & 8 /* SkipInstanceVariables */) === 0) {
|
743
|
+
const symbol = memberFields.get(memberName);
|
744
|
+
if (symbol && symbol.isInstanceMember()) {
|
745
|
+
const hasDeclaredType = symbol.hasTypedDeclarations();
|
746
|
+
if (!declaredTypesOnly || hasDeclaredType) {
|
747
|
+
const cm = {
|
748
|
+
symbol,
|
749
|
+
isInstanceMember: true,
|
750
|
+
isClassMember: symbol.isClassMember(),
|
751
|
+
isClassVar: symbol.isClassVar(),
|
752
|
+
classType: specializedMroClass,
|
753
|
+
isTypeDeclared: hasDeclaredType,
|
754
|
+
skippedUndeclaredType,
|
755
|
+
};
|
756
|
+
yield cm;
|
757
|
+
}
|
758
|
+
else {
|
759
|
+
skippedUndeclaredType = true;
|
760
|
+
}
|
761
|
+
}
|
762
|
+
}
|
763
|
+
// Next look at class members.
|
764
|
+
const symbol = memberFields.get(memberName);
|
765
|
+
if (symbol && symbol.isClassMember()) {
|
766
|
+
const hasDeclaredType = symbol.hasTypedDeclarations();
|
767
|
+
if (!declaredTypesOnly || hasDeclaredType) {
|
768
|
+
let isInstanceMember = symbol.isInstanceMember();
|
769
|
+
let isClassMember = true;
|
770
|
+
// For data classes and typed dicts, variables that are declared
|
771
|
+
// within the class are treated as instance variables. This distinction
|
772
|
+
// is important in cases where a variable is a callable type because
|
773
|
+
// we don't want to bind it to the instance like we would for a
|
774
|
+
// class member.
|
775
|
+
const isDataclass = types_1.ClassType.isDataClass(specializedMroClass);
|
776
|
+
const isTypedDict = types_1.ClassType.isTypedDictClass(specializedMroClass);
|
777
|
+
if (isDataclass || isTypedDict) {
|
778
|
+
const decls = symbol.getDeclarations();
|
779
|
+
if (decls.length > 0 && decls[0].type === 1 /* Variable */) {
|
780
|
+
isInstanceMember = true;
|
781
|
+
isClassMember = isDataclass;
|
782
|
+
}
|
783
|
+
}
|
784
|
+
const cm = {
|
785
|
+
symbol,
|
786
|
+
isInstanceMember,
|
787
|
+
isClassMember,
|
788
|
+
isClassVar: symbol.isClassVar(),
|
789
|
+
classType: specializedMroClass,
|
790
|
+
isTypeDeclared: hasDeclaredType,
|
791
|
+
skippedUndeclaredType,
|
792
|
+
};
|
793
|
+
yield cm;
|
794
|
+
}
|
795
|
+
else {
|
796
|
+
skippedUndeclaredType = true;
|
797
|
+
}
|
798
|
+
}
|
799
|
+
}
|
800
|
+
}
|
801
|
+
else if ((0, types_1.isAnyOrUnknown)(classType)) {
|
802
|
+
// The class derives from an unknown type, so all bets are off
|
803
|
+
// when trying to find a member. Return an unknown symbol.
|
804
|
+
const cm = {
|
805
|
+
symbol: symbol_1.Symbol.createWithType(0 /* None */, types_1.UnknownType.create()),
|
806
|
+
isInstanceMember: false,
|
807
|
+
isClassMember: true,
|
808
|
+
isClassVar: false,
|
809
|
+
classType: types_1.UnknownType.create(),
|
810
|
+
isTypeDeclared: false,
|
811
|
+
skippedUndeclaredType: false,
|
812
|
+
};
|
813
|
+
yield cm;
|
814
|
+
}
|
815
|
+
return undefined;
|
816
|
+
}
|
817
|
+
exports.getClassMemberIterator = getClassMemberIterator;
|
818
|
+
function* getClassIterator(classType, flags = 0 /* Default */) {
|
819
|
+
if ((0, types_1.isClass)(classType)) {
|
820
|
+
let skipMroEntry = (flags & 1 /* SkipOriginalClass */) !== 0;
|
821
|
+
for (const mroClass of classType.details.mro) {
|
822
|
+
if (skipMroEntry) {
|
823
|
+
skipMroEntry = false;
|
824
|
+
continue;
|
825
|
+
}
|
826
|
+
// If mroClass is an ancestor of classType, partially specialize
|
827
|
+
// it in the context of classType.
|
828
|
+
const specializedMroClass = partiallySpecializeType(mroClass, classType);
|
829
|
+
// Should we ignore members on the 'object' base class?
|
830
|
+
if (flags & 4 /* SkipObjectBaseClass */) {
|
831
|
+
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
832
|
+
if (types_1.ClassType.isBuiltIn(specializedMroClass, 'object')) {
|
833
|
+
break;
|
834
|
+
}
|
835
|
+
}
|
836
|
+
}
|
837
|
+
// Should we ignore members on the 'type' base class?
|
838
|
+
if (flags & 8 /* SkipTypeBaseClass */) {
|
839
|
+
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
840
|
+
if (types_1.ClassType.isBuiltIn(specializedMroClass, 'type')) {
|
841
|
+
break;
|
842
|
+
}
|
843
|
+
}
|
844
|
+
}
|
845
|
+
yield [mroClass, specializedMroClass];
|
846
|
+
if ((flags & 2 /* SkipBaseClasses */) !== 0) {
|
847
|
+
break;
|
848
|
+
}
|
849
|
+
}
|
850
|
+
}
|
851
|
+
return undefined;
|
852
|
+
}
|
853
|
+
exports.getClassIterator = getClassIterator;
|
854
|
+
function getClassFieldsRecursive(classType) {
|
855
|
+
const memberMap = new Map();
|
856
|
+
// Evaluate the types of members from the end of the MRO to the beginning.
|
857
|
+
for (let i = classType.details.mro.length - 1; i >= 0; i--) {
|
858
|
+
const mroClass = partiallySpecializeType(classType.details.mro[i], classType);
|
859
|
+
// If this ancestor class is unknown, throw away all symbols
|
860
|
+
// found so far because they could be overridden by the unknown class.
|
861
|
+
if (!(0, types_1.isClass)(mroClass)) {
|
862
|
+
memberMap.clear();
|
863
|
+
continue;
|
864
|
+
}
|
865
|
+
mroClass.details.fields.forEach((symbol, name) => {
|
866
|
+
if (!symbol.isIgnoredForProtocolMatch() && symbol.hasTypedDeclarations()) {
|
867
|
+
memberMap.set(name, {
|
868
|
+
classType: mroClass,
|
869
|
+
symbol,
|
870
|
+
isInstanceMember: symbol.isInstanceMember(),
|
871
|
+
isClassMember: symbol.isClassMember(),
|
872
|
+
isClassVar: symbol.isClassVar(),
|
873
|
+
isTypeDeclared: true,
|
874
|
+
skippedUndeclaredType: false,
|
875
|
+
});
|
876
|
+
}
|
877
|
+
});
|
878
|
+
}
|
879
|
+
return memberMap;
|
880
|
+
}
|
881
|
+
exports.getClassFieldsRecursive = getClassFieldsRecursive;
|
882
|
+
// Combines two lists of type var types, maintaining the combined order
|
883
|
+
// but removing any duplicates.
|
884
|
+
function addTypeVarsToListIfUnique(list1, list2) {
|
885
|
+
for (const type2 of list2) {
|
886
|
+
if (!list1.find((type1) => (0, types_1.isTypeSame)(convertToInstance(type1), convertToInstance(type2)))) {
|
887
|
+
list1.push(type2);
|
888
|
+
}
|
889
|
+
}
|
890
|
+
}
|
891
|
+
exports.addTypeVarsToListIfUnique = addTypeVarsToListIfUnique;
|
892
|
+
// Walks the type recursively (in a depth-first manner), finds all
|
893
|
+
// type variables that are referenced, and returns an ordered list
|
894
|
+
// of unique type variables. For example, if the type is
|
895
|
+
// Union[List[Dict[_T1, _T2]], _T1, _T3], the result would be
|
896
|
+
// [_T1, _T2, _T3].
|
897
|
+
function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
|
898
|
+
var _a, _b;
|
899
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
900
|
+
return [];
|
901
|
+
}
|
902
|
+
recursionCount++;
|
903
|
+
const getTypeVarsFromClass = (classType) => {
|
904
|
+
const combinedList = [];
|
905
|
+
if (classType.typeArguments) {
|
906
|
+
classType.typeArguments.forEach((typeArg) => {
|
907
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
|
908
|
+
});
|
909
|
+
}
|
910
|
+
return combinedList;
|
911
|
+
};
|
912
|
+
if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
|
913
|
+
const combinedList = [];
|
914
|
+
(_b = type.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.typeArguments.forEach((typeArg) => {
|
915
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
|
916
|
+
});
|
917
|
+
return combinedList;
|
918
|
+
}
|
919
|
+
if ((0, types_1.isTypeVar)(type)) {
|
920
|
+
// Don't return any recursive type alias placeholders.
|
921
|
+
if (type.details.recursiveTypeAliasName) {
|
922
|
+
return [];
|
923
|
+
}
|
924
|
+
// Don't return any P.args or P.kwargs types.
|
925
|
+
if ((0, types_1.isParamSpec)(type) && type.paramSpecAccess) {
|
926
|
+
return [];
|
927
|
+
}
|
928
|
+
return [types_1.TypeBase.isInstantiable(type) ? types_1.TypeVarType.cloneAsInstance(type) : type];
|
929
|
+
}
|
930
|
+
if ((0, types_1.isClass)(type)) {
|
931
|
+
return getTypeVarsFromClass(type);
|
932
|
+
}
|
933
|
+
if ((0, types_1.isUnion)(type)) {
|
934
|
+
const combinedList = [];
|
935
|
+
doForEachSubtype(type, (subtype) => {
|
936
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(subtype, recursionCount));
|
937
|
+
});
|
938
|
+
return combinedList;
|
939
|
+
}
|
940
|
+
if ((0, types_1.isFunction)(type)) {
|
941
|
+
const combinedList = [];
|
942
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
943
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(types_1.FunctionType.getEffectiveParameterType(type, i), recursionCount));
|
944
|
+
}
|
945
|
+
if (type.details.paramSpec) {
|
946
|
+
addTypeVarsToListIfUnique(combinedList, [type.details.paramSpec]);
|
947
|
+
}
|
948
|
+
const returnType = types_1.FunctionType.getSpecializedReturnType(type);
|
949
|
+
if (returnType) {
|
950
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(returnType, recursionCount));
|
951
|
+
}
|
952
|
+
return combinedList;
|
953
|
+
}
|
954
|
+
return [];
|
955
|
+
}
|
956
|
+
exports.getTypeVarArgumentsRecursive = getTypeVarArgumentsRecursive;
|
957
|
+
// Creates a specialized version of the class, filling in any unspecified
|
958
|
+
// type arguments with Unknown.
|
959
|
+
function specializeClassType(type) {
|
960
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(type));
|
961
|
+
const typeParams = types_1.ClassType.getTypeParameters(type);
|
962
|
+
typeParams.forEach((typeParam) => {
|
963
|
+
typeVarContext.setTypeVarType(typeParam, types_1.UnknownType.create());
|
964
|
+
});
|
965
|
+
return applySolvedTypeVars(type, typeVarContext);
|
966
|
+
}
|
967
|
+
exports.specializeClassType = specializeClassType;
|
968
|
+
// Recursively finds all of the type arguments and sets them
|
969
|
+
// to the specified srcType.
|
970
|
+
function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionCount = 0) {
|
971
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
972
|
+
return;
|
973
|
+
}
|
974
|
+
recursionCount++;
|
975
|
+
if (typeVarContext.isLocked()) {
|
976
|
+
return;
|
977
|
+
}
|
978
|
+
switch (destType.category) {
|
979
|
+
case 9 /* Union */:
|
980
|
+
doForEachSubtype(destType, (subtype) => {
|
981
|
+
setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
982
|
+
});
|
983
|
+
break;
|
984
|
+
case 7 /* Class */:
|
985
|
+
if (destType.typeArguments) {
|
986
|
+
destType.typeArguments.forEach((typeArg) => {
|
987
|
+
setTypeArgumentsRecursive(typeArg, srcType, typeVarContext, recursionCount);
|
988
|
+
});
|
989
|
+
}
|
990
|
+
if (destType.tupleTypeArguments) {
|
991
|
+
destType.tupleTypeArguments.forEach((typeArg) => {
|
992
|
+
setTypeArgumentsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
|
993
|
+
});
|
994
|
+
}
|
995
|
+
break;
|
996
|
+
case 5 /* Function */:
|
997
|
+
if (destType.specializedTypes) {
|
998
|
+
destType.specializedTypes.parameterTypes.forEach((paramType) => {
|
999
|
+
setTypeArgumentsRecursive(paramType, srcType, typeVarContext, recursionCount);
|
1000
|
+
});
|
1001
|
+
if (destType.specializedTypes.returnType) {
|
1002
|
+
setTypeArgumentsRecursive(destType.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
|
1003
|
+
}
|
1004
|
+
}
|
1005
|
+
else {
|
1006
|
+
destType.details.parameters.forEach((param) => {
|
1007
|
+
setTypeArgumentsRecursive(param.type, srcType, typeVarContext, recursionCount);
|
1008
|
+
});
|
1009
|
+
if (destType.details.declaredReturnType) {
|
1010
|
+
setTypeArgumentsRecursive(destType.details.declaredReturnType, srcType, typeVarContext, recursionCount);
|
1011
|
+
}
|
1012
|
+
if (destType.details.paramSpec) {
|
1013
|
+
// Fill in an empty signature for a ParamSpec if the source is Any or Unknown.
|
1014
|
+
if (!typeVarContext.hasTypeVar(destType.details.paramSpec) && (0, types_1.isAnyOrUnknown)(srcType)) {
|
1015
|
+
typeVarContext.setParamSpec(destType.details.paramSpec, {
|
1016
|
+
flags: 0 /* None */,
|
1017
|
+
parameters: types_1.FunctionType.getDefaultParameters(),
|
1018
|
+
typeVarScopeId: undefined,
|
1019
|
+
docString: undefined,
|
1020
|
+
paramSpec: undefined,
|
1021
|
+
});
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
break;
|
1026
|
+
case 6 /* OverloadedFunction */:
|
1027
|
+
destType.overloads.forEach((subtype) => {
|
1028
|
+
setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
1029
|
+
});
|
1030
|
+
break;
|
1031
|
+
case 10 /* TypeVar */:
|
1032
|
+
if (!typeVarContext.hasTypeVar(destType)) {
|
1033
|
+
typeVarContext.setTypeVarType(destType, srcType);
|
1034
|
+
}
|
1035
|
+
break;
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
exports.setTypeArgumentsRecursive = setTypeArgumentsRecursive;
|
1039
|
+
// Builds a mapping between type parameters and their specialized
|
1040
|
+
// types. For example, if the generic type is Dict[_T1, _T2] and the
|
1041
|
+
// specialized type is Dict[str, int], it returns a map that associates
|
1042
|
+
// _T1 with str and _T2 with int.
|
1043
|
+
function buildTypeVarContextFromSpecializedClass(classType, makeConcrete = true) {
|
1044
|
+
const typeParameters = types_1.ClassType.getTypeParameters(classType);
|
1045
|
+
let typeArguments = classType.typeArguments;
|
1046
|
+
// If there are no type arguments, we can either use the type variables
|
1047
|
+
// from the type parameters (keeping the type arguments generic) or
|
1048
|
+
// fill in concrete types.
|
1049
|
+
if (!typeArguments && !makeConcrete) {
|
1050
|
+
typeArguments = typeParameters;
|
1051
|
+
}
|
1052
|
+
const typeVarContext = buildTypeVarContext(typeParameters, typeArguments, getTypeVarScopeId(classType));
|
1053
|
+
if (types_1.ClassType.isTupleClass(classType) && classType.tupleTypeArguments && typeParameters.length >= 1) {
|
1054
|
+
typeVarContext.setVariadicTypeVar(typeParameters[0], classType.tupleTypeArguments);
|
1055
|
+
}
|
1056
|
+
return typeVarContext;
|
1057
|
+
}
|
1058
|
+
exports.buildTypeVarContextFromSpecializedClass = buildTypeVarContextFromSpecializedClass;
|
1059
|
+
function buildTypeVarContext(typeParameters, typeArgs, typeVarScopeId) {
|
1060
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext(typeVarScopeId);
|
1061
|
+
typeParameters.forEach((typeParam, index) => {
|
1062
|
+
let typeArgType;
|
1063
|
+
if (typeArgs) {
|
1064
|
+
if ((0, types_1.isParamSpec)(typeParam)) {
|
1065
|
+
if (index < typeArgs.length) {
|
1066
|
+
typeArgType = typeArgs[index];
|
1067
|
+
if ((0, types_1.isFunction)(typeArgType) && types_1.FunctionType.isParamSpecValue(typeArgType)) {
|
1068
|
+
const paramSpecEntries = [];
|
1069
|
+
const typeArgFunctionType = typeArgType;
|
1070
|
+
typeArgType.details.parameters.forEach((param, paramIndex) => {
|
1071
|
+
paramSpecEntries.push({
|
1072
|
+
category: param.category,
|
1073
|
+
name: param.name,
|
1074
|
+
hasDefault: !!param.hasDefault,
|
1075
|
+
isNameSynthesized: param.isNameSynthesized,
|
1076
|
+
type: types_1.FunctionType.getEffectiveParameterType(typeArgFunctionType, paramIndex),
|
1077
|
+
});
|
1078
|
+
});
|
1079
|
+
typeVarContext.setParamSpec(typeParam, {
|
1080
|
+
parameters: paramSpecEntries,
|
1081
|
+
typeVarScopeId: typeArgType.details.typeVarScopeId,
|
1082
|
+
flags: typeArgType.details.flags,
|
1083
|
+
docString: typeArgType.details.docString,
|
1084
|
+
paramSpec: typeArgType.details.paramSpec,
|
1085
|
+
});
|
1086
|
+
}
|
1087
|
+
else if ((0, types_1.isParamSpec)(typeArgType)) {
|
1088
|
+
typeVarContext.setParamSpec(typeParam, {
|
1089
|
+
flags: 0 /* None */,
|
1090
|
+
parameters: [],
|
1091
|
+
typeVarScopeId: undefined,
|
1092
|
+
docString: undefined,
|
1093
|
+
paramSpec: typeArgType,
|
1094
|
+
});
|
1095
|
+
}
|
1096
|
+
else if ((0, types_1.isAnyOrUnknown)(typeArgType)) {
|
1097
|
+
// Fill in an empty signature if the arg type is Any or Unknown.
|
1098
|
+
typeVarContext.setParamSpec(typeParam, {
|
1099
|
+
flags: 0 /* None */,
|
1100
|
+
parameters: types_1.FunctionType.getDefaultParameters(),
|
1101
|
+
typeVarScopeId: undefined,
|
1102
|
+
docString: undefined,
|
1103
|
+
paramSpec: undefined,
|
1104
|
+
});
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
}
|
1108
|
+
else {
|
1109
|
+
if (index >= typeArgs.length) {
|
1110
|
+
typeArgType = types_1.AnyType.create();
|
1111
|
+
}
|
1112
|
+
else {
|
1113
|
+
typeArgType = typeArgs[index];
|
1114
|
+
}
|
1115
|
+
typeVarContext.setTypeVarType(typeParam, typeArgType, typeArgType, /* retainLiteral */ true);
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
});
|
1119
|
+
return typeVarContext;
|
1120
|
+
}
|
1121
|
+
exports.buildTypeVarContext = buildTypeVarContext;
|
1122
|
+
// Determines the specialized base class type that srcType derives from.
|
1123
|
+
function specializeForBaseClass(srcType, baseClass) {
|
1124
|
+
const typeParams = types_1.ClassType.getTypeParameters(baseClass);
|
1125
|
+
// If there are no type parameters for the specified base class,
|
1126
|
+
// no specialization is required.
|
1127
|
+
if (typeParams.length === 0) {
|
1128
|
+
return baseClass;
|
1129
|
+
}
|
1130
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(srcType);
|
1131
|
+
const specializedType = applySolvedTypeVars(baseClass, typeVarContext);
|
1132
|
+
(0, debug_1.assert)((0, types_1.isInstantiableClass)(specializedType));
|
1133
|
+
return specializedType;
|
1134
|
+
}
|
1135
|
+
exports.specializeForBaseClass = specializeForBaseClass;
|
1136
|
+
// If ignoreUnknown is true, an unknown base class is ignored when
|
1137
|
+
// checking for derivation. If ignoreUnknown is false, a return value
|
1138
|
+
// of true is assumed.
|
1139
|
+
function derivesFromClassRecursive(classType, baseClassToFind, ignoreUnknown) {
|
1140
|
+
if (types_1.ClassType.isSameGenericClass(classType, baseClassToFind)) {
|
1141
|
+
return true;
|
1142
|
+
}
|
1143
|
+
for (const baseClass of classType.details.baseClasses) {
|
1144
|
+
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
1145
|
+
if (derivesFromClassRecursive(baseClass, baseClassToFind, ignoreUnknown)) {
|
1146
|
+
return true;
|
1147
|
+
}
|
1148
|
+
}
|
1149
|
+
else if (!ignoreUnknown && (0, types_1.isAnyOrUnknown)(baseClass)) {
|
1150
|
+
// If the base class is unknown, we have to make a conservative assumption.
|
1151
|
+
return true;
|
1152
|
+
}
|
1153
|
+
}
|
1154
|
+
return false;
|
1155
|
+
}
|
1156
|
+
exports.derivesFromClassRecursive = derivesFromClassRecursive;
|
1157
|
+
function synthesizeTypeVarForSelfCls(classType, isClsParam) {
|
1158
|
+
var _a;
|
1159
|
+
const selfType = types_1.TypeVarType.createInstance(`__type_of_self__`);
|
1160
|
+
const scopeId = (_a = getTypeVarScopeId(classType)) !== null && _a !== void 0 ? _a : '';
|
1161
|
+
selfType.details.isSynthesized = true;
|
1162
|
+
selfType.details.isSynthesizedSelf = true;
|
1163
|
+
selfType.nameWithScope = types_1.TypeVarType.makeNameWithScope(selfType.details.name, scopeId);
|
1164
|
+
selfType.scopeId = scopeId;
|
1165
|
+
const boundType = types_1.ClassType.cloneForSpecialization(classType, types_1.ClassType.getTypeParameters(classType),
|
1166
|
+
/* isTypeArgumentExplicit */ false,
|
1167
|
+
/* includeSubclasses */ true);
|
1168
|
+
selfType.details.boundType = types_1.ClassType.cloneAsInstance(boundType);
|
1169
|
+
return isClsParam ? types_1.TypeVarType.cloneAsInstantiable(selfType) : selfType;
|
1170
|
+
}
|
1171
|
+
exports.synthesizeTypeVarForSelfCls = synthesizeTypeVarForSelfCls;
|
1172
|
+
// Returns the declared "return" type (the type returned from a return statement)
|
1173
|
+
// if it was declared, or undefined otherwise.
|
1174
|
+
function getDeclaredGeneratorReturnType(functionType) {
|
1175
|
+
const returnType = types_1.FunctionType.getSpecializedReturnType(functionType);
|
1176
|
+
if (returnType) {
|
1177
|
+
const generatorTypeArgs = getGeneratorTypeArgs(returnType);
|
1178
|
+
if (generatorTypeArgs) {
|
1179
|
+
// The send type is the third type arg.
|
1180
|
+
return generatorTypeArgs.length >= 3 ? generatorTypeArgs[2] : types_1.UnknownType.create();
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
return undefined;
|
1184
|
+
}
|
1185
|
+
exports.getDeclaredGeneratorReturnType = getDeclaredGeneratorReturnType;
|
1186
|
+
// If the declared return type is a Generator, Iterable, Iterator or the async
|
1187
|
+
// counterparts, returns the yield type. If the type is invalid for a generator,
|
1188
|
+
// returns undefined.
|
1189
|
+
function getGeneratorYieldType(declaredReturnType, isAsync) {
|
1190
|
+
let isLegalGeneratorType = true;
|
1191
|
+
const yieldType = mapSubtypes(declaredReturnType, (subtype) => {
|
1192
|
+
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
1193
|
+
return subtype;
|
1194
|
+
}
|
1195
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
1196
|
+
const expectedClasses = [
|
1197
|
+
['AsyncIterable', 'Iterable'],
|
1198
|
+
['AsyncIterator', 'Iterator'],
|
1199
|
+
['AsyncGenerator', 'Generator'],
|
1200
|
+
['', 'AwaitableGenerator'],
|
1201
|
+
];
|
1202
|
+
if (expectedClasses.some((classes) => types_1.ClassType.isBuiltIn(subtype, isAsync ? classes[0] : classes[1]))) {
|
1203
|
+
return subtype.typeArguments && subtype.typeArguments.length >= 1
|
1204
|
+
? subtype.typeArguments[0]
|
1205
|
+
: types_1.UnknownType.create();
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
isLegalGeneratorType = false;
|
1209
|
+
return undefined;
|
1210
|
+
});
|
1211
|
+
return isLegalGeneratorType ? yieldType : undefined;
|
1212
|
+
}
|
1213
|
+
exports.getGeneratorYieldType = getGeneratorYieldType;
|
1214
|
+
function isEffectivelyInstantiable(type) {
|
1215
|
+
if (types_1.TypeBase.isInstantiable(type)) {
|
1216
|
+
return true;
|
1217
|
+
}
|
1218
|
+
// Handle the special case of 'type', which is instantiable.
|
1219
|
+
if ((0, types_1.isClassInstance)(type) && types_1.ClassType.isBuiltIn(type, 'type')) {
|
1220
|
+
return true;
|
1221
|
+
}
|
1222
|
+
if ((0, types_1.isUnion)(type)) {
|
1223
|
+
return type.subtypes.every((subtype) => isEffectivelyInstantiable(subtype));
|
1224
|
+
}
|
1225
|
+
return false;
|
1226
|
+
}
|
1227
|
+
exports.isEffectivelyInstantiable = isEffectivelyInstantiable;
|
1228
|
+
function convertToInstance(type) {
|
1229
|
+
let result = mapSubtypes(type, (subtype) => {
|
1230
|
+
switch (subtype.category) {
|
1231
|
+
case 7 /* Class */: {
|
1232
|
+
// Handle Type[x] as a special case.
|
1233
|
+
if (types_1.ClassType.isBuiltIn(subtype, 'Type')) {
|
1234
|
+
if (!subtype.typeArguments || subtype.typeArguments.length < 1) {
|
1235
|
+
return types_1.UnknownType.create();
|
1236
|
+
}
|
1237
|
+
else {
|
1238
|
+
return convertToInstantiable(subtype.typeArguments[0]);
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
return types_1.ClassType.cloneAsInstance(subtype);
|
1242
|
+
}
|
1243
|
+
case 3 /* None */: {
|
1244
|
+
return types_1.NoneType.createInstance();
|
1245
|
+
}
|
1246
|
+
case 5 /* Function */: {
|
1247
|
+
if (types_1.TypeBase.isInstantiable(subtype)) {
|
1248
|
+
return types_1.FunctionType.cloneAsInstance(subtype);
|
1249
|
+
}
|
1250
|
+
break;
|
1251
|
+
}
|
1252
|
+
case 10 /* TypeVar */: {
|
1253
|
+
if (types_1.TypeBase.isInstantiable(subtype)) {
|
1254
|
+
return types_1.TypeVarType.cloneAsInstance(subtype);
|
1255
|
+
}
|
1256
|
+
break;
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
return subtype;
|
1260
|
+
});
|
1261
|
+
// Copy over any type alias information.
|
1262
|
+
if (type.typeAliasInfo && type !== result) {
|
1263
|
+
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1264
|
+
}
|
1265
|
+
return result;
|
1266
|
+
}
|
1267
|
+
exports.convertToInstance = convertToInstance;
|
1268
|
+
function convertToInstantiable(type) {
|
1269
|
+
let result = mapSubtypes(type, (subtype) => {
|
1270
|
+
switch (subtype.category) {
|
1271
|
+
case 7 /* Class */: {
|
1272
|
+
return types_1.ClassType.cloneAsInstantiable(subtype);
|
1273
|
+
}
|
1274
|
+
case 3 /* None */: {
|
1275
|
+
return types_1.NoneType.createType();
|
1276
|
+
}
|
1277
|
+
case 5 /* Function */: {
|
1278
|
+
return types_1.FunctionType.cloneAsInstantiable(subtype);
|
1279
|
+
}
|
1280
|
+
case 10 /* TypeVar */: {
|
1281
|
+
return types_1.TypeVarType.cloneAsInstantiable(subtype);
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
return subtype;
|
1285
|
+
});
|
1286
|
+
// Copy over any type alias information.
|
1287
|
+
if (type.typeAliasInfo && type !== result) {
|
1288
|
+
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
1289
|
+
}
|
1290
|
+
return result;
|
1291
|
+
}
|
1292
|
+
exports.convertToInstantiable = convertToInstantiable;
|
1293
|
+
function getMembersForClass(classType, symbolTable, includeInstanceVars) {
|
1294
|
+
for (let i = 0; i < classType.details.mro.length; i++) {
|
1295
|
+
const mroClass = classType.details.mro[i];
|
1296
|
+
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
1297
|
+
// Add any new member variables from this class.
|
1298
|
+
const isClassTypedDict = types_1.ClassType.isTypedDictClass(mroClass);
|
1299
|
+
mroClass.details.fields.forEach((symbol, name) => {
|
1300
|
+
if (symbol.isClassMember() || (includeInstanceVars && symbol.isInstanceMember())) {
|
1301
|
+
if (!isClassTypedDict || !(0, symbolUtils_1.isTypedDictMemberAccessedThroughIndex)(symbol)) {
|
1302
|
+
if (!symbol.isInitVar()) {
|
1303
|
+
const existingSymbol = symbolTable.get(name);
|
1304
|
+
if (!existingSymbol) {
|
1305
|
+
symbolTable.set(name, symbol);
|
1306
|
+
}
|
1307
|
+
else if (!existingSymbol.hasTypedDeclarations() && symbol.hasTypedDeclarations()) {
|
1308
|
+
// If the existing symbol is unannotated but a parent class
|
1309
|
+
// has an annotation for the symbol, use the parent type instead.
|
1310
|
+
symbolTable.set(name, symbol);
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
});
|
1316
|
+
}
|
1317
|
+
}
|
1318
|
+
// Add members of the metaclass as well.
|
1319
|
+
if (!includeInstanceVars) {
|
1320
|
+
const metaclass = classType.details.effectiveMetaclass;
|
1321
|
+
if (metaclass && (0, types_1.isInstantiableClass)(metaclass)) {
|
1322
|
+
for (const mroClass of metaclass.details.mro) {
|
1323
|
+
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
1324
|
+
mroClass.details.fields.forEach((symbol, name) => {
|
1325
|
+
const existingSymbol = symbolTable.get(name);
|
1326
|
+
if (!existingSymbol) {
|
1327
|
+
symbolTable.set(name, symbol);
|
1328
|
+
}
|
1329
|
+
else if (!existingSymbol.hasTypedDeclarations() && symbol.hasTypedDeclarations()) {
|
1330
|
+
// If the existing symbol is unannotated but a parent class
|
1331
|
+
// has an annotation for the symbol, use the parent type instead.
|
1332
|
+
symbolTable.set(name, symbol);
|
1333
|
+
}
|
1334
|
+
});
|
1335
|
+
}
|
1336
|
+
else {
|
1337
|
+
break;
|
1338
|
+
}
|
1339
|
+
}
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
exports.getMembersForClass = getMembersForClass;
|
1344
|
+
function getMembersForModule(moduleType, symbolTable) {
|
1345
|
+
// Start with the loader fields. If there are any symbols of the
|
1346
|
+
// same name defined within the module, they will overwrite the
|
1347
|
+
// loader fields.
|
1348
|
+
if (moduleType.loaderFields) {
|
1349
|
+
moduleType.loaderFields.forEach((symbol, name) => {
|
1350
|
+
symbolTable.set(name, symbol);
|
1351
|
+
});
|
1352
|
+
}
|
1353
|
+
moduleType.fields.forEach((symbol, name) => {
|
1354
|
+
symbolTable.set(name, symbol);
|
1355
|
+
});
|
1356
|
+
}
|
1357
|
+
exports.getMembersForModule = getMembersForModule;
|
1358
|
+
// Determines if the type is an Unknown or a union that contains an Unknown.
|
1359
|
+
// It does not look at type arguments.
|
1360
|
+
function containsUnknown(type) {
|
1361
|
+
let foundUnknown = false;
|
1362
|
+
doForEachSubtype(type, (subtype) => {
|
1363
|
+
if ((0, types_1.isUnknown)(subtype)) {
|
1364
|
+
foundUnknown = true;
|
1365
|
+
}
|
1366
|
+
});
|
1367
|
+
return foundUnknown;
|
1368
|
+
}
|
1369
|
+
exports.containsUnknown = containsUnknown;
|
1370
|
+
// Determines if any part of the type contains "Unknown", including any type arguments.
|
1371
|
+
function isPartlyUnknown(type, allowUnknownTypeArgsForClasses = false, recursionCount = 0) {
|
1372
|
+
var _a, _b;
|
1373
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1374
|
+
return false;
|
1375
|
+
}
|
1376
|
+
recursionCount++;
|
1377
|
+
if ((0, types_1.isUnknown)(type)) {
|
1378
|
+
return true;
|
1379
|
+
}
|
1380
|
+
// If this is a generic type alias, see if any of its type arguments
|
1381
|
+
// are either unspecified or are partially known.
|
1382
|
+
if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
|
1383
|
+
if (type.typeAliasInfo.typeArguments.some((typeArg) => isPartlyUnknown(typeArg, allowUnknownTypeArgsForClasses, recursionCount))) {
|
1384
|
+
return true;
|
1385
|
+
}
|
1386
|
+
}
|
1387
|
+
// See if a union contains an unknown type.
|
1388
|
+
if ((0, types_1.isUnion)(type)) {
|
1389
|
+
return ((0, types_1.findSubtype)(type, (subtype) => isPartlyUnknown(subtype, allowUnknownTypeArgsForClasses, recursionCount)) !==
|
1390
|
+
undefined);
|
1391
|
+
}
|
1392
|
+
// See if an object or class has an unknown type argument.
|
1393
|
+
if ((0, types_1.isClass)(type)) {
|
1394
|
+
if (types_1.TypeBase.isInstance(type)) {
|
1395
|
+
allowUnknownTypeArgsForClasses = false;
|
1396
|
+
}
|
1397
|
+
if (!allowUnknownTypeArgsForClasses && !types_1.ClassType.isPseudoGenericClass(type)) {
|
1398
|
+
const typeArgs = ((_b = type.tupleTypeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.typeArguments;
|
1399
|
+
if (typeArgs) {
|
1400
|
+
for (const argType of typeArgs) {
|
1401
|
+
if (isPartlyUnknown(argType, allowUnknownTypeArgsForClasses, recursionCount)) {
|
1402
|
+
return true;
|
1403
|
+
}
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
}
|
1407
|
+
return false;
|
1408
|
+
}
|
1409
|
+
// See if a function has an unknown type.
|
1410
|
+
if ((0, types_1.isOverloadedFunction)(type)) {
|
1411
|
+
return type.overloads.some((overload) => {
|
1412
|
+
return isPartlyUnknown(overload, false, recursionCount);
|
1413
|
+
});
|
1414
|
+
}
|
1415
|
+
if ((0, types_1.isFunction)(type)) {
|
1416
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
1417
|
+
// Ignore parameters such as "*" that have no name.
|
1418
|
+
if (type.details.parameters[i].name) {
|
1419
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, i);
|
1420
|
+
if (isPartlyUnknown(paramType, /* allowUnknownTypeArgsForClasses */ false, recursionCount)) {
|
1421
|
+
return true;
|
1422
|
+
}
|
1423
|
+
}
|
1424
|
+
}
|
1425
|
+
if (type.details.declaredReturnType &&
|
1426
|
+
!types_1.FunctionType.isParamSpecValue(type) &&
|
1427
|
+
isPartlyUnknown(type.details.declaredReturnType, /* allowUnknownTypeArgsForClasses */ false, recursionCount)) {
|
1428
|
+
return true;
|
1429
|
+
}
|
1430
|
+
return false;
|
1431
|
+
}
|
1432
|
+
return false;
|
1433
|
+
}
|
1434
|
+
exports.isPartlyUnknown = isPartlyUnknown;
|
1435
|
+
// If the specified type is a generic class with a single type argument
|
1436
|
+
// that is a union, it "explodes" the class into a union of classes with
|
1437
|
+
// each element of the union - e.g. Foo[A | B] becomes Foo[A] | Foo[B].
|
1438
|
+
function explodeGenericClass(classType) {
|
1439
|
+
if (!classType.typeArguments || classType.typeArguments.length !== 1 || !(0, types_1.isUnion)(classType.typeArguments[0])) {
|
1440
|
+
return classType;
|
1441
|
+
}
|
1442
|
+
return (0, types_1.combineTypes)(classType.typeArguments[0].subtypes.map((subtype) => {
|
1443
|
+
return types_1.ClassType.cloneForSpecialization(classType, [subtype], /* isTypeArgumentExplicit */ true);
|
1444
|
+
}));
|
1445
|
+
}
|
1446
|
+
exports.explodeGenericClass = explodeGenericClass;
|
1447
|
+
// If the type is a union of same-sized tuples, these are combined into
|
1448
|
+
// a single tuple with that size. Otherwise, returns undefined.
|
1449
|
+
function combineSameSizedTuples(type, tupleType) {
|
1450
|
+
if (!tupleType || !(0, types_1.isInstantiableClass)(tupleType) || isUnboundedTupleClass(tupleType)) {
|
1451
|
+
return undefined;
|
1452
|
+
}
|
1453
|
+
let tupleEntries;
|
1454
|
+
let isValid = true;
|
1455
|
+
doForEachSubtype(type, (subtype) => {
|
1456
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
1457
|
+
let tupleClass;
|
1458
|
+
if ((0, types_1.isClass)(subtype) && isTupleClass(subtype) && !isUnboundedTupleClass(subtype)) {
|
1459
|
+
tupleClass = subtype;
|
1460
|
+
}
|
1461
|
+
if (!tupleClass) {
|
1462
|
+
// Look in the mro list to see if this subtype derives from a
|
1463
|
+
// tuple with a known size. This includes named tuples.
|
1464
|
+
tupleClass = subtype.details.mro.find((mroClass) => (0, types_1.isClass)(mroClass) && isTupleClass(mroClass) && !isUnboundedTupleClass(mroClass));
|
1465
|
+
}
|
1466
|
+
if (tupleClass && (0, types_1.isClass)(tupleClass) && tupleClass.tupleTypeArguments) {
|
1467
|
+
if (tupleEntries) {
|
1468
|
+
if (tupleEntries.length === tupleClass.tupleTypeArguments.length) {
|
1469
|
+
tupleClass.tupleTypeArguments.forEach((entry, index) => {
|
1470
|
+
tupleEntries[index].push(entry.type);
|
1471
|
+
});
|
1472
|
+
}
|
1473
|
+
else {
|
1474
|
+
isValid = false;
|
1475
|
+
}
|
1476
|
+
}
|
1477
|
+
else {
|
1478
|
+
tupleEntries = tupleClass.tupleTypeArguments.map((entry) => [entry.type]);
|
1479
|
+
}
|
1480
|
+
}
|
1481
|
+
else {
|
1482
|
+
isValid = false;
|
1483
|
+
}
|
1484
|
+
}
|
1485
|
+
else {
|
1486
|
+
isValid = false;
|
1487
|
+
}
|
1488
|
+
});
|
1489
|
+
if (!isValid || !tupleEntries) {
|
1490
|
+
return undefined;
|
1491
|
+
}
|
1492
|
+
return convertToInstance(specializeTupleClass(tupleType, tupleEntries.map((entry) => {
|
1493
|
+
return { type: (0, types_1.combineTypes)(entry), isUnbounded: false };
|
1494
|
+
})));
|
1495
|
+
}
|
1496
|
+
exports.combineSameSizedTuples = combineSameSizedTuples;
|
1497
|
+
// Tuples require special handling for specialization. This method computes
|
1498
|
+
// the "effective" type argument, which is a union of the variadic type
|
1499
|
+
// arguments. If stripLiterals is true, literal values are stripped when
|
1500
|
+
// computing the effective type args.
|
1501
|
+
function specializeTupleClass(classType, typeArgs, isTypeArgumentExplicit = true, stripLiterals = true, isUnpackedTuple = false) {
|
1502
|
+
let combinedTupleType = (0, types_1.combineTypes)(typeArgs.map((t) => t.type));
|
1503
|
+
if (stripLiterals) {
|
1504
|
+
combinedTupleType = stripLiteralValue(combinedTupleType);
|
1505
|
+
}
|
1506
|
+
// An empty tuple has an effective type of Any.
|
1507
|
+
if ((0, types_1.isNever)(combinedTupleType)) {
|
1508
|
+
combinedTupleType = types_1.AnyType.create();
|
1509
|
+
}
|
1510
|
+
const clonedClassType = types_1.ClassType.cloneForSpecialization(classType, [combinedTupleType], isTypeArgumentExplicit,
|
1511
|
+
/* includeSubclasses */ undefined, typeArgs);
|
1512
|
+
if (isUnpackedTuple) {
|
1513
|
+
clonedClassType.isUnpacked = true;
|
1514
|
+
}
|
1515
|
+
return clonedClassType;
|
1516
|
+
}
|
1517
|
+
exports.specializeTupleClass = specializeTupleClass;
|
1518
|
+
// If the type is a function or overloaded function that has a paramSpec
|
1519
|
+
// associated with it and P.args and P.kwargs at the end of the signature,
|
1520
|
+
// it removes these parameters from the function.
|
1521
|
+
function removeParamSpecVariadicsFromSignature(type) {
|
1522
|
+
if ((0, types_1.isFunction)(type)) {
|
1523
|
+
return removeParamSpecVariadicsFromFunction(type);
|
1524
|
+
}
|
1525
|
+
const newOverloads = [];
|
1526
|
+
let newTypeNeeded = false;
|
1527
|
+
for (const overload of type.overloads) {
|
1528
|
+
const newOverload = removeParamSpecVariadicsFromFunction(overload);
|
1529
|
+
newOverloads.push(newOverload);
|
1530
|
+
if (newOverload !== overload) {
|
1531
|
+
newTypeNeeded = true;
|
1532
|
+
}
|
1533
|
+
}
|
1534
|
+
return newTypeNeeded ? types_1.OverloadedFunctionType.create(newOverloads) : type;
|
1535
|
+
}
|
1536
|
+
exports.removeParamSpecVariadicsFromSignature = removeParamSpecVariadicsFromSignature;
|
1537
|
+
function removeParamSpecVariadicsFromFunction(type) {
|
1538
|
+
const paramCount = type.details.parameters.length;
|
1539
|
+
if (paramCount < 2) {
|
1540
|
+
return type;
|
1541
|
+
}
|
1542
|
+
const argsParam = type.details.parameters[paramCount - 2];
|
1543
|
+
const kwargsParam = type.details.parameters[paramCount - 1];
|
1544
|
+
if (argsParam.category !== 1 /* VarArgList */ ||
|
1545
|
+
kwargsParam.category !== 2 /* VarArgDictionary */ ||
|
1546
|
+
!(0, types_1.isParamSpec)(argsParam.type) ||
|
1547
|
+
!(0, types_1.isParamSpec)(kwargsParam.type) ||
|
1548
|
+
!(0, types_1.isTypeSame)(argsParam.type, kwargsParam.type)) {
|
1549
|
+
return type;
|
1550
|
+
}
|
1551
|
+
return types_1.FunctionType.cloneRemoveParamSpecVariadics(type, argsParam.type);
|
1552
|
+
}
|
1553
|
+
exports.removeParamSpecVariadicsFromFunction = removeParamSpecVariadicsFromFunction;
|
1554
|
+
function _expandVariadicUnpackedUnion(type) {
|
1555
|
+
if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.tupleTypeArguments && type.isUnpacked) {
|
1556
|
+
return (0, types_1.combineTypes)(type.tupleTypeArguments.map((t) => t.type));
|
1557
|
+
}
|
1558
|
+
return type;
|
1559
|
+
}
|
1560
|
+
// If the declared return type for the function is a Generator or AsyncGenerator,
|
1561
|
+
// returns the type arguments for the type.
|
1562
|
+
function getGeneratorTypeArgs(returnType) {
|
1563
|
+
var _a;
|
1564
|
+
if ((0, types_1.isClassInstance)(returnType)) {
|
1565
|
+
if (types_1.ClassType.isBuiltIn(returnType, ['Generator', 'AsyncGenerator'])) {
|
1566
|
+
return returnType.typeArguments;
|
1567
|
+
}
|
1568
|
+
else if (types_1.ClassType.isBuiltIn(returnType, 'AwaitableGenerator')) {
|
1569
|
+
// AwaitableGenerator has four type arguments, and the last 3
|
1570
|
+
// correspond to the generator.
|
1571
|
+
return (_a = returnType.typeArguments) === null || _a === void 0 ? void 0 : _a.slice(1);
|
1572
|
+
}
|
1573
|
+
}
|
1574
|
+
return undefined;
|
1575
|
+
}
|
1576
|
+
exports.getGeneratorTypeArgs = getGeneratorTypeArgs;
|
1577
|
+
function requiresTypeArguments(classType) {
|
1578
|
+
if (classType.details.typeParameters.length > 0) {
|
1579
|
+
// If there are type parameters, type arguments are needed.
|
1580
|
+
// The exception is if type parameters have been synthesized
|
1581
|
+
// for classes that have untyped constructors.
|
1582
|
+
return !classType.details.typeParameters[0].details.isSynthesized;
|
1583
|
+
}
|
1584
|
+
// There are a few built-in special classes that require
|
1585
|
+
// type arguments even though typeParameters is empty.
|
1586
|
+
if (types_1.ClassType.isSpecialBuiltIn(classType)) {
|
1587
|
+
const specialClasses = [
|
1588
|
+
'Tuple',
|
1589
|
+
'Callable',
|
1590
|
+
'Generic',
|
1591
|
+
'Type',
|
1592
|
+
'Optional',
|
1593
|
+
'Union',
|
1594
|
+
'Literal',
|
1595
|
+
'Annotated',
|
1596
|
+
'TypeGuard',
|
1597
|
+
'StrictTypeGuard',
|
1598
|
+
];
|
1599
|
+
if (specialClasses.some((t) => t === (classType.aliasName || classType.details.name))) {
|
1600
|
+
return true;
|
1601
|
+
}
|
1602
|
+
}
|
1603
|
+
return false;
|
1604
|
+
}
|
1605
|
+
exports.requiresTypeArguments = requiresTypeArguments;
|
1606
|
+
function requiresSpecialization(type, ignorePseudoGeneric = false, ignoreSelf = false, recursionCount = 0) {
|
1607
|
+
var _a;
|
1608
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1609
|
+
return false;
|
1610
|
+
}
|
1611
|
+
recursionCount++;
|
1612
|
+
switch (type.category) {
|
1613
|
+
case 7 /* Class */: {
|
1614
|
+
if (types_1.ClassType.isPseudoGenericClass(type) && ignorePseudoGeneric) {
|
1615
|
+
return false;
|
1616
|
+
}
|
1617
|
+
if (type.typeArguments) {
|
1618
|
+
return (type.typeArguments.find((typeArg) => requiresSpecialization(typeArg, ignorePseudoGeneric, ignoreSelf, recursionCount)) !== undefined);
|
1619
|
+
}
|
1620
|
+
return types_1.ClassType.getTypeParameters(type).length > 0;
|
1621
|
+
}
|
1622
|
+
case 5 /* Function */: {
|
1623
|
+
if (type.details.paramSpec) {
|
1624
|
+
return true;
|
1625
|
+
}
|
1626
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
1627
|
+
if (requiresSpecialization(types_1.FunctionType.getEffectiveParameterType(type, i), ignorePseudoGeneric, ignoreSelf, recursionCount)) {
|
1628
|
+
return true;
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
const declaredReturnType = type.specializedTypes && type.specializedTypes.returnType
|
1632
|
+
? type.specializedTypes.returnType
|
1633
|
+
: type.details.declaredReturnType;
|
1634
|
+
if (declaredReturnType) {
|
1635
|
+
if (requiresSpecialization(declaredReturnType, ignorePseudoGeneric, ignoreSelf, recursionCount)) {
|
1636
|
+
return true;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
else if (type.inferredReturnType) {
|
1640
|
+
if (requiresSpecialization(type.inferredReturnType, ignorePseudoGeneric, ignoreSelf, recursionCount)) {
|
1641
|
+
return true;
|
1642
|
+
}
|
1643
|
+
}
|
1644
|
+
return false;
|
1645
|
+
}
|
1646
|
+
case 6 /* OverloadedFunction */: {
|
1647
|
+
return (type.overloads.find((overload) => requiresSpecialization(overload, ignorePseudoGeneric, ignoreSelf, recursionCount)) !== undefined);
|
1648
|
+
}
|
1649
|
+
case 9 /* Union */: {
|
1650
|
+
return ((0, types_1.findSubtype)(type, (subtype) => requiresSpecialization(subtype, ignorePseudoGeneric, ignoreSelf, recursionCount)) !== undefined);
|
1651
|
+
}
|
1652
|
+
case 10 /* TypeVar */: {
|
1653
|
+
// Most TypeVar types need to be specialized.
|
1654
|
+
if (!type.details.recursiveTypeAliasName) {
|
1655
|
+
if (type.details.isSynthesizedSelf && ignoreSelf) {
|
1656
|
+
return false;
|
1657
|
+
}
|
1658
|
+
return true;
|
1659
|
+
}
|
1660
|
+
// If this is a recursive type alias, it may need to be specialized
|
1661
|
+
// if it has generic type arguments.
|
1662
|
+
if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
|
1663
|
+
return type.typeAliasInfo.typeArguments.some((typeArg) => requiresSpecialization(typeArg, ignorePseudoGeneric, ignoreSelf, recursionCount));
|
1664
|
+
}
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
return false;
|
1668
|
+
}
|
1669
|
+
exports.requiresSpecialization = requiresSpecialization;
|
1670
|
+
// Computes the method resolution ordering for a class whose base classes
|
1671
|
+
// have already been filled in. The algorithm for computing MRO is described
|
1672
|
+
// here: https://www.python.org/download/releases/2.3/mro/. It returns true
|
1673
|
+
// if an MRO was possible, false otherwise.
|
1674
|
+
function computeMroLinearization(classType) {
|
1675
|
+
let isMroFound = true;
|
1676
|
+
// Clear out any existing MRO information.
|
1677
|
+
classType.details.mro = [];
|
1678
|
+
const filteredBaseClasses = classType.details.baseClasses.filter((baseClass, index) => {
|
1679
|
+
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
1680
|
+
// Generic has some special-case logic (see description of __mro_entries__
|
1681
|
+
// in PEP 560) that we need to account for here.
|
1682
|
+
if (types_1.ClassType.isBuiltIn(baseClass, 'Generic')) {
|
1683
|
+
// If the class is a Protocol, the generic is ignored for the purposes
|
1684
|
+
// of computing the MRO.
|
1685
|
+
if (types_1.ClassType.isProtocolClass(classType)) {
|
1686
|
+
return false;
|
1687
|
+
}
|
1688
|
+
// If the class contains any specialized generic classes after
|
1689
|
+
// the Generic base, the Generic base is ignored for purposes
|
1690
|
+
// of computing the MRO.
|
1691
|
+
if (classType.details.baseClasses.some((innerBaseClass, innerIndex) => {
|
1692
|
+
return (innerIndex > index &&
|
1693
|
+
(0, types_1.isInstantiableClass)(innerBaseClass) &&
|
1694
|
+
innerBaseClass.typeArguments &&
|
1695
|
+
innerBaseClass.isTypeArgumentExplicit);
|
1696
|
+
})) {
|
1697
|
+
return false;
|
1698
|
+
}
|
1699
|
+
}
|
1700
|
+
}
|
1701
|
+
return true;
|
1702
|
+
});
|
1703
|
+
// Construct the list of class lists that need to be merged.
|
1704
|
+
const classListsToMerge = [];
|
1705
|
+
filteredBaseClasses.forEach((baseClass, index) => {
|
1706
|
+
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
1707
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(baseClass, /* makeConcrete */ false);
|
1708
|
+
classListsToMerge.push(baseClass.details.mro.map((mroClass) => {
|
1709
|
+
return applySolvedTypeVars(mroClass, typeVarContext);
|
1710
|
+
}));
|
1711
|
+
}
|
1712
|
+
else {
|
1713
|
+
classListsToMerge.push([baseClass]);
|
1714
|
+
}
|
1715
|
+
});
|
1716
|
+
classListsToMerge.push(filteredBaseClasses.map((baseClass) => {
|
1717
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(classType, /* makeConcrete */ false);
|
1718
|
+
return applySolvedTypeVars(baseClass, typeVarContext);
|
1719
|
+
}));
|
1720
|
+
// The first class in the MRO is the class itself.
|
1721
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(classType, /* makeConcrete */ false);
|
1722
|
+
classType.details.mro.push(applySolvedTypeVars(classType, typeVarContext));
|
1723
|
+
// Helper function that returns true if the specified searchClass
|
1724
|
+
// is found in the "tail" (i.e. in elements 1 through n) of any
|
1725
|
+
// of the class lists.
|
1726
|
+
const isInTail = (searchClass, classLists) => {
|
1727
|
+
return classLists.some((classList) => {
|
1728
|
+
return (classList.findIndex((value) => (0, types_1.isInstantiableClass)(value) && types_1.ClassType.isSameGenericClass(value, searchClass)) > 0);
|
1729
|
+
});
|
1730
|
+
};
|
1731
|
+
const filterClass = (classToFilter, classLists) => {
|
1732
|
+
for (let i = 0; i < classLists.length; i++) {
|
1733
|
+
classLists[i] = classLists[i].filter((value) => !(0, types_1.isInstantiableClass)(value) || !types_1.ClassType.isSameGenericClass(value, classToFilter));
|
1734
|
+
}
|
1735
|
+
};
|
1736
|
+
while (true) {
|
1737
|
+
let foundValidHead = false;
|
1738
|
+
let nonEmptyList = undefined;
|
1739
|
+
for (let i = 0; i < classListsToMerge.length; i++) {
|
1740
|
+
const classList = classListsToMerge[i];
|
1741
|
+
if (classList.length > 0) {
|
1742
|
+
if (nonEmptyList === undefined) {
|
1743
|
+
nonEmptyList = classList;
|
1744
|
+
}
|
1745
|
+
if (!(0, types_1.isInstantiableClass)(classList[0])) {
|
1746
|
+
foundValidHead = true;
|
1747
|
+
classType.details.mro.push(classList[0]);
|
1748
|
+
classList.shift();
|
1749
|
+
break;
|
1750
|
+
}
|
1751
|
+
else if (!isInTail(classList[0], classListsToMerge)) {
|
1752
|
+
foundValidHead = true;
|
1753
|
+
classType.details.mro.push(classList[0]);
|
1754
|
+
filterClass(classList[0], classListsToMerge);
|
1755
|
+
break;
|
1756
|
+
}
|
1757
|
+
}
|
1758
|
+
}
|
1759
|
+
// If all lists are empty, we are done.
|
1760
|
+
if (!nonEmptyList) {
|
1761
|
+
break;
|
1762
|
+
}
|
1763
|
+
// We made it all the way through the list of class lists without
|
1764
|
+
// finding a valid head, but there is at least one list that's not
|
1765
|
+
// yet empty. This means there's no valid MRO order.
|
1766
|
+
if (!foundValidHead) {
|
1767
|
+
isMroFound = false;
|
1768
|
+
// Handle the situation by pull the head off the first empty list.
|
1769
|
+
// This allows us to make forward progress.
|
1770
|
+
if (!(0, types_1.isInstantiableClass)(nonEmptyList[0])) {
|
1771
|
+
classType.details.mro.push(nonEmptyList[0]);
|
1772
|
+
nonEmptyList.shift();
|
1773
|
+
}
|
1774
|
+
else {
|
1775
|
+
classType.details.mro.push(nonEmptyList[0]);
|
1776
|
+
filterClass(nonEmptyList[0], classListsToMerge);
|
1777
|
+
}
|
1778
|
+
}
|
1779
|
+
}
|
1780
|
+
return isMroFound;
|
1781
|
+
}
|
1782
|
+
exports.computeMroLinearization = computeMroLinearization;
|
1783
|
+
// Returns zero or more unique module names that point to the place(s)
|
1784
|
+
// where the type is declared. Unions, for example, can result in more
|
1785
|
+
// than one result. Type arguments are not included.
|
1786
|
+
function getDeclaringModulesForType(type) {
|
1787
|
+
const moduleList = [];
|
1788
|
+
addDeclaringModuleNamesForType(type, moduleList);
|
1789
|
+
return moduleList;
|
1790
|
+
}
|
1791
|
+
exports.getDeclaringModulesForType = getDeclaringModulesForType;
|
1792
|
+
function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
|
1793
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1794
|
+
return;
|
1795
|
+
}
|
1796
|
+
recursionCount++;
|
1797
|
+
const addIfUnique = (moduleName) => {
|
1798
|
+
if (moduleName && !moduleList.some((n) => n === moduleName)) {
|
1799
|
+
moduleList.push(moduleName);
|
1800
|
+
}
|
1801
|
+
};
|
1802
|
+
switch (type.category) {
|
1803
|
+
case 7 /* Class */: {
|
1804
|
+
addIfUnique(type.details.moduleName);
|
1805
|
+
break;
|
1806
|
+
}
|
1807
|
+
case 5 /* Function */: {
|
1808
|
+
addIfUnique(type.details.moduleName);
|
1809
|
+
break;
|
1810
|
+
}
|
1811
|
+
case 6 /* OverloadedFunction */: {
|
1812
|
+
type.overloads.forEach((overload) => {
|
1813
|
+
addDeclaringModuleNamesForType(overload, moduleList, recursionCount);
|
1814
|
+
});
|
1815
|
+
break;
|
1816
|
+
}
|
1817
|
+
case 9 /* Union */: {
|
1818
|
+
doForEachSubtype(type, (subtype) => {
|
1819
|
+
addDeclaringModuleNamesForType(subtype, moduleList, recursionCount);
|
1820
|
+
});
|
1821
|
+
break;
|
1822
|
+
}
|
1823
|
+
case 8 /* Module */: {
|
1824
|
+
addIfUnique(type.moduleName);
|
1825
|
+
break;
|
1826
|
+
}
|
1827
|
+
}
|
1828
|
+
}
|
1829
|
+
function convertParamSpecValueToType(paramSpecEntry, omitParamSpec = false) {
|
1830
|
+
let hasParameters = paramSpecEntry.parameters.length > 0;
|
1831
|
+
if (paramSpecEntry.parameters.length === 1) {
|
1832
|
+
// If the ParamSpec has a position-only separator as its only parameter,
|
1833
|
+
// treat it as though there are no parameters.
|
1834
|
+
const onlyParam = paramSpecEntry.parameters[0];
|
1835
|
+
if (onlyParam.category === 0 /* Simple */ && !onlyParam.name) {
|
1836
|
+
hasParameters = false;
|
1837
|
+
}
|
1838
|
+
}
|
1839
|
+
if (hasParameters || !paramSpecEntry.paramSpec || omitParamSpec) {
|
1840
|
+
// Create a function type from the param spec entries.
|
1841
|
+
const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* ParamSpecValue */ | paramSpecEntry.flags);
|
1842
|
+
paramSpecEntry.parameters.forEach((entry) => {
|
1843
|
+
types_1.FunctionType.addParameter(functionType, {
|
1844
|
+
category: entry.category,
|
1845
|
+
name: entry.name,
|
1846
|
+
hasDefault: entry.hasDefault,
|
1847
|
+
isNameSynthesized: entry.isNameSynthesized,
|
1848
|
+
hasDeclaredType: true,
|
1849
|
+
type: entry.type,
|
1850
|
+
});
|
1851
|
+
});
|
1852
|
+
if (!omitParamSpec) {
|
1853
|
+
functionType.details.paramSpec = paramSpecEntry.paramSpec;
|
1854
|
+
}
|
1855
|
+
functionType.details.docString = paramSpecEntry.docString;
|
1856
|
+
return functionType;
|
1857
|
+
}
|
1858
|
+
return paramSpecEntry.paramSpec;
|
1859
|
+
}
|
1860
|
+
exports.convertParamSpecValueToType = convertParamSpecValueToType;
|
1861
|
+
// Recursively walks a type and calls a callback for each TypeVar, allowing
|
1862
|
+
// it to be replaced with something else.
|
1863
|
+
class TypeVarTransformer {
|
1864
|
+
constructor() {
|
1865
|
+
this._isTransformingTypeArg = false;
|
1866
|
+
this._pendingTypeVarTransformations = new Set();
|
1867
|
+
}
|
1868
|
+
apply(type, recursionCount = 0) {
|
1869
|
+
var _a;
|
1870
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1871
|
+
return type;
|
1872
|
+
}
|
1873
|
+
recursionCount++;
|
1874
|
+
type = this._transformGenericTypeAlias(type, recursionCount);
|
1875
|
+
// Shortcut the operation if possible.
|
1876
|
+
if (!requiresSpecialization(type)) {
|
1877
|
+
return type;
|
1878
|
+
}
|
1879
|
+
if ((0, types_1.isAnyOrUnknown)(type)) {
|
1880
|
+
return type;
|
1881
|
+
}
|
1882
|
+
if ((0, types_1.isNoneInstance)(type)) {
|
1883
|
+
return type;
|
1884
|
+
}
|
1885
|
+
if ((0, types_1.isTypeVar)(type)) {
|
1886
|
+
// Handle recursive type aliases specially. In particular,
|
1887
|
+
// we need to specialize type arguments for generic recursive
|
1888
|
+
// type aliases.
|
1889
|
+
if (type.details.recursiveTypeAliasName) {
|
1890
|
+
if (!((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments)) {
|
1891
|
+
return type;
|
1892
|
+
}
|
1893
|
+
let requiresUpdate = false;
|
1894
|
+
const typeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
|
1895
|
+
const replacementType = this.apply(typeArg, recursionCount);
|
1896
|
+
if (replacementType !== typeArg) {
|
1897
|
+
requiresUpdate = true;
|
1898
|
+
}
|
1899
|
+
return replacementType;
|
1900
|
+
});
|
1901
|
+
if (requiresUpdate) {
|
1902
|
+
return types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, typeArgs);
|
1903
|
+
}
|
1904
|
+
return type;
|
1905
|
+
}
|
1906
|
+
let replacementType = type;
|
1907
|
+
// Recursively transform the results, but ensure that we don't replace the
|
1908
|
+
// same type variable recursively by setting it in the
|
1909
|
+
// _pendingTypeVarTransformations set.
|
1910
|
+
const typeVarName = types_1.TypeVarType.getNameWithScope(type);
|
1911
|
+
if (!this._pendingTypeVarTransformations.has(typeVarName)) {
|
1912
|
+
replacementType = this.transformTypeVar(type);
|
1913
|
+
if (!this._isTransformingTypeArg) {
|
1914
|
+
this._pendingTypeVarTransformations.add(typeVarName);
|
1915
|
+
replacementType = this.apply(replacementType, recursionCount);
|
1916
|
+
this._pendingTypeVarTransformations.delete(typeVarName);
|
1917
|
+
}
|
1918
|
+
// If we're transforming a variadic type variable that was in a union,
|
1919
|
+
// expand the union types.
|
1920
|
+
if ((0, types_1.isVariadicTypeVar)(type) && type.isVariadicInUnion) {
|
1921
|
+
replacementType = _expandVariadicUnpackedUnion(replacementType);
|
1922
|
+
}
|
1923
|
+
}
|
1924
|
+
return replacementType;
|
1925
|
+
}
|
1926
|
+
if ((0, types_1.isUnion)(type)) {
|
1927
|
+
const newUnionType = mapSubtypes(type, (subtype) => {
|
1928
|
+
let transformedType = this.apply(subtype, recursionCount);
|
1929
|
+
// If we're transforming a variadic type variable within a union,
|
1930
|
+
// combine the individual types within the variadic type variable.
|
1931
|
+
if ((0, types_1.isVariadicTypeVar)(subtype) && !(0, types_1.isVariadicTypeVar)(transformedType)) {
|
1932
|
+
const subtypesToCombine = [];
|
1933
|
+
doForEachSubtype(transformedType, (transformedSubtype) => {
|
1934
|
+
subtypesToCombine.push(_expandVariadicUnpackedUnion(transformedSubtype));
|
1935
|
+
});
|
1936
|
+
transformedType = (0, types_1.combineTypes)(subtypesToCombine);
|
1937
|
+
}
|
1938
|
+
if (this.transformUnionSubtype) {
|
1939
|
+
return this.transformUnionSubtype(subtype, transformedType);
|
1940
|
+
}
|
1941
|
+
return transformedType;
|
1942
|
+
});
|
1943
|
+
return !(0, types_1.isNever)(newUnionType) ? newUnionType : types_1.UnknownType.create();
|
1944
|
+
}
|
1945
|
+
if ((0, types_1.isClass)(type)) {
|
1946
|
+
return this._transformTypeVarsInClassType(type, recursionCount);
|
1947
|
+
}
|
1948
|
+
if ((0, types_1.isFunction)(type)) {
|
1949
|
+
return this._transformTypeVarsInFunctionType(type, recursionCount);
|
1950
|
+
}
|
1951
|
+
if ((0, types_1.isOverloadedFunction)(type)) {
|
1952
|
+
let requiresUpdate = false;
|
1953
|
+
// Specialize each of the functions in the overload.
|
1954
|
+
const newOverloads = [];
|
1955
|
+
type.overloads.forEach((entry) => {
|
1956
|
+
const replacementType = this._transformTypeVarsInFunctionType(entry, recursionCount);
|
1957
|
+
newOverloads.push(replacementType);
|
1958
|
+
if (replacementType !== entry) {
|
1959
|
+
requiresUpdate = true;
|
1960
|
+
}
|
1961
|
+
});
|
1962
|
+
// Construct a new overload with the specialized function types.
|
1963
|
+
return requiresUpdate ? types_1.OverloadedFunctionType.create(newOverloads) : type;
|
1964
|
+
}
|
1965
|
+
return type;
|
1966
|
+
}
|
1967
|
+
transformTypeVar(typeVar) {
|
1968
|
+
return typeVar;
|
1969
|
+
}
|
1970
|
+
transformVariadicTypeVar(paramSpec) {
|
1971
|
+
return undefined;
|
1972
|
+
}
|
1973
|
+
transformParamSpec(paramSpec) {
|
1974
|
+
return undefined;
|
1975
|
+
}
|
1976
|
+
transformUnionSubtype(preTransform, postTransform) {
|
1977
|
+
return postTransform;
|
1978
|
+
}
|
1979
|
+
_transformGenericTypeAlias(type, recursionCount) {
|
1980
|
+
if (!type.typeAliasInfo || !type.typeAliasInfo.typeParameters || !type.typeAliasInfo.typeArguments) {
|
1981
|
+
return type;
|
1982
|
+
}
|
1983
|
+
let requiresUpdate = false;
|
1984
|
+
const newTypeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
|
1985
|
+
const updatedType = this.apply(typeArg, recursionCount);
|
1986
|
+
if (type !== updatedType) {
|
1987
|
+
requiresUpdate = true;
|
1988
|
+
}
|
1989
|
+
return updatedType;
|
1990
|
+
});
|
1991
|
+
return requiresUpdate
|
1992
|
+
? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, newTypeArgs)
|
1993
|
+
: type;
|
1994
|
+
}
|
1995
|
+
_transformTypeVarsInClassType(classType, recursionCount) {
|
1996
|
+
// Handle the common case where the class has no type parameters.
|
1997
|
+
if (types_1.ClassType.getTypeParameters(classType).length === 0 && !types_1.ClassType.isSpecialBuiltIn(classType)) {
|
1998
|
+
return classType;
|
1999
|
+
}
|
2000
|
+
let newTypeArgs = [];
|
2001
|
+
let newVariadicTypeArgs;
|
2002
|
+
let specializationNeeded = false;
|
2003
|
+
const typeParams = types_1.ClassType.getTypeParameters(classType);
|
2004
|
+
const transformParamSpec = (paramSpec) => {
|
2005
|
+
const paramSpecValue = this.transformParamSpec(paramSpec);
|
2006
|
+
if (paramSpecValue) {
|
2007
|
+
specializationNeeded = true;
|
2008
|
+
return convertParamSpecValueToType(paramSpecValue);
|
2009
|
+
}
|
2010
|
+
else {
|
2011
|
+
return paramSpec;
|
2012
|
+
}
|
2013
|
+
};
|
2014
|
+
const wasTransformingTypeArg = this._isTransformingTypeArg;
|
2015
|
+
this._isTransformingTypeArg = true;
|
2016
|
+
// If type args were previously provided, specialize them.
|
2017
|
+
if (classType.typeArguments) {
|
2018
|
+
newTypeArgs = classType.typeArguments.map((oldTypeArgType) => {
|
2019
|
+
if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.details.isParamSpec) {
|
2020
|
+
return transformParamSpec(oldTypeArgType);
|
2021
|
+
}
|
2022
|
+
let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
|
2023
|
+
if (newTypeArgType !== oldTypeArgType) {
|
2024
|
+
specializationNeeded = true;
|
2025
|
+
// If this was a variadic type variable that was part of a union
|
2026
|
+
// (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
|
2027
|
+
if ((0, types_1.isTypeVar)(oldTypeArgType) &&
|
2028
|
+
(0, types_1.isVariadicTypeVar)(oldTypeArgType) &&
|
2029
|
+
oldTypeArgType.isVariadicInUnion) {
|
2030
|
+
newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
|
2031
|
+
}
|
2032
|
+
}
|
2033
|
+
return newTypeArgType;
|
2034
|
+
});
|
2035
|
+
}
|
2036
|
+
else {
|
2037
|
+
typeParams.forEach((typeParam) => {
|
2038
|
+
let replacementType = typeParam;
|
2039
|
+
if (typeParam.details.isParamSpec) {
|
2040
|
+
replacementType = transformParamSpec(typeParam);
|
2041
|
+
if (replacementType !== typeParam) {
|
2042
|
+
specializationNeeded = true;
|
2043
|
+
}
|
2044
|
+
}
|
2045
|
+
else {
|
2046
|
+
const typeParamName = types_1.TypeVarType.getNameWithScope(typeParam);
|
2047
|
+
if (!this._pendingTypeVarTransformations.has(typeParamName)) {
|
2048
|
+
replacementType = this.transformTypeVar(typeParam);
|
2049
|
+
if (replacementType !== typeParam) {
|
2050
|
+
if (!this._isTransformingTypeArg) {
|
2051
|
+
this._pendingTypeVarTransformations.add(typeParamName);
|
2052
|
+
replacementType = this.apply(replacementType, recursionCount);
|
2053
|
+
this._pendingTypeVarTransformations.delete(typeParamName);
|
2054
|
+
}
|
2055
|
+
specializationNeeded = true;
|
2056
|
+
}
|
2057
|
+
}
|
2058
|
+
}
|
2059
|
+
newTypeArgs.push(replacementType);
|
2060
|
+
});
|
2061
|
+
}
|
2062
|
+
if (types_1.ClassType.isTupleClass(classType)) {
|
2063
|
+
if (classType.tupleTypeArguments) {
|
2064
|
+
newVariadicTypeArgs = [];
|
2065
|
+
classType.tupleTypeArguments.forEach((oldTypeArgType) => {
|
2066
|
+
const newTypeArgType = this.apply(oldTypeArgType.type, recursionCount);
|
2067
|
+
if (newTypeArgType !== oldTypeArgType.type) {
|
2068
|
+
specializationNeeded = true;
|
2069
|
+
}
|
2070
|
+
if ((0, types_1.isVariadicTypeVar)(oldTypeArgType.type) &&
|
2071
|
+
(0, types_1.isClassInstance)(newTypeArgType) &&
|
2072
|
+
isTupleClass(newTypeArgType) &&
|
2073
|
+
newTypeArgType.tupleTypeArguments) {
|
2074
|
+
(0, collectionUtils_1.appendArray)(newVariadicTypeArgs, newTypeArgType.tupleTypeArguments);
|
2075
|
+
}
|
2076
|
+
else {
|
2077
|
+
newVariadicTypeArgs.push({ type: newTypeArgType, isUnbounded: oldTypeArgType.isUnbounded });
|
2078
|
+
}
|
2079
|
+
});
|
2080
|
+
}
|
2081
|
+
else if (typeParams.length > 0) {
|
2082
|
+
newVariadicTypeArgs = this.transformVariadicTypeVar(typeParams[0]);
|
2083
|
+
if (newVariadicTypeArgs) {
|
2084
|
+
specializationNeeded = true;
|
2085
|
+
}
|
2086
|
+
}
|
2087
|
+
}
|
2088
|
+
this._isTransformingTypeArg = wasTransformingTypeArg;
|
2089
|
+
// If specialization wasn't needed, don't allocate a new class.
|
2090
|
+
if (!specializationNeeded) {
|
2091
|
+
return classType;
|
2092
|
+
}
|
2093
|
+
return types_1.ClassType.cloneForSpecialization(classType, newTypeArgs,
|
2094
|
+
/* isTypeArgumentExplicit */ true,
|
2095
|
+
/* includeSubclasses */ undefined, newVariadicTypeArgs);
|
2096
|
+
}
|
2097
|
+
_transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
2098
|
+
let functionType = sourceType;
|
2099
|
+
// Handle functions with a parameter specification in a special manner.
|
2100
|
+
if (functionType.details.paramSpec) {
|
2101
|
+
const paramSpec = this.transformParamSpec(functionType.details.paramSpec);
|
2102
|
+
if (paramSpec) {
|
2103
|
+
functionType = types_1.FunctionType.cloneForParamSpec(functionType, paramSpec);
|
2104
|
+
}
|
2105
|
+
}
|
2106
|
+
const declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionType);
|
2107
|
+
const specializedReturnType = declaredReturnType ? this.apply(declaredReturnType, recursionCount) : undefined;
|
2108
|
+
let typesRequiredSpecialization = declaredReturnType !== specializedReturnType;
|
2109
|
+
const specializedParameters = {
|
2110
|
+
parameterTypes: [],
|
2111
|
+
returnType: specializedReturnType,
|
2112
|
+
};
|
2113
|
+
// Does this function end with *args: P.args, **args: P.kwargs? If so, we'll
|
2114
|
+
// modify the function and replace these parameters with the signature captured
|
2115
|
+
// by the ParamSpec.
|
2116
|
+
if (functionType.details.parameters.length >= 2) {
|
2117
|
+
const argsParam = functionType.details.parameters[functionType.details.parameters.length - 2];
|
2118
|
+
const kwargsParam = functionType.details.parameters[functionType.details.parameters.length - 1];
|
2119
|
+
const argsParamType = types_1.FunctionType.getEffectiveParameterType(functionType, functionType.details.parameters.length - 2);
|
2120
|
+
const kwargsParamType = types_1.FunctionType.getEffectiveParameterType(functionType, functionType.details.parameters.length - 1);
|
2121
|
+
if (argsParam.category === 1 /* VarArgList */ &&
|
2122
|
+
kwargsParam.category === 2 /* VarArgDictionary */ &&
|
2123
|
+
(0, types_1.isParamSpec)(argsParamType) &&
|
2124
|
+
(0, types_1.isParamSpec)(kwargsParamType) &&
|
2125
|
+
(0, types_1.isTypeSame)(argsParamType, kwargsParamType)) {
|
2126
|
+
const paramSpecType = this.transformParamSpec(argsParamType);
|
2127
|
+
if (paramSpecType) {
|
2128
|
+
if (paramSpecType.parameters.length > 0 ||
|
2129
|
+
paramSpecType.paramSpec === undefined ||
|
2130
|
+
!(0, types_1.isTypeSame)(argsParamType, paramSpecType.paramSpec)) {
|
2131
|
+
functionType = types_1.FunctionType.cloneForParamSpecApplication(functionType, paramSpecType);
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
}
|
2135
|
+
}
|
2136
|
+
let variadicParamIndex;
|
2137
|
+
let variadicTypesToUnpack;
|
2138
|
+
const specializedDefaultArgs = [];
|
2139
|
+
for (let i = 0; i < functionType.details.parameters.length; i++) {
|
2140
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(functionType, i);
|
2141
|
+
const specializedType = this.apply(paramType, recursionCount);
|
2142
|
+
specializedParameters.parameterTypes.push(specializedType);
|
2143
|
+
// Do we need to specialize the default argument type for this parameter?
|
2144
|
+
let defaultArgType = types_1.FunctionType.getEffectiveParameterDefaultArgType(functionType, i);
|
2145
|
+
if (defaultArgType) {
|
2146
|
+
const specializedArgType = this.apply(defaultArgType, recursionCount);
|
2147
|
+
if (specializedArgType !== defaultArgType) {
|
2148
|
+
defaultArgType = specializedArgType;
|
2149
|
+
typesRequiredSpecialization = true;
|
2150
|
+
}
|
2151
|
+
}
|
2152
|
+
specializedDefaultArgs.push(defaultArgType);
|
2153
|
+
if (variadicParamIndex === undefined &&
|
2154
|
+
(0, types_1.isVariadicTypeVar)(paramType) &&
|
2155
|
+
functionType.details.parameters[i].category === 1 /* VarArgList */) {
|
2156
|
+
variadicParamIndex = i;
|
2157
|
+
if ((0, types_1.isClassInstance)(specializedType) && isTupleClass(specializedType) && specializedType.isUnpacked) {
|
2158
|
+
variadicTypesToUnpack = specializedType.tupleTypeArguments;
|
2159
|
+
}
|
2160
|
+
}
|
2161
|
+
if (paramType !== specializedType) {
|
2162
|
+
typesRequiredSpecialization = true;
|
2163
|
+
}
|
2164
|
+
}
|
2165
|
+
if (!typesRequiredSpecialization) {
|
2166
|
+
return functionType;
|
2167
|
+
}
|
2168
|
+
let specializedInferredReturnType;
|
2169
|
+
if (functionType.inferredReturnType) {
|
2170
|
+
specializedInferredReturnType = this.apply(functionType.inferredReturnType, recursionCount);
|
2171
|
+
}
|
2172
|
+
if (specializedDefaultArgs.some((t) => t !== undefined)) {
|
2173
|
+
specializedParameters.parameterDefaultArgs = specializedDefaultArgs;
|
2174
|
+
}
|
2175
|
+
// If there was no unpacked variadic type variable, we're done.
|
2176
|
+
if (!variadicTypesToUnpack) {
|
2177
|
+
return types_1.FunctionType.cloneForSpecialization(functionType, specializedParameters, specializedInferredReturnType);
|
2178
|
+
}
|
2179
|
+
// Unpack the tuple and synthesize a new function in the process.
|
2180
|
+
const newFunctionType = types_1.FunctionType.createSynthesizedInstance('');
|
2181
|
+
let insertKeywordOnlySeparator = false;
|
2182
|
+
let swallowPositionOnlySeparator = false;
|
2183
|
+
specializedParameters.parameterTypes.forEach((paramType, index) => {
|
2184
|
+
if (index === variadicParamIndex) {
|
2185
|
+
let sawUnboundedEntry = false;
|
2186
|
+
// Unpack the tuple into individual parameters.
|
2187
|
+
variadicTypesToUnpack.forEach((unpackedType) => {
|
2188
|
+
types_1.FunctionType.addParameter(newFunctionType, {
|
2189
|
+
category: unpackedType.isUnbounded ? 1 /* VarArgList */ : 0 /* Simple */,
|
2190
|
+
name: `__p${newFunctionType.details.parameters.length}`,
|
2191
|
+
isNameSynthesized: true,
|
2192
|
+
type: unpackedType.type,
|
2193
|
+
hasDeclaredType: true,
|
2194
|
+
});
|
2195
|
+
if (unpackedType.isUnbounded) {
|
2196
|
+
sawUnboundedEntry = true;
|
2197
|
+
}
|
2198
|
+
});
|
2199
|
+
if (sawUnboundedEntry) {
|
2200
|
+
swallowPositionOnlySeparator = true;
|
2201
|
+
}
|
2202
|
+
else {
|
2203
|
+
insertKeywordOnlySeparator = true;
|
2204
|
+
}
|
2205
|
+
}
|
2206
|
+
else {
|
2207
|
+
const param = { ...functionType.details.parameters[index] };
|
2208
|
+
if (param.category === 1 /* VarArgList */ && !param.name) {
|
2209
|
+
insertKeywordOnlySeparator = false;
|
2210
|
+
}
|
2211
|
+
else if (param.category === 2 /* VarArgDictionary */) {
|
2212
|
+
insertKeywordOnlySeparator = false;
|
2213
|
+
}
|
2214
|
+
// Insert a keyword-only separator parameter if we previously
|
2215
|
+
// unpacked a variadic TypeVar.
|
2216
|
+
if (param.category === 0 /* Simple */ && param.name && insertKeywordOnlySeparator) {
|
2217
|
+
types_1.FunctionType.addParameter(newFunctionType, {
|
2218
|
+
category: 1 /* VarArgList */,
|
2219
|
+
type: types_1.UnknownType.create(),
|
2220
|
+
});
|
2221
|
+
insertKeywordOnlySeparator = false;
|
2222
|
+
}
|
2223
|
+
param.type = paramType;
|
2224
|
+
if (param.name && param.isNameSynthesized) {
|
2225
|
+
param.name = `__p${newFunctionType.details.parameters.length}`;
|
2226
|
+
}
|
2227
|
+
if (param.category !== 0 /* Simple */ || param.name || !swallowPositionOnlySeparator) {
|
2228
|
+
types_1.FunctionType.addParameter(newFunctionType, param);
|
2229
|
+
}
|
2230
|
+
}
|
2231
|
+
});
|
2232
|
+
newFunctionType.details.declaredReturnType = specializedParameters.returnType;
|
2233
|
+
return newFunctionType;
|
2234
|
+
}
|
2235
|
+
}
|
2236
|
+
// Specializes a (potentially generic) type by substituting
|
2237
|
+
// type variables from a type var map.
|
2238
|
+
class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
2239
|
+
constructor(_typeVarContext, _unknownIfNotFound = false, _useNarrowBoundOnly = false, _eliminateUnsolvedInUnions = false, _typeClassType) {
|
2240
|
+
super();
|
2241
|
+
this._typeVarContext = _typeVarContext;
|
2242
|
+
this._unknownIfNotFound = _unknownIfNotFound;
|
2243
|
+
this._useNarrowBoundOnly = _useNarrowBoundOnly;
|
2244
|
+
this._eliminateUnsolvedInUnions = _eliminateUnsolvedInUnions;
|
2245
|
+
this._typeClassType = _typeClassType;
|
2246
|
+
}
|
2247
|
+
transformTypeVar(typeVar) {
|
2248
|
+
// If the type variable is unrelated to the scopes we're solving,
|
2249
|
+
// don't transform that type variable.
|
2250
|
+
if (typeVar.scopeId && this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
|
2251
|
+
let replacement = this._typeVarContext.getTypeVarType(typeVar, this._useNarrowBoundOnly);
|
2252
|
+
// If there was no narrow bound but there is a wide bound that
|
2253
|
+
// contains literals, we'll use the wide bound even if "useNarrowBoundOnly"
|
2254
|
+
// is specified.
|
2255
|
+
if (!replacement && this._useNarrowBoundOnly) {
|
2256
|
+
const wideType = this._typeVarContext.getTypeVarType(typeVar);
|
2257
|
+
if (wideType) {
|
2258
|
+
if (containsLiteralType(wideType, /* includeTypeArgs */ true)) {
|
2259
|
+
replacement = wideType;
|
2260
|
+
}
|
2261
|
+
}
|
2262
|
+
}
|
2263
|
+
if (replacement) {
|
2264
|
+
if (types_1.TypeBase.isInstantiable(typeVar)) {
|
2265
|
+
if ((0, types_1.isAnyOrUnknown)(replacement) &&
|
2266
|
+
this._typeClassType &&
|
2267
|
+
(0, types_1.isInstantiableClass)(this._typeClassType)) {
|
2268
|
+
replacement = types_1.ClassType.cloneForSpecialization(types_1.ClassType.cloneAsInstance(this._typeClassType), [replacement],
|
2269
|
+
/* isTypeArgumentExplicit */ true);
|
2270
|
+
}
|
2271
|
+
else {
|
2272
|
+
replacement = convertToInstantiable(replacement);
|
2273
|
+
}
|
2274
|
+
}
|
2275
|
+
return replacement;
|
2276
|
+
}
|
2277
|
+
// If this typeVar is in scope for what we're solving but the type
|
2278
|
+
// var map doesn't contain any entry for it, replace with Unknown.
|
2279
|
+
if (this._unknownIfNotFound && !this._typeVarContext.hasSolveForScope(types_1.WildcardTypeVarScopeId)) {
|
2280
|
+
return types_1.UnknownType.create();
|
2281
|
+
}
|
2282
|
+
}
|
2283
|
+
return typeVar;
|
2284
|
+
}
|
2285
|
+
transformUnionSubtype(preTransform, postTransform) {
|
2286
|
+
// If a union contains unsolved TypeVars within scope, eliminate them
|
2287
|
+
// unless this results in an empty union. This elimination is needed
|
2288
|
+
// in cases where TypeVars can go unsolved due to unions in parameter
|
2289
|
+
// annotations, like this:
|
2290
|
+
// def test(x: Union[str, T]) -> Union[str, T]
|
2291
|
+
if (this._eliminateUnsolvedInUnions) {
|
2292
|
+
if ((0, types_1.isTypeVar)(preTransform) &&
|
2293
|
+
preTransform.scopeId !== undefined &&
|
2294
|
+
this._typeVarContext.hasSolveForScope(preTransform.scopeId)) {
|
2295
|
+
// If the TypeVar was not transformed, then it was unsolved,
|
2296
|
+
// and we'll eliminate it.
|
2297
|
+
if (preTransform === postTransform) {
|
2298
|
+
return undefined;
|
2299
|
+
}
|
2300
|
+
// If _unknownIfNotFound is true, the postTransform type will
|
2301
|
+
// be Unknown, which we want to eliminate.
|
2302
|
+
if ((0, types_1.isUnknown)(postTransform) && this._unknownIfNotFound) {
|
2303
|
+
return undefined;
|
2304
|
+
}
|
2305
|
+
}
|
2306
|
+
}
|
2307
|
+
return postTransform;
|
2308
|
+
}
|
2309
|
+
transformVariadicTypeVar(typeVar) {
|
2310
|
+
if (!typeVar.scopeId || !this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
|
2311
|
+
return undefined;
|
2312
|
+
}
|
2313
|
+
return this._typeVarContext.getVariadicTypeVar(typeVar);
|
2314
|
+
}
|
2315
|
+
transformParamSpec(paramSpec) {
|
2316
|
+
if (!paramSpec.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.scopeId)) {
|
2317
|
+
return undefined;
|
2318
|
+
}
|
2319
|
+
const transformedParamSpec = this._typeVarContext.getParamSpec(paramSpec);
|
2320
|
+
if (transformedParamSpec) {
|
2321
|
+
return transformedParamSpec;
|
2322
|
+
}
|
2323
|
+
if (this._unknownIfNotFound && !this._typeVarContext.hasSolveForScope(types_1.WildcardTypeVarScopeId)) {
|
2324
|
+
// Convert to the ParamSpec equivalent of "Unknown".
|
2325
|
+
const paramSpecValue = {
|
2326
|
+
flags: 0 /* None */,
|
2327
|
+
parameters: types_1.FunctionType.getDefaultParameters(/* useUnknown */ true),
|
2328
|
+
typeVarScopeId: undefined,
|
2329
|
+
docString: undefined,
|
2330
|
+
paramSpec: undefined,
|
2331
|
+
};
|
2332
|
+
return paramSpecValue;
|
2333
|
+
}
|
2334
|
+
return undefined;
|
2335
|
+
}
|
2336
|
+
}
|
2337
|
+
class ExpectedConstructorTypeTransformer extends TypeVarTransformer {
|
2338
|
+
constructor(_typeVarContext, _liveTypeVarScopes) {
|
2339
|
+
super();
|
2340
|
+
this._typeVarContext = _typeVarContext;
|
2341
|
+
this._liveTypeVarScopes = _liveTypeVarScopes;
|
2342
|
+
this.dummyScopeId = '__expected_type_scope_id';
|
2343
|
+
this.dummyTypeVarPrefix = '__expected_type_';
|
2344
|
+
this._typeVarContext.addSolveForScope(this.dummyScopeId);
|
2345
|
+
}
|
2346
|
+
_isTypeVarLive(typeVar) {
|
2347
|
+
return this._liveTypeVarScopes.some((scopeId) => typeVar.scopeId === scopeId);
|
2348
|
+
}
|
2349
|
+
_createDummyTypeVar(prevTypeVar) {
|
2350
|
+
// If we previously synthesized this dummy type var, just return it.
|
2351
|
+
if (prevTypeVar.details.isSynthesized && prevTypeVar.details.name.startsWith(this.dummyTypeVarPrefix)) {
|
2352
|
+
return prevTypeVar;
|
2353
|
+
}
|
2354
|
+
const isInstance = types_1.TypeBase.isInstance(prevTypeVar);
|
2355
|
+
let newTypeVar = types_1.TypeVarType.createInstance(`__expected_type_${ExpectedConstructorTypeTransformer.synthesizedTypeVarIndexForExpectedType}`);
|
2356
|
+
newTypeVar.details.isSynthesized = true;
|
2357
|
+
newTypeVar.scopeId = this.dummyScopeId;
|
2358
|
+
newTypeVar.nameWithScope = types_1.TypeVarType.makeNameWithScope(newTypeVar.details.name, this.dummyScopeId);
|
2359
|
+
if (!isInstance) {
|
2360
|
+
newTypeVar = convertToInstantiable(newTypeVar);
|
2361
|
+
}
|
2362
|
+
// If the original TypeVar was bound or constrained, make the replacement as well.
|
2363
|
+
newTypeVar.details.boundType = prevTypeVar.details.boundType;
|
2364
|
+
newTypeVar.details.constraints = prevTypeVar.details.constraints;
|
2365
|
+
// Also copy the variance.
|
2366
|
+
newTypeVar.details.variance = prevTypeVar.details.variance;
|
2367
|
+
ExpectedConstructorTypeTransformer.synthesizedTypeVarIndexForExpectedType++;
|
2368
|
+
return newTypeVar;
|
2369
|
+
}
|
2370
|
+
transformTypeVar(typeVar) {
|
2371
|
+
// If the type variable is unrelated to the scopes we're solving,
|
2372
|
+
// don't transform that type variable.
|
2373
|
+
if (this._isTypeVarLive(typeVar)) {
|
2374
|
+
return typeVar;
|
2375
|
+
}
|
2376
|
+
return this._createDummyTypeVar(typeVar);
|
2377
|
+
}
|
2378
|
+
}
|
2379
|
+
ExpectedConstructorTypeTransformer.synthesizedTypeVarIndexForExpectedType = 1;
|
2380
|
+
//# sourceMappingURL=typeUtils.js.map
|