@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,1293 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
* typeGuards.ts
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
5
|
+
* Licensed under the MIT license.
|
6
|
+
* Author: Eric Traut
|
7
|
+
*
|
8
|
+
* Provides logic for narrowing types based on conditional
|
9
|
+
* expressions. The logic handles both positive ("if") and
|
10
|
+
* negative ("else") narrowing cases.
|
11
|
+
*/
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
13
|
+
if (k2 === undefined) k2 = k;
|
14
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
15
|
+
}) : (function(o, m, k, k2) {
|
16
|
+
if (k2 === undefined) k2 = k;
|
17
|
+
o[k2] = m[k];
|
18
|
+
}));
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
21
|
+
}) : function(o, v) {
|
22
|
+
o["default"] = v;
|
23
|
+
});
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
25
|
+
if (mod && mod.__esModule) return mod;
|
26
|
+
var result = {};
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
28
|
+
__setModuleDefault(result, mod);
|
29
|
+
return result;
|
30
|
+
};
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
32
|
+
exports.enumerateLiteralsForType = exports.getTypeNarrowingCallback = void 0;
|
33
|
+
const parseNodes_1 = require("../parser/parseNodes");
|
34
|
+
const analyzerNodeInfo_1 = require("./analyzerNodeInfo");
|
35
|
+
const constraintSolver_1 = require("./constraintSolver");
|
36
|
+
const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
|
37
|
+
const scopeUtils_1 = require("./scopeUtils");
|
38
|
+
const symbol_1 = require("./symbol");
|
39
|
+
const typedDicts_1 = require("./typedDicts");
|
40
|
+
const types_1 = require("./types");
|
41
|
+
const typeUtils_1 = require("./typeUtils");
|
42
|
+
const typeVarContext_1 = require("./typeVarContext");
|
43
|
+
// Given a reference expression and a test expression, returns a callback that
|
44
|
+
// can be used to narrow the type described by the reference expression.
|
45
|
+
// If the specified flow node is not associated with the test expression,
|
46
|
+
// it returns undefined.
|
47
|
+
function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositiveTest, recursionCount = 0) {
|
48
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
49
|
+
return undefined;
|
50
|
+
}
|
51
|
+
recursionCount++;
|
52
|
+
if (testExpression.nodeType === 4 /* AssignmentExpression */) {
|
53
|
+
return getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, recursionCount);
|
54
|
+
}
|
55
|
+
if (testExpression.nodeType === 7 /* BinaryOperation */) {
|
56
|
+
const isOrIsNotOperator = testExpression.operator === 39 /* Is */ || testExpression.operator === 40 /* IsNot */;
|
57
|
+
const equalsOrNotEqualsOperator = testExpression.operator === 12 /* Equals */ || testExpression.operator === 28 /* NotEquals */;
|
58
|
+
if (isOrIsNotOperator || equalsOrNotEqualsOperator) {
|
59
|
+
// Invert the "isPositiveTest" value if this is an "is not" operation.
|
60
|
+
const adjIsPositiveTest = testExpression.operator === 39 /* Is */ || testExpression.operator === 12 /* Equals */
|
61
|
+
? isPositiveTest
|
62
|
+
: !isPositiveTest;
|
63
|
+
// Look for "X is None", "X is not None", "X == None", and "X != None".
|
64
|
+
// These are commonly-used patterns used in control flow.
|
65
|
+
if (testExpression.rightExpression.nodeType === 11 /* Constant */ &&
|
66
|
+
testExpression.rightExpression.constType === 26 /* None */) {
|
67
|
+
// Allow the LHS to be either a simple expression or an assignment
|
68
|
+
// expression that assigns to a simple name.
|
69
|
+
let leftExpression = testExpression.leftExpression;
|
70
|
+
if (leftExpression.nodeType === 4 /* AssignmentExpression */) {
|
71
|
+
leftExpression = leftExpression.name;
|
72
|
+
}
|
73
|
+
if (ParseTreeUtils.isMatchingExpression(reference, leftExpression)) {
|
74
|
+
return (type) => {
|
75
|
+
return narrowTypeForIsNone(evaluator, type, adjIsPositiveTest);
|
76
|
+
};
|
77
|
+
}
|
78
|
+
if (leftExpression.nodeType === 24 /* Index */ &&
|
79
|
+
ParseTreeUtils.isMatchingExpression(reference, leftExpression.baseExpression) &&
|
80
|
+
leftExpression.items.length === 1 &&
|
81
|
+
!leftExpression.trailingComma &&
|
82
|
+
leftExpression.items[0].argumentCategory === 0 /* Simple */ &&
|
83
|
+
!leftExpression.items[0].name &&
|
84
|
+
leftExpression.items[0].valueExpression.nodeType === 40 /* Number */ &&
|
85
|
+
leftExpression.items[0].valueExpression.isInteger &&
|
86
|
+
!leftExpression.items[0].valueExpression.isImaginary) {
|
87
|
+
const indexValue = leftExpression.items[0].valueExpression.value;
|
88
|
+
if (typeof indexValue === 'number') {
|
89
|
+
return (type) => {
|
90
|
+
return narrowTupleTypeForIsNone(evaluator, type, adjIsPositiveTest, indexValue);
|
91
|
+
};
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
// Look for "type(X) is Y" or "type(X) is not Y".
|
96
|
+
if (isOrIsNotOperator && testExpression.leftExpression.nodeType === 9 /* Call */) {
|
97
|
+
const callType = evaluator.getTypeOfExpression(testExpression.leftExpression.leftExpression, 2 /* DoNotSpecialize */).type;
|
98
|
+
if ((0, types_1.isInstantiableClass)(callType) &&
|
99
|
+
types_1.ClassType.isBuiltIn(callType, 'type') &&
|
100
|
+
testExpression.leftExpression.arguments.length === 1 &&
|
101
|
+
testExpression.leftExpression.arguments[0].argumentCategory === 0 /* Simple */) {
|
102
|
+
const arg0Expr = testExpression.leftExpression.arguments[0].valueExpression;
|
103
|
+
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
104
|
+
const classType = evaluator.makeTopLevelTypeVarsConcrete(evaluator.getTypeOfExpression(testExpression.rightExpression).type);
|
105
|
+
if ((0, types_1.isInstantiableClass)(classType)) {
|
106
|
+
return (type) => {
|
107
|
+
return narrowTypeForTypeIs(type, classType, adjIsPositiveTest);
|
108
|
+
};
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
// Look for "X is Y" or "X is not Y" where Y is a an enum or bool literal.
|
114
|
+
if (isOrIsNotOperator) {
|
115
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression)) {
|
116
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
117
|
+
if ((0, types_1.isClassInstance)(rightType) &&
|
118
|
+
(types_1.ClassType.isEnumClass(rightType) || types_1.ClassType.isBuiltIn(rightType, 'bool')) &&
|
119
|
+
rightType.literalValue !== undefined) {
|
120
|
+
return (type) => {
|
121
|
+
return narrowTypeForLiteralComparison(evaluator, type, rightType, adjIsPositiveTest,
|
122
|
+
/* isIsOperator */ true);
|
123
|
+
};
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
if (equalsOrNotEqualsOperator) {
|
128
|
+
// Look for X == <literal> or X != <literal>
|
129
|
+
const adjIsPositiveTest = testExpression.operator === 12 /* Equals */ ? isPositiveTest : !isPositiveTest;
|
130
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression)) {
|
131
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
132
|
+
if ((0, types_1.isClassInstance)(rightType) && rightType.literalValue !== undefined) {
|
133
|
+
return (type) => {
|
134
|
+
return narrowTypeForLiteralComparison(evaluator, type, rightType, adjIsPositiveTest,
|
135
|
+
/* isIsOperator */ false);
|
136
|
+
};
|
137
|
+
}
|
138
|
+
}
|
139
|
+
// Look for <literal> == X or <literal> != X
|
140
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.rightExpression)) {
|
141
|
+
const leftType = evaluator.getTypeOfExpression(testExpression.leftExpression).type;
|
142
|
+
if ((0, types_1.isClassInstance)(leftType) && leftType.literalValue !== undefined) {
|
143
|
+
return (type) => {
|
144
|
+
return narrowTypeForLiteralComparison(evaluator, type, leftType, adjIsPositiveTest,
|
145
|
+
/* isIsOperator */ false);
|
146
|
+
};
|
147
|
+
}
|
148
|
+
}
|
149
|
+
// Look for X[<literal>] == <literal> or X[<literal>] != <literal>
|
150
|
+
if (testExpression.leftExpression.nodeType === 24 /* Index */ &&
|
151
|
+
testExpression.leftExpression.items.length === 1 &&
|
152
|
+
!testExpression.leftExpression.trailingComma &&
|
153
|
+
testExpression.leftExpression.items[0].argumentCategory === 0 /* Simple */ &&
|
154
|
+
ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.baseExpression)) {
|
155
|
+
const indexType = evaluator.getTypeOfExpression(testExpression.leftExpression.items[0].valueExpression).type;
|
156
|
+
if ((0, types_1.isClassInstance)(indexType) && (0, typeUtils_1.isLiteralType)(indexType)) {
|
157
|
+
if (types_1.ClassType.isBuiltIn(indexType, 'str')) {
|
158
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
159
|
+
if ((0, types_1.isClassInstance)(rightType) && rightType.literalValue !== undefined) {
|
160
|
+
return (type) => {
|
161
|
+
return narrowTypeForDiscriminatedDictEntryComparison(evaluator, type, indexType, rightType, adjIsPositiveTest);
|
162
|
+
};
|
163
|
+
}
|
164
|
+
}
|
165
|
+
else if (types_1.ClassType.isBuiltIn(indexType, 'int')) {
|
166
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
167
|
+
if ((0, types_1.isClassInstance)(rightType) && rightType.literalValue !== undefined) {
|
168
|
+
return (type) => {
|
169
|
+
return narrowTypeForDiscriminatedTupleComparison(evaluator, type, indexType, rightType, adjIsPositiveTest);
|
170
|
+
};
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
// Look for len(x) == <literal> or len(x) != <literal>
|
177
|
+
if (equalsOrNotEqualsOperator &&
|
178
|
+
testExpression.leftExpression.nodeType === 9 /* Call */ &&
|
179
|
+
testExpression.leftExpression.arguments.length === 1 &&
|
180
|
+
testExpression.rightExpression.nodeType === 40 /* Number */ &&
|
181
|
+
testExpression.rightExpression.isInteger) {
|
182
|
+
const arg0Expr = testExpression.leftExpression.arguments[0].valueExpression;
|
183
|
+
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
184
|
+
const callType = evaluator.getTypeOfExpression(testExpression.leftExpression.leftExpression, 2 /* DoNotSpecialize */).type;
|
185
|
+
if ((0, types_1.isFunction)(callType) && callType.details.fullName === 'builtins.len') {
|
186
|
+
const tupleLength = testExpression.rightExpression.value;
|
187
|
+
if (typeof tupleLength === 'number') {
|
188
|
+
return (type) => {
|
189
|
+
return narrowTypeForTupleLength(evaluator, type, tupleLength, adjIsPositiveTest);
|
190
|
+
};
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
// Look for X.Y == <literal> or X.Y != <literal>
|
196
|
+
if (equalsOrNotEqualsOperator &&
|
197
|
+
testExpression.leftExpression.nodeType === 35 /* MemberAccess */ &&
|
198
|
+
ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.leftExpression)) {
|
199
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
200
|
+
const memberName = testExpression.leftExpression.memberName;
|
201
|
+
if ((0, types_1.isClassInstance)(rightType) && rightType.literalValue !== undefined) {
|
202
|
+
return (type) => {
|
203
|
+
return narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, type, memberName.value, rightType, adjIsPositiveTest);
|
204
|
+
};
|
205
|
+
}
|
206
|
+
}
|
207
|
+
// Look for X.Y is <literal> or X.Y is not <literal> where <literal> is
|
208
|
+
// an enum or bool literal
|
209
|
+
if (testExpression.leftExpression.nodeType === 35 /* MemberAccess */ &&
|
210
|
+
ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.leftExpression)) {
|
211
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
212
|
+
const memberName = testExpression.leftExpression.memberName;
|
213
|
+
if ((0, types_1.isClassInstance)(rightType) &&
|
214
|
+
(types_1.ClassType.isEnumClass(rightType) || types_1.ClassType.isBuiltIn(rightType, 'bool')) &&
|
215
|
+
rightType.literalValue !== undefined) {
|
216
|
+
return (type) => {
|
217
|
+
return narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, type, memberName.value, rightType, adjIsPositiveTest);
|
218
|
+
};
|
219
|
+
}
|
220
|
+
}
|
221
|
+
// Look for X.Y is None or X.Y is not None
|
222
|
+
// These are commonly-used patterns used in control flow.
|
223
|
+
if (testExpression.leftExpression.nodeType === 35 /* MemberAccess */ &&
|
224
|
+
ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.leftExpression) &&
|
225
|
+
testExpression.rightExpression.nodeType === 11 /* Constant */ &&
|
226
|
+
testExpression.rightExpression.constType === 26 /* None */) {
|
227
|
+
const memberName = testExpression.leftExpression.memberName;
|
228
|
+
return (type) => {
|
229
|
+
return narrowTypeForDiscriminatedFieldNoneComparison(evaluator, type, memberName.value, adjIsPositiveTest);
|
230
|
+
};
|
231
|
+
}
|
232
|
+
}
|
233
|
+
if (testExpression.operator === 41 /* In */ || testExpression.operator === 42 /* NotIn */) {
|
234
|
+
// Look for "x in y" or "x not in y" where y is one of several built-in types.
|
235
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression)) {
|
236
|
+
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
237
|
+
const adjIsPositiveTest = testExpression.operator === 41 /* In */ ? isPositiveTest : !isPositiveTest;
|
238
|
+
if (adjIsPositiveTest) {
|
239
|
+
return (type) => {
|
240
|
+
return narrowTypeForContains(evaluator, type, rightType);
|
241
|
+
};
|
242
|
+
}
|
243
|
+
}
|
244
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.rightExpression)) {
|
245
|
+
// Look for <string literal> in y where y is a union that contains
|
246
|
+
// one or more TypedDicts.
|
247
|
+
const leftType = evaluator.getTypeOfExpression(testExpression.leftExpression).type;
|
248
|
+
if ((0, types_1.isClassInstance)(leftType) && types_1.ClassType.isBuiltIn(leftType, 'str') && (0, typeUtils_1.isLiteralType)(leftType)) {
|
249
|
+
const adjIsPositiveTest = testExpression.operator === 41 /* In */ ? isPositiveTest : !isPositiveTest;
|
250
|
+
return (type) => {
|
251
|
+
return narrowTypeForTypedDictKey(evaluator, type, types_1.ClassType.cloneAsInstantiable(leftType), adjIsPositiveTest);
|
252
|
+
};
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
if (testExpression.nodeType === 9 /* Call */) {
|
258
|
+
const callType = evaluator.getTypeOfExpression(testExpression.leftExpression, 2 /* DoNotSpecialize */).type;
|
259
|
+
// Look for "isinstance(X, Y)" or "issubclass(X, Y)".
|
260
|
+
if ((0, types_1.isFunction)(callType) &&
|
261
|
+
(callType.details.builtInName === 'isinstance' || callType.details.builtInName === 'issubclass') &&
|
262
|
+
testExpression.arguments.length === 2) {
|
263
|
+
// Make sure the first parameter is a supported expression type
|
264
|
+
// and the second parameter is a valid class type or a tuple
|
265
|
+
// of valid class types.
|
266
|
+
const isInstanceCheck = callType.details.builtInName === 'isinstance';
|
267
|
+
const arg0Expr = testExpression.arguments[0].valueExpression;
|
268
|
+
const arg1Expr = testExpression.arguments[1].valueExpression;
|
269
|
+
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
270
|
+
const arg1Type = evaluator.getTypeOfExpression(arg1Expr, 8 /* EvaluateStringLiteralAsType */ |
|
271
|
+
32 /* ParamSpecDisallowed */ |
|
272
|
+
128 /* TypeVarTupleDisallowed */).type;
|
273
|
+
const classTypeList = getIsInstanceClassTypes(arg1Type);
|
274
|
+
if (classTypeList) {
|
275
|
+
return (type) => {
|
276
|
+
const narrowedType = narrowTypeForIsInstance(evaluator, type, classTypeList, isInstanceCheck, isPositiveTest,
|
277
|
+
/* allowIntersections */ false, testExpression);
|
278
|
+
if (!(0, types_1.isNever)(narrowedType)) {
|
279
|
+
return narrowedType;
|
280
|
+
}
|
281
|
+
// Try again with intersection types allowed.
|
282
|
+
return narrowTypeForIsInstance(evaluator, type, classTypeList, isInstanceCheck, isPositiveTest,
|
283
|
+
/* allowIntersections */ true, testExpression);
|
284
|
+
};
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
// Look for "callable(X)"
|
289
|
+
if ((0, types_1.isFunction)(callType) &&
|
290
|
+
callType.details.builtInName === 'callable' &&
|
291
|
+
testExpression.arguments.length === 1) {
|
292
|
+
const arg0Expr = testExpression.arguments[0].valueExpression;
|
293
|
+
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
294
|
+
return (type) => {
|
295
|
+
let narrowedType = narrowTypeForCallable(evaluator, type, isPositiveTest, testExpression,
|
296
|
+
/* allowIntersections */ false);
|
297
|
+
if (isPositiveTest && (0, types_1.isNever)(narrowedType)) {
|
298
|
+
// Try again with intersections allowed.
|
299
|
+
narrowedType = narrowTypeForCallable(evaluator, type, isPositiveTest, testExpression,
|
300
|
+
/* allowIntersections */ true);
|
301
|
+
}
|
302
|
+
return narrowedType;
|
303
|
+
};
|
304
|
+
}
|
305
|
+
}
|
306
|
+
// Look for "bool(X)"
|
307
|
+
if ((0, types_1.isInstantiableClass)(callType) &&
|
308
|
+
types_1.ClassType.isBuiltIn(callType, 'bool') &&
|
309
|
+
testExpression.arguments.length === 1 &&
|
310
|
+
!testExpression.arguments[0].name) {
|
311
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.arguments[0].valueExpression)) {
|
312
|
+
return (type) => {
|
313
|
+
return narrowTypeForTruthiness(evaluator, type, isPositiveTest);
|
314
|
+
};
|
315
|
+
}
|
316
|
+
}
|
317
|
+
// Look for a TypeGuard function.
|
318
|
+
if (testExpression.arguments.length >= 1) {
|
319
|
+
const arg0Expr = testExpression.arguments[0].valueExpression;
|
320
|
+
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
321
|
+
// Does this look like it's a custom type guard function?
|
322
|
+
if ((0, types_1.isFunction)(callType) &&
|
323
|
+
callType.details.declaredReturnType &&
|
324
|
+
(0, types_1.isClassInstance)(callType.details.declaredReturnType) &&
|
325
|
+
types_1.ClassType.isBuiltIn(callType.details.declaredReturnType, ['TypeGuard', 'StrictTypeGuard'])) {
|
326
|
+
// Evaluate the type guard call expression.
|
327
|
+
const functionReturnType = evaluator.getTypeOfExpression(testExpression).type;
|
328
|
+
if ((0, types_1.isClassInstance)(functionReturnType) &&
|
329
|
+
types_1.ClassType.isBuiltIn(functionReturnType, 'bool') &&
|
330
|
+
functionReturnType.typeGuardType) {
|
331
|
+
const isStrictTypeGuard = types_1.ClassType.isBuiltIn(callType.details.declaredReturnType, 'StrictTypeGuard');
|
332
|
+
const typeGuardType = functionReturnType.typeGuardType;
|
333
|
+
return (type) => {
|
334
|
+
return narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard);
|
335
|
+
};
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
if (ParseTreeUtils.isMatchingExpression(reference, testExpression)) {
|
342
|
+
return (type) => {
|
343
|
+
return narrowTypeForTruthiness(evaluator, type, isPositiveTest);
|
344
|
+
};
|
345
|
+
}
|
346
|
+
// Is this a reference to an aliased conditional expression (a local variable
|
347
|
+
// that was assigned a value that can inform type narrowing of the reference expression)?
|
348
|
+
const narrowingCallback = getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, recursionCount);
|
349
|
+
if (narrowingCallback) {
|
350
|
+
return narrowingCallback;
|
351
|
+
}
|
352
|
+
// We normally won't find a "not" operator here because they are stripped out
|
353
|
+
// by the binder when it creates condition flow nodes, but we can find this
|
354
|
+
// in the case of local variables type narrowing.
|
355
|
+
if (reference.nodeType === 38 /* Name */) {
|
356
|
+
if (testExpression.nodeType === 55 /* UnaryOperation */ && testExpression.operator === 38 /* Not */) {
|
357
|
+
return getTypeNarrowingCallback(evaluator, reference, testExpression.expression, !isPositiveTest, recursionCount);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
return undefined;
|
361
|
+
}
|
362
|
+
exports.getTypeNarrowingCallback = getTypeNarrowingCallback;
|
363
|
+
function getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, recursionCount) {
|
364
|
+
if (testExpression.nodeType !== 38 /* Name */ ||
|
365
|
+
reference.nodeType !== 38 /* Name */ ||
|
366
|
+
testExpression === reference) {
|
367
|
+
return undefined;
|
368
|
+
}
|
369
|
+
// Make sure the reference expression is a constant parameter or variable.
|
370
|
+
// If the reference expression is modified within the scope multiple times,
|
371
|
+
// we need to validate that it is not modified between the test expression
|
372
|
+
// evaluation and the conditional check.
|
373
|
+
const testExprDecl = getDeclsForLocalVar(evaluator, testExpression, testExpression);
|
374
|
+
if (!testExprDecl || testExprDecl.length !== 1 || testExprDecl[0].type !== 1 /* Variable */) {
|
375
|
+
return undefined;
|
376
|
+
}
|
377
|
+
const referenceDecls = getDeclsForLocalVar(evaluator, reference, testExpression);
|
378
|
+
if (!referenceDecls) {
|
379
|
+
return undefined;
|
380
|
+
}
|
381
|
+
let modifyingDecls = [];
|
382
|
+
if (referenceDecls.length > 1) {
|
383
|
+
// If there is more than one assignment to the reference variable within
|
384
|
+
// the local scope, make sure that none of these assignments are done
|
385
|
+
// after the test expression but before the condition check.
|
386
|
+
//
|
387
|
+
// This is OK:
|
388
|
+
// val = None
|
389
|
+
// is_none = val is None
|
390
|
+
// if is_none: ...
|
391
|
+
//
|
392
|
+
// This is not OK:
|
393
|
+
// val = None
|
394
|
+
// is_none = val is None
|
395
|
+
// val = 1
|
396
|
+
// if is_none: ...
|
397
|
+
modifyingDecls = referenceDecls.filter((decl) => {
|
398
|
+
return (evaluator.isNodeReachable(testExpression, decl.node) &&
|
399
|
+
evaluator.isNodeReachable(decl.node, testExprDecl[0].node));
|
400
|
+
});
|
401
|
+
}
|
402
|
+
if (modifyingDecls.length !== 0) {
|
403
|
+
return undefined;
|
404
|
+
}
|
405
|
+
const initNode = testExprDecl[0].inferredTypeSource;
|
406
|
+
if (!initNode || ParseTreeUtils.isNodeContainedWithin(testExpression, initNode) || !(0, parseNodes_1.isExpressionNode)(initNode)) {
|
407
|
+
return undefined;
|
408
|
+
}
|
409
|
+
return getTypeNarrowingCallback(evaluator, reference, initNode, isPositiveTest, recursionCount);
|
410
|
+
}
|
411
|
+
// Determines whether the symbol is a local variable or parameter within
|
412
|
+
// the current scope.
|
413
|
+
function getDeclsForLocalVar(evaluator, name, reachableFrom) {
|
414
|
+
const scope = (0, scopeUtils_1.getScopeForNode)(name);
|
415
|
+
if ((scope === null || scope === void 0 ? void 0 : scope.type) !== 1 /* Function */ && (scope === null || scope === void 0 ? void 0 : scope.type) !== 3 /* Module */) {
|
416
|
+
return undefined;
|
417
|
+
}
|
418
|
+
const symbol = scope.lookUpSymbol(name.value);
|
419
|
+
if (!symbol) {
|
420
|
+
return undefined;
|
421
|
+
}
|
422
|
+
const decls = symbol.getDeclarations();
|
423
|
+
if (decls.length === 0 ||
|
424
|
+
decls.some((decl) => decl.type !== 1 /* Variable */ && decl.type !== 2 /* Parameter */)) {
|
425
|
+
return undefined;
|
426
|
+
}
|
427
|
+
// If there are any assignments within different scopes (e.g. via a "global" or
|
428
|
+
// "nonlocal" reference), don't consider it a local variable.
|
429
|
+
let prevDeclScope;
|
430
|
+
if (decls.some((decl) => {
|
431
|
+
const nodeToConsider = decl.type === 2 /* Parameter */ ? decl.node.name : decl.node;
|
432
|
+
const declScopeNode = ParseTreeUtils.getExecutionScopeNode(nodeToConsider);
|
433
|
+
if (prevDeclScope && declScopeNode !== prevDeclScope) {
|
434
|
+
return true;
|
435
|
+
}
|
436
|
+
prevDeclScope = declScopeNode;
|
437
|
+
return false;
|
438
|
+
})) {
|
439
|
+
return undefined;
|
440
|
+
}
|
441
|
+
const reachableDecls = decls.filter((decl) => evaluator.isNodeReachable(reachableFrom, decl.node));
|
442
|
+
return reachableDecls.length > 0 ? reachableDecls : undefined;
|
443
|
+
}
|
444
|
+
function getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, recursionCount) {
|
445
|
+
var _a;
|
446
|
+
return ((_a = getTypeNarrowingCallback(evaluator, reference, testExpression.rightExpression, isPositiveTest, recursionCount)) !== null && _a !== void 0 ? _a : getTypeNarrowingCallback(evaluator, reference, testExpression.name, isPositiveTest, recursionCount));
|
447
|
+
}
|
448
|
+
function narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard) {
|
449
|
+
// For non-strict type guards, always narrow to the typeGuardType
|
450
|
+
// in the positive case and don't narrow in the negative case.
|
451
|
+
if (!isStrictTypeGuard) {
|
452
|
+
return isPositiveTest ? typeGuardType : type;
|
453
|
+
}
|
454
|
+
// For strict type guards, narrow the current type.
|
455
|
+
return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
456
|
+
return (0, typeUtils_1.mapSubtypes)(typeGuardType, (typeGuardSubtype) => {
|
457
|
+
const isSubType = evaluator.assignType(typeGuardType, subtype);
|
458
|
+
const isSuperType = evaluator.assignType(subtype, typeGuardSubtype);
|
459
|
+
if (isPositiveTest) {
|
460
|
+
if (isSubType) {
|
461
|
+
return subtype;
|
462
|
+
}
|
463
|
+
else if (isSuperType) {
|
464
|
+
return typeGuardSubtype;
|
465
|
+
}
|
466
|
+
}
|
467
|
+
else {
|
468
|
+
if (!isSubType && !isSubType) {
|
469
|
+
return subtype;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
return undefined;
|
473
|
+
});
|
474
|
+
});
|
475
|
+
}
|
476
|
+
// Narrow the type based on whether the subtype can be true or false.
|
477
|
+
function narrowTypeForTruthiness(evaluator, type, isPositiveTest) {
|
478
|
+
return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
479
|
+
if (isPositiveTest) {
|
480
|
+
if (evaluator.canBeTruthy(subtype)) {
|
481
|
+
return evaluator.removeFalsinessFromType(subtype);
|
482
|
+
}
|
483
|
+
}
|
484
|
+
else {
|
485
|
+
if (evaluator.canBeFalsy(subtype)) {
|
486
|
+
return evaluator.removeTruthinessFromType(subtype);
|
487
|
+
}
|
488
|
+
}
|
489
|
+
return undefined;
|
490
|
+
});
|
491
|
+
}
|
492
|
+
// Handle type narrowing for expressions of the form "a[I] is None" and "a[I] is not None" where
|
493
|
+
// I is an integer and a is a union of Tuples (or subtypes thereof) with known lengths and entry types.
|
494
|
+
function narrowTupleTypeForIsNone(evaluator, type, isPositiveTest, indexValue) {
|
495
|
+
return evaluator.mapSubtypesExpandTypeVars(type, /* conditionFilter */ undefined, (subtype) => {
|
496
|
+
const tupleType = (0, typeUtils_1.getSpecializedTupleType)(subtype);
|
497
|
+
if (!tupleType || (0, typeUtils_1.isUnboundedTupleClass)(tupleType) || !tupleType.tupleTypeArguments) {
|
498
|
+
return subtype;
|
499
|
+
}
|
500
|
+
const tupleLength = tupleType.tupleTypeArguments.length;
|
501
|
+
if (indexValue < 0 || indexValue >= tupleLength) {
|
502
|
+
return subtype;
|
503
|
+
}
|
504
|
+
const typeOfEntry = evaluator.makeTopLevelTypeVarsConcrete(tupleType.tupleTypeArguments[indexValue].type);
|
505
|
+
if (isPositiveTest) {
|
506
|
+
if (!evaluator.assignType(typeOfEntry, types_1.NoneType.createInstance())) {
|
507
|
+
return undefined;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
else {
|
511
|
+
if ((0, types_1.isNoneInstance)(typeOfEntry)) {
|
512
|
+
return undefined;
|
513
|
+
}
|
514
|
+
}
|
515
|
+
return subtype;
|
516
|
+
});
|
517
|
+
}
|
518
|
+
// Handle type narrowing for expressions of the form "x is None" and "x is not None".
|
519
|
+
function narrowTypeForIsNone(evaluator, type, isPositiveTest) {
|
520
|
+
const expandedType = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
521
|
+
return (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(subtype);
|
522
|
+
});
|
523
|
+
return evaluator.mapSubtypesExpandTypeVars(expandedType,
|
524
|
+
/* conditionFilter */ undefined, (subtype, unexpandedSubtype) => {
|
525
|
+
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
526
|
+
// We need to assume that "Any" is always both None and not None,
|
527
|
+
// so it matches regardless of whether the test is positive or negative.
|
528
|
+
return subtype;
|
529
|
+
}
|
530
|
+
// If this is a TypeVar that isn't constrained, use the unexpanded
|
531
|
+
// TypeVar. For all other cases (including constrained TypeVars),
|
532
|
+
// use the expanded subtype.
|
533
|
+
const adjustedSubtype = (0, types_1.isTypeVar)(unexpandedSubtype) && unexpandedSubtype.details.constraints.length === 0
|
534
|
+
? unexpandedSubtype
|
535
|
+
: subtype;
|
536
|
+
// See if it's a match for object.
|
537
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'object')) {
|
538
|
+
return isPositiveTest
|
539
|
+
? (0, typeUtils_1.addConditionToType)(types_1.NoneType.createInstance(), subtype.condition)
|
540
|
+
: adjustedSubtype;
|
541
|
+
}
|
542
|
+
// See if it's a match for None.
|
543
|
+
if ((0, types_1.isNoneInstance)(subtype) === isPositiveTest) {
|
544
|
+
return subtype;
|
545
|
+
}
|
546
|
+
return undefined;
|
547
|
+
});
|
548
|
+
}
|
549
|
+
// The "isinstance" and "issubclass" calls support two forms - a simple form
|
550
|
+
// that accepts a single class, and a more complex form that accepts a tuple
|
551
|
+
// of classes (including arbitrarily-nested tuples). This method determines
|
552
|
+
// which form and returns a list of classes or undefined.
|
553
|
+
function getIsInstanceClassTypes(argType) {
|
554
|
+
let foundNonClassType = false;
|
555
|
+
const classTypeList = [];
|
556
|
+
// Create a helper function that returns a list of class types or
|
557
|
+
// undefined if any of the types are not valid.
|
558
|
+
const addClassTypesToList = (types) => {
|
559
|
+
types.forEach((subtype) => {
|
560
|
+
if ((0, types_1.isInstantiableClass)(subtype) || ((0, types_1.isTypeVar)(subtype) && types_1.TypeBase.isInstantiable(subtype))) {
|
561
|
+
classTypeList.push(subtype);
|
562
|
+
}
|
563
|
+
else if ((0, types_1.isNoneTypeClass)(subtype)) {
|
564
|
+
classTypeList.push(subtype);
|
565
|
+
}
|
566
|
+
else if ((0, types_1.isFunction)(subtype) &&
|
567
|
+
subtype.details.parameters.length === 2 &&
|
568
|
+
subtype.details.parameters[0].category === 1 /* VarArgList */ &&
|
569
|
+
subtype.details.parameters[1].category === 2 /* VarArgDictionary */) {
|
570
|
+
classTypeList.push(subtype);
|
571
|
+
}
|
572
|
+
else {
|
573
|
+
foundNonClassType = true;
|
574
|
+
}
|
575
|
+
});
|
576
|
+
};
|
577
|
+
const addClassTypesRecursive = (subtype, recursionCount = 0) => {
|
578
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
579
|
+
return;
|
580
|
+
}
|
581
|
+
if ((0, types_1.isClass)(subtype) && types_1.TypeBase.isInstance(subtype) && (0, typeUtils_1.isTupleClass)(subtype)) {
|
582
|
+
if (subtype.tupleTypeArguments) {
|
583
|
+
subtype.tupleTypeArguments.forEach((tupleEntry) => {
|
584
|
+
addClassTypesRecursive(tupleEntry.type, recursionCount + 1);
|
585
|
+
});
|
586
|
+
}
|
587
|
+
}
|
588
|
+
else {
|
589
|
+
addClassTypesToList([subtype]);
|
590
|
+
}
|
591
|
+
};
|
592
|
+
(0, typeUtils_1.doForEachSubtype)(argType, (subtype) => {
|
593
|
+
addClassTypesRecursive(subtype);
|
594
|
+
});
|
595
|
+
return foundNonClassType ? undefined : classTypeList;
|
596
|
+
}
|
597
|
+
// Attempts to narrow a type (make it more constrained) based on a
|
598
|
+
// call to isinstance or issubclass. For example, if the original
|
599
|
+
// type of expression "x" is "Mammal" and the test expression is
|
600
|
+
// "isinstance(x, Cow)", (assuming "Cow" is a subclass of "Mammal"),
|
601
|
+
// we can conclude that x must be constrained to "Cow".
|
602
|
+
function narrowTypeForIsInstance(evaluator, type, classTypeList, isInstanceCheck, isPositiveTest, allowIntersections, errorNode) {
|
603
|
+
const expandedTypes = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
604
|
+
return (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(subtype);
|
605
|
+
});
|
606
|
+
// Filters the varType by the parameters of the isinstance
|
607
|
+
// and returns the list of types the varType could be after
|
608
|
+
// applying the filter.
|
609
|
+
const filterClassType = (varType, unexpandedType, constraints, negativeFallbackType) => {
|
610
|
+
const filteredTypes = [];
|
611
|
+
let foundSuperclass = false;
|
612
|
+
let isClassRelationshipIndeterminate = false;
|
613
|
+
for (const filterType of classTypeList) {
|
614
|
+
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
615
|
+
if ((0, types_1.isInstantiableClass)(concreteFilterType)) {
|
616
|
+
// Handle the special case where the variable type is a TypedDict and
|
617
|
+
// we're filtering against 'dict'. TypedDict isn't derived from dict,
|
618
|
+
// but at runtime, isinstance returns True.
|
619
|
+
const filterIsSuperclass = !(0, types_1.isTypeVar)(filterType) &&
|
620
|
+
(types_1.ClassType.isDerivedFrom(varType, concreteFilterType) ||
|
621
|
+
(isInstanceCheck &&
|
622
|
+
types_1.ClassType.isProtocolClass(concreteFilterType) &&
|
623
|
+
evaluator.assignType(concreteFilterType, varType)) ||
|
624
|
+
(types_1.ClassType.isBuiltIn(concreteFilterType, 'dict') && types_1.ClassType.isTypedDictClass(varType)));
|
625
|
+
const filterIsSubclass = types_1.ClassType.isDerivedFrom(concreteFilterType, varType) ||
|
626
|
+
(isInstanceCheck &&
|
627
|
+
types_1.ClassType.isProtocolClass(varType) &&
|
628
|
+
evaluator.assignType(varType, concreteFilterType));
|
629
|
+
if (filterIsSuperclass) {
|
630
|
+
foundSuperclass = true;
|
631
|
+
}
|
632
|
+
// Normally, a type should never be both a subclass or a superclass.
|
633
|
+
// This can happen if either of the class types derives from a
|
634
|
+
// class whose type is unknown (e.g. an import failed). We'll
|
635
|
+
// note this case specially so we don't do any narrowing, which
|
636
|
+
// will generate false positives.
|
637
|
+
if (filterIsSubclass &&
|
638
|
+
filterIsSuperclass &&
|
639
|
+
!types_1.ClassType.isSameGenericClass(varType, concreteFilterType)) {
|
640
|
+
isClassRelationshipIndeterminate = true;
|
641
|
+
}
|
642
|
+
if (isPositiveTest) {
|
643
|
+
if (filterIsSuperclass) {
|
644
|
+
// If the variable type is a subclass of the isinstance filter,
|
645
|
+
// we haven't learned anything new about the variable type.
|
646
|
+
filteredTypes.push((0, typeUtils_1.addConditionToType)(varType, constraints));
|
647
|
+
}
|
648
|
+
else if (filterIsSubclass) {
|
649
|
+
// If the variable type is a superclass of the isinstance
|
650
|
+
// filter, we can narrow the type to the subclass.
|
651
|
+
let specializedFilterType = filterType;
|
652
|
+
// Try to retain the type arguments for the filter type. This is
|
653
|
+
// important because a specialized version of the filter cannot
|
654
|
+
// be passed to isinstance or issubclass.
|
655
|
+
if ((0, types_1.isClass)(filterType)) {
|
656
|
+
if (types_1.ClassType.isSpecialBuiltIn(filterType) ||
|
657
|
+
filterType.details.typeParameters.length > 0) {
|
658
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(filterType));
|
659
|
+
const unspecializedFilterType = types_1.ClassType.cloneForSpecialization(filterType,
|
660
|
+
/* typeArguments */ undefined,
|
661
|
+
/* isTypeArgumentExplicit */ false);
|
662
|
+
if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, unspecializedFilterType, varType, typeVarContext,
|
663
|
+
/* liveTypeVarScopes */ undefined)) {
|
664
|
+
specializedFilterType = (0, typeUtils_1.applySolvedTypeVars)(unspecializedFilterType, typeVarContext,
|
665
|
+
/* unknownIfNotFound */ true);
|
666
|
+
}
|
667
|
+
}
|
668
|
+
}
|
669
|
+
filteredTypes.push((0, typeUtils_1.addConditionToType)(specializedFilterType, constraints));
|
670
|
+
}
|
671
|
+
else if (allowIntersections) {
|
672
|
+
// The two types appear to have no relation. It's possible that the
|
673
|
+
// two types are protocols or the program is expecting one type to
|
674
|
+
// be a mix-in class used with the other. In this case, we'll
|
675
|
+
// synthesize a new class type that represents an intersection of
|
676
|
+
// the two types.
|
677
|
+
const className = `<subclass of ${varType.details.name} and ${concreteFilterType.details.name}>`;
|
678
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
679
|
+
let newClassType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, 0 /* None */, ParseTreeUtils.getTypeSourceId(errorNode),
|
680
|
+
/* declaredMetaclass */ undefined, varType.details.effectiveMetaclass, varType.details.docString);
|
681
|
+
newClassType.details.baseClasses = [types_1.ClassType.cloneAsInstantiable(varType), concreteFilterType];
|
682
|
+
(0, typeUtils_1.computeMroLinearization)(newClassType);
|
683
|
+
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, concreteFilterType.condition);
|
684
|
+
if ((0, types_1.isTypeVar)(unexpandedType) &&
|
685
|
+
!unexpandedType.details.isParamSpec &&
|
686
|
+
unexpandedType.details.constraints.length === 0) {
|
687
|
+
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, [
|
688
|
+
{
|
689
|
+
typeVarName: types_1.TypeVarType.getNameWithScope(unexpandedType),
|
690
|
+
constraintIndex: 0,
|
691
|
+
isConstrainedTypeVar: false,
|
692
|
+
},
|
693
|
+
]);
|
694
|
+
}
|
695
|
+
const newClassInstanceType = types_1.ClassType.cloneAsInstance(newClassType);
|
696
|
+
// If this is a issubclass check, we do a double conversion from instantiable
|
697
|
+
// to instance back to instantiable to make sure that the includeSubclasses flag
|
698
|
+
// gets cleared.
|
699
|
+
filteredTypes.push(isInstanceCheck ? newClassInstanceType : types_1.ClassType.cloneAsInstantiable(newClassInstanceType));
|
700
|
+
}
|
701
|
+
}
|
702
|
+
}
|
703
|
+
else if ((0, types_1.isTypeVar)(filterType) && types_1.TypeBase.isInstantiable(filterType)) {
|
704
|
+
// Handle the case where the filter type is Type[T] and the unexpanded
|
705
|
+
// subtype is some instance type, possibly T.
|
706
|
+
if (isInstanceCheck && types_1.TypeBase.isInstance(unexpandedType)) {
|
707
|
+
if ((0, types_1.isTypeVar)(unexpandedType) && (0, types_1.isTypeSame)((0, typeUtils_1.convertToInstance)(filterType), unexpandedType)) {
|
708
|
+
// If the unexpanded subtype is T, we can definitively filter
|
709
|
+
// in both the positive and negative cases.
|
710
|
+
if (isPositiveTest) {
|
711
|
+
filteredTypes.push(unexpandedType);
|
712
|
+
}
|
713
|
+
}
|
714
|
+
else {
|
715
|
+
if (isPositiveTest) {
|
716
|
+
filteredTypes.push((0, typeUtils_1.convertToInstance)(filterType));
|
717
|
+
}
|
718
|
+
else {
|
719
|
+
// If the unexpanded subtype is some other instance, we can't
|
720
|
+
// filter anything because it might be an instance.
|
721
|
+
filteredTypes.push(unexpandedType);
|
722
|
+
isClassRelationshipIndeterminate = true;
|
723
|
+
}
|
724
|
+
}
|
725
|
+
}
|
726
|
+
else if (!isInstanceCheck && types_1.TypeBase.isInstantiable(unexpandedType)) {
|
727
|
+
if ((0, types_1.isTypeVar)(unexpandedType) && (0, types_1.isTypeSame)(filterType, unexpandedType)) {
|
728
|
+
if (isPositiveTest) {
|
729
|
+
filteredTypes.push(unexpandedType);
|
730
|
+
}
|
731
|
+
}
|
732
|
+
else {
|
733
|
+
if (isPositiveTest) {
|
734
|
+
filteredTypes.push(filterType);
|
735
|
+
}
|
736
|
+
else {
|
737
|
+
filteredTypes.push(unexpandedType);
|
738
|
+
isClassRelationshipIndeterminate = true;
|
739
|
+
}
|
740
|
+
}
|
741
|
+
}
|
742
|
+
}
|
743
|
+
else if ((0, types_1.isFunction)(filterType)) {
|
744
|
+
// Handle an isinstance check against Callable.
|
745
|
+
if (isInstanceCheck) {
|
746
|
+
let isCallable = false;
|
747
|
+
if ((0, types_1.isClass)(varType)) {
|
748
|
+
if (types_1.TypeBase.isInstantiable(unexpandedType)) {
|
749
|
+
isCallable = true;
|
750
|
+
}
|
751
|
+
else {
|
752
|
+
isCallable = !!(0, typeUtils_1.lookUpClassMember)(varType, '__call__');
|
753
|
+
}
|
754
|
+
}
|
755
|
+
if (isCallable) {
|
756
|
+
if (isPositiveTest) {
|
757
|
+
filteredTypes.push(unexpandedType);
|
758
|
+
}
|
759
|
+
else {
|
760
|
+
foundSuperclass = true;
|
761
|
+
}
|
762
|
+
}
|
763
|
+
}
|
764
|
+
}
|
765
|
+
}
|
766
|
+
// In the negative case, if one or more of the filters
|
767
|
+
// always match the type (i.e. they are an exact match or
|
768
|
+
// a superclass of the type), then there's nothing left after
|
769
|
+
// the filter is applied. If we didn't find any superclass
|
770
|
+
// match, then the original variable type survives the filter.
|
771
|
+
if (!isPositiveTest) {
|
772
|
+
if (!foundSuperclass || isClassRelationshipIndeterminate) {
|
773
|
+
filteredTypes.push(negativeFallbackType);
|
774
|
+
}
|
775
|
+
}
|
776
|
+
if (!isInstanceCheck) {
|
777
|
+
return filteredTypes;
|
778
|
+
}
|
779
|
+
return filteredTypes.map((t) => (0, typeUtils_1.convertToInstance)(t));
|
780
|
+
};
|
781
|
+
const filterFunctionType = (varType, unexpandedType) => {
|
782
|
+
const filteredTypes = [];
|
783
|
+
if (isPositiveTest) {
|
784
|
+
for (const filterType of classTypeList) {
|
785
|
+
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
786
|
+
if (evaluator.assignType(varType, (0, typeUtils_1.convertToInstance)(concreteFilterType))) {
|
787
|
+
// If the filter type is a Callable, use the original type. If the
|
788
|
+
// filter type is a callback protocol, use the filter type.
|
789
|
+
if ((0, types_1.isFunction)(filterType)) {
|
790
|
+
filteredTypes.push(unexpandedType);
|
791
|
+
}
|
792
|
+
else {
|
793
|
+
filteredTypes.push((0, typeUtils_1.convertToInstance)(filterType));
|
794
|
+
}
|
795
|
+
}
|
796
|
+
}
|
797
|
+
}
|
798
|
+
else if (!classTypeList.some((filterType) => {
|
799
|
+
// If the filter type is a runtime checkable protocol class, it can
|
800
|
+
// be used in an instance check.
|
801
|
+
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
802
|
+
if ((0, types_1.isClass)(concreteFilterType) && !types_1.ClassType.isProtocolClass(concreteFilterType)) {
|
803
|
+
return false;
|
804
|
+
}
|
805
|
+
return evaluator.assignType(varType, (0, typeUtils_1.convertToInstance)(concreteFilterType));
|
806
|
+
})) {
|
807
|
+
filteredTypes.push(unexpandedType);
|
808
|
+
}
|
809
|
+
return filteredTypes;
|
810
|
+
};
|
811
|
+
const anyOrUnknownSubstitutions = [];
|
812
|
+
const anyOrUnknown = [];
|
813
|
+
const filteredType = evaluator.mapSubtypesExpandTypeVars(expandedTypes,
|
814
|
+
/* conditionFilter */ undefined, (subtype, unexpandedSubtype) => {
|
815
|
+
// If we fail to filter anything in the negative case, we need to decide
|
816
|
+
// whether to retain the original TypeVar or replace it with its specialized
|
817
|
+
// type(s). We'll assume that if someone is using isinstance or issubclass
|
818
|
+
// on a constrained TypeVar that they want to filter based on its constrained
|
819
|
+
// parts.
|
820
|
+
const negativeFallback = (0, typeUtils_1.getTypeCondition)(subtype) ? subtype : unexpandedSubtype;
|
821
|
+
const isSubtypeTypeObject = (0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'type');
|
822
|
+
if (isPositiveTest && (0, types_1.isAnyOrUnknown)(subtype)) {
|
823
|
+
// If this is a positive test and the effective type is Any or
|
824
|
+
// Unknown, we can assume that the type matches one of the
|
825
|
+
// specified types.
|
826
|
+
if (isInstanceCheck) {
|
827
|
+
anyOrUnknownSubstitutions.push((0, types_1.combineTypes)(classTypeList.map((classType) => (0, typeUtils_1.convertToInstance)(classType))));
|
828
|
+
}
|
829
|
+
else {
|
830
|
+
// We perform a double conversion from instance to instantiable
|
831
|
+
// here to make sure that the includeSubclasses flag is cleared
|
832
|
+
// if it's a class.
|
833
|
+
anyOrUnknownSubstitutions.push((0, types_1.combineTypes)(classTypeList.map((classType) => (0, typeUtils_1.convertToInstantiable)((0, typeUtils_1.convertToInstance)(classType)))));
|
834
|
+
}
|
835
|
+
anyOrUnknown.push(subtype);
|
836
|
+
return undefined;
|
837
|
+
}
|
838
|
+
if (isInstanceCheck) {
|
839
|
+
if ((0, types_1.isNoneInstance)(subtype)) {
|
840
|
+
const containsNoneType = classTypeList.some((t) => (0, types_1.isNoneTypeClass)(t));
|
841
|
+
if (isPositiveTest) {
|
842
|
+
return containsNoneType ? subtype : undefined;
|
843
|
+
}
|
844
|
+
else {
|
845
|
+
return containsNoneType ? undefined : subtype;
|
846
|
+
}
|
847
|
+
}
|
848
|
+
if ((0, types_1.isModule)(subtype) || ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'ModuleType'))) {
|
849
|
+
// Handle type narrowing for runtime-checkable protocols
|
850
|
+
// when applied to modules.
|
851
|
+
if (isPositiveTest) {
|
852
|
+
const filteredTypes = classTypeList.filter((classType) => {
|
853
|
+
const concreteClassType = evaluator.makeTopLevelTypeVarsConcrete(classType);
|
854
|
+
return ((0, types_1.isInstantiableClass)(concreteClassType) && types_1.ClassType.isProtocolClass(concreteClassType));
|
855
|
+
});
|
856
|
+
if (filteredTypes.length > 0) {
|
857
|
+
return (0, typeUtils_1.convertToInstance)((0, types_1.combineTypes)(filteredTypes));
|
858
|
+
}
|
859
|
+
}
|
860
|
+
}
|
861
|
+
if ((0, types_1.isClassInstance)(subtype) && !isSubtypeTypeObject) {
|
862
|
+
return (0, types_1.combineTypes)(filterClassType(types_1.ClassType.cloneAsInstantiable(subtype), (0, typeUtils_1.convertToInstance)(unexpandedSubtype), (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
863
|
+
}
|
864
|
+
if (((0, types_1.isFunction)(subtype) || (0, types_1.isOverloadedFunction)(subtype)) && isInstanceCheck) {
|
865
|
+
return (0, types_1.combineTypes)(filterFunctionType(subtype, (0, typeUtils_1.convertToInstance)(unexpandedSubtype)));
|
866
|
+
}
|
867
|
+
if ((0, types_1.isInstantiableClass)(subtype) || isSubtypeTypeObject) {
|
868
|
+
// Handle the special case of isinstance(x, type).
|
869
|
+
const includesTypeType = classTypeList.some((classType) => (0, types_1.isInstantiableClass)(classType) && types_1.ClassType.isBuiltIn(classType, 'type'));
|
870
|
+
if (isPositiveTest) {
|
871
|
+
return includesTypeType ? negativeFallback : undefined;
|
872
|
+
}
|
873
|
+
else {
|
874
|
+
return includesTypeType ? undefined : negativeFallback;
|
875
|
+
}
|
876
|
+
}
|
877
|
+
}
|
878
|
+
else {
|
879
|
+
if ((0, types_1.isInstantiableClass)(subtype)) {
|
880
|
+
return (0, types_1.combineTypes)(filterClassType(subtype, unexpandedSubtype, (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
881
|
+
}
|
882
|
+
if (isSubtypeTypeObject) {
|
883
|
+
const objectType = evaluator.getBuiltInObject(errorNode, 'object');
|
884
|
+
if (objectType && (0, types_1.isClassInstance)(objectType)) {
|
885
|
+
return (0, types_1.combineTypes)(filterClassType(types_1.ClassType.cloneAsInstantiable(objectType), (0, typeUtils_1.convertToInstantiable)(unexpandedSubtype), (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
886
|
+
}
|
887
|
+
}
|
888
|
+
}
|
889
|
+
return isPositiveTest ? undefined : negativeFallback;
|
890
|
+
});
|
891
|
+
// If the result is Any/Unknown and contains no other subtypes and
|
892
|
+
// we have substitutions for Any/Unknown, use those instead. We don't
|
893
|
+
// want to apply this if the filtering produced something other than
|
894
|
+
// Any/Unknown. For example, if the statement is "isinstance(x, list)"
|
895
|
+
// and the type of x is "List[str] | int | Any", the result should be
|
896
|
+
// "List[str]", not "List[str] | List[Unknown]".
|
897
|
+
if ((0, types_1.isNever)(filteredType) && anyOrUnknownSubstitutions.length > 0) {
|
898
|
+
return (0, types_1.combineTypes)(anyOrUnknownSubstitutions);
|
899
|
+
}
|
900
|
+
if (anyOrUnknown.length > 0) {
|
901
|
+
return (0, types_1.combineTypes)([filteredType, ...anyOrUnknown]);
|
902
|
+
}
|
903
|
+
return filteredType;
|
904
|
+
}
|
905
|
+
// Attempts to narrow a union of tuples based on their known length.
|
906
|
+
function narrowTypeForTupleLength(evaluator, referenceType, lengthValue, isPositiveTest) {
|
907
|
+
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
908
|
+
const concreteSubtype = evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
909
|
+
// If it's not a tuple, we can't narrow it.
|
910
|
+
if (!(0, types_1.isClassInstance)(concreteSubtype) ||
|
911
|
+
!(0, typeUtils_1.isTupleClass)(concreteSubtype) ||
|
912
|
+
(0, typeUtils_1.isUnboundedTupleClass)(concreteSubtype) ||
|
913
|
+
!concreteSubtype.tupleTypeArguments) {
|
914
|
+
return subtype;
|
915
|
+
}
|
916
|
+
const tupleLengthMatches = concreteSubtype.tupleTypeArguments.length === lengthValue;
|
917
|
+
return tupleLengthMatches === isPositiveTest ? subtype : undefined;
|
918
|
+
});
|
919
|
+
}
|
920
|
+
// Attempts to narrow a type (make it more constrained) based on an "in" or
|
921
|
+
// "not in" binary expression.
|
922
|
+
function narrowTypeForContains(evaluator, referenceType, containerType) {
|
923
|
+
// We support contains narrowing only for certain built-in types that have been specialized.
|
924
|
+
if (!(0, types_1.isClassInstance)(containerType) || !types_1.ClassType.isBuiltIn(containerType)) {
|
925
|
+
return referenceType;
|
926
|
+
}
|
927
|
+
const builtInName = containerType.details.name;
|
928
|
+
if (!['list', 'set', 'frozenset', 'deque', 'tuple', 'dict', 'defaultdict', 'OrderedDict'].some((name) => name === builtInName)) {
|
929
|
+
return referenceType;
|
930
|
+
}
|
931
|
+
if (!containerType.typeArguments || containerType.typeArguments.length < 1) {
|
932
|
+
return referenceType;
|
933
|
+
}
|
934
|
+
let elementType = containerType.typeArguments[0];
|
935
|
+
if ((0, typeUtils_1.isTupleClass)(containerType) && containerType.tupleTypeArguments) {
|
936
|
+
elementType = (0, types_1.combineTypes)(containerType.tupleTypeArguments.map((t) => t.type));
|
937
|
+
}
|
938
|
+
let canNarrow = true;
|
939
|
+
const elementTypeWithoutLiteral = (0, typeUtils_1.stripLiteralValue)(elementType);
|
940
|
+
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (referenceSubtype) => {
|
941
|
+
const concreteReferenceType = evaluator.makeTopLevelTypeVarsConcrete(referenceSubtype);
|
942
|
+
if ((0, types_1.isAnyOrUnknown)(concreteReferenceType)) {
|
943
|
+
canNarrow = false;
|
944
|
+
return referenceSubtype;
|
945
|
+
}
|
946
|
+
if (evaluator.assignType(elementType, concreteReferenceType)) {
|
947
|
+
return referenceSubtype;
|
948
|
+
}
|
949
|
+
if (evaluator.assignType(elementTypeWithoutLiteral, concreteReferenceType)) {
|
950
|
+
return (0, typeUtils_1.mapSubtypes)(elementType, (elementSubtype) => {
|
951
|
+
if ((0, types_1.isClassInstance)(elementSubtype) && (0, types_1.isSameWithoutLiteralValue)(referenceSubtype, elementSubtype)) {
|
952
|
+
return elementSubtype;
|
953
|
+
}
|
954
|
+
return undefined;
|
955
|
+
});
|
956
|
+
}
|
957
|
+
return undefined;
|
958
|
+
});
|
959
|
+
return canNarrow ? narrowedType : referenceType;
|
960
|
+
}
|
961
|
+
// Attempts to narrow a type based on whether it is a TypedDict with
|
962
|
+
// a literal key value.
|
963
|
+
function narrowTypeForTypedDictKey(evaluator, referenceType, literalKey, isPositiveTest) {
|
964
|
+
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
965
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
|
966
|
+
const entries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, subtype, /* allowNarrowed */ true);
|
967
|
+
const tdEntry = entries.get(literalKey.literalValue);
|
968
|
+
if (isPositiveTest) {
|
969
|
+
if (!tdEntry) {
|
970
|
+
// If the class is final, we can say with certainty that if
|
971
|
+
// the TypedDict doesn't define this entry, it is not this type.
|
972
|
+
// If it's not final, we can't say this because it could be a
|
973
|
+
// subclass of this TypedDict that adds more fields.
|
974
|
+
return types_1.ClassType.isFinal(subtype) ? undefined : subtype;
|
975
|
+
}
|
976
|
+
// If the entry is currently not required and not marked provided, we can mark
|
977
|
+
// it as provided after this guard expression confirms it is.
|
978
|
+
if (tdEntry.isRequired || tdEntry.isProvided) {
|
979
|
+
return subtype;
|
980
|
+
}
|
981
|
+
const oldNarrowedEntriesMap = subtype.typedDictNarrowedEntries;
|
982
|
+
const newNarrowedEntriesMap = new Map();
|
983
|
+
if (oldNarrowedEntriesMap) {
|
984
|
+
// Copy the old entries.
|
985
|
+
oldNarrowedEntriesMap.forEach((value, key) => {
|
986
|
+
newNarrowedEntriesMap.set(key, value);
|
987
|
+
});
|
988
|
+
}
|
989
|
+
// Add the new entry.
|
990
|
+
newNarrowedEntriesMap.set(literalKey.literalValue, {
|
991
|
+
valueType: tdEntry.valueType,
|
992
|
+
isRequired: false,
|
993
|
+
isProvided: true,
|
994
|
+
});
|
995
|
+
// Clone the TypedDict object with the new entries.
|
996
|
+
return types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForNarrowedTypedDictEntries(types_1.ClassType.cloneAsInstantiable(subtype), newNarrowedEntriesMap));
|
997
|
+
}
|
998
|
+
else {
|
999
|
+
return tdEntry !== undefined && (tdEntry.isRequired || tdEntry.isProvided) ? undefined : subtype;
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
return subtype;
|
1003
|
+
});
|
1004
|
+
return narrowedType;
|
1005
|
+
}
|
1006
|
+
// Attempts to narrow a TypedDict type based on a comparison (equal or not
|
1007
|
+
// equal) between a discriminating entry type that has a declared literal
|
1008
|
+
// type to a literal value.
|
1009
|
+
function narrowTypeForDiscriminatedDictEntryComparison(evaluator, referenceType, indexLiteralType, literalType, isPositiveTest) {
|
1010
|
+
let canNarrow = true;
|
1011
|
+
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
1012
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
|
1013
|
+
const symbolMap = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, subtype);
|
1014
|
+
const tdEntry = symbolMap.get(indexLiteralType.literalValue);
|
1015
|
+
if (tdEntry && (0, typeUtils_1.isLiteralTypeOrUnion)(tdEntry.valueType)) {
|
1016
|
+
if (isPositiveTest) {
|
1017
|
+
return evaluator.assignType(tdEntry.valueType, literalType) ? subtype : undefined;
|
1018
|
+
}
|
1019
|
+
else {
|
1020
|
+
return evaluator.assignType(literalType, tdEntry.valueType) ? undefined : subtype;
|
1021
|
+
}
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
canNarrow = false;
|
1025
|
+
return subtype;
|
1026
|
+
});
|
1027
|
+
return canNarrow ? narrowedType : referenceType;
|
1028
|
+
}
|
1029
|
+
function narrowTypeForDiscriminatedTupleComparison(evaluator, referenceType, indexLiteralType, literalType, isPositiveTest) {
|
1030
|
+
let canNarrow = true;
|
1031
|
+
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
1032
|
+
var _a;
|
1033
|
+
if ((0, types_1.isClassInstance)(subtype) &&
|
1034
|
+
types_1.ClassType.isTupleClass(subtype) &&
|
1035
|
+
!(0, typeUtils_1.isUnboundedTupleClass)(subtype) &&
|
1036
|
+
typeof indexLiteralType.literalValue === 'number') {
|
1037
|
+
const indexValue = indexLiteralType.literalValue;
|
1038
|
+
if (subtype.tupleTypeArguments && indexValue >= 0 && indexValue < subtype.tupleTypeArguments.length) {
|
1039
|
+
const tupleEntryType = (_a = subtype.tupleTypeArguments[indexValue]) === null || _a === void 0 ? void 0 : _a.type;
|
1040
|
+
if (tupleEntryType && (0, typeUtils_1.isLiteralTypeOrUnion)(tupleEntryType)) {
|
1041
|
+
if (isPositiveTest) {
|
1042
|
+
return evaluator.assignType(tupleEntryType, literalType) ? subtype : undefined;
|
1043
|
+
}
|
1044
|
+
else {
|
1045
|
+
return evaluator.assignType(literalType, tupleEntryType) ? undefined : subtype;
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
}
|
1050
|
+
canNarrow = false;
|
1051
|
+
return subtype;
|
1052
|
+
});
|
1053
|
+
return canNarrow ? narrowedType : referenceType;
|
1054
|
+
}
|
1055
|
+
// Attempts to narrow a type based on a comparison (equal or not equal)
|
1056
|
+
// between a discriminating field that has a declared literal type to a
|
1057
|
+
// literal value.
|
1058
|
+
function narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, referenceType, memberName, literalType, isPositiveTest) {
|
1059
|
+
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
1060
|
+
let memberInfo;
|
1061
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
1062
|
+
memberInfo = (0, typeUtils_1.lookUpObjectMember)(subtype, memberName);
|
1063
|
+
}
|
1064
|
+
else if ((0, types_1.isInstantiableClass)(subtype)) {
|
1065
|
+
memberInfo = (0, typeUtils_1.lookUpClassMember)(subtype, memberName);
|
1066
|
+
}
|
1067
|
+
if (memberInfo && memberInfo.isTypeDeclared) {
|
1068
|
+
let memberType = evaluator.getTypeOfMember(memberInfo);
|
1069
|
+
// Handle the case where the field is a property
|
1070
|
+
// that has a declared literal return type for its getter.
|
1071
|
+
if ((0, types_1.isClassInstance)(subtype) && (0, typeUtils_1.isProperty)(memberType)) {
|
1072
|
+
const getterInfo = (0, typeUtils_1.lookUpObjectMember)(memberType, 'fget');
|
1073
|
+
if (getterInfo && getterInfo.isTypeDeclared) {
|
1074
|
+
const getterType = evaluator.getTypeOfMember(getterInfo);
|
1075
|
+
if ((0, types_1.isFunction)(getterType) && getterType.details.declaredReturnType) {
|
1076
|
+
const getterReturnType = types_1.FunctionType.getSpecializedReturnType(getterType);
|
1077
|
+
if (getterReturnType) {
|
1078
|
+
memberType = getterReturnType;
|
1079
|
+
}
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
if ((0, typeUtils_1.isLiteralTypeOrUnion)(memberType)) {
|
1084
|
+
if (isPositiveTest) {
|
1085
|
+
return evaluator.assignType(memberType, literalType) ? subtype : undefined;
|
1086
|
+
}
|
1087
|
+
else {
|
1088
|
+
return evaluator.assignType(literalType, memberType) ? undefined : subtype;
|
1089
|
+
}
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
return subtype;
|
1093
|
+
});
|
1094
|
+
return narrowedType;
|
1095
|
+
}
|
1096
|
+
// Attempts to narrow a type based on a comparison (equal or not equal)
|
1097
|
+
// between a discriminating field that has a declared None type to a
|
1098
|
+
// None.
|
1099
|
+
function narrowTypeForDiscriminatedFieldNoneComparison(evaluator, referenceType, memberName, isPositiveTest) {
|
1100
|
+
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
1101
|
+
let memberInfo;
|
1102
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
1103
|
+
memberInfo = (0, typeUtils_1.lookUpObjectMember)(subtype, memberName);
|
1104
|
+
}
|
1105
|
+
else if ((0, types_1.isInstantiableClass)(subtype)) {
|
1106
|
+
memberInfo = (0, typeUtils_1.lookUpClassMember)(subtype, memberName);
|
1107
|
+
}
|
1108
|
+
if (memberInfo && memberInfo.isTypeDeclared) {
|
1109
|
+
const memberType = evaluator.makeTopLevelTypeVarsConcrete(evaluator.getTypeOfMember(memberInfo));
|
1110
|
+
let canNarrow = true;
|
1111
|
+
if (isPositiveTest) {
|
1112
|
+
(0, typeUtils_1.doForEachSubtype)(memberType, (memberSubtype) => {
|
1113
|
+
memberSubtype = evaluator.makeTopLevelTypeVarsConcrete(memberSubtype);
|
1114
|
+
// Don't attempt to narrow if the member is a descriptor or property.
|
1115
|
+
if ((0, typeUtils_1.isProperty)(memberSubtype) || (0, typeUtils_1.isMaybeDescriptorInstance)(memberSubtype)) {
|
1116
|
+
canNarrow = false;
|
1117
|
+
}
|
1118
|
+
if ((0, types_1.isAnyOrUnknown)(memberSubtype) || (0, types_1.isNoneInstance)(memberSubtype) || (0, types_1.isNever)(memberSubtype)) {
|
1119
|
+
canNarrow = false;
|
1120
|
+
}
|
1121
|
+
});
|
1122
|
+
}
|
1123
|
+
else {
|
1124
|
+
canNarrow = (0, types_1.isNoneInstance)(memberType);
|
1125
|
+
}
|
1126
|
+
if (canNarrow) {
|
1127
|
+
return undefined;
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
return subtype;
|
1131
|
+
});
|
1132
|
+
}
|
1133
|
+
// Attempts to narrow a type based on a "type(x) is y" or "type(x) is not y" check.
|
1134
|
+
function narrowTypeForTypeIs(type, classType, isPositiveTest) {
|
1135
|
+
return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
1136
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
1137
|
+
const matches = types_1.ClassType.isDerivedFrom(classType, types_1.ClassType.cloneAsInstantiable(subtype));
|
1138
|
+
if (isPositiveTest) {
|
1139
|
+
if (matches) {
|
1140
|
+
if (types_1.ClassType.isSameGenericClass(subtype, classType)) {
|
1141
|
+
return subtype;
|
1142
|
+
}
|
1143
|
+
return types_1.ClassType.cloneAsInstance(classType);
|
1144
|
+
}
|
1145
|
+
return undefined;
|
1146
|
+
}
|
1147
|
+
else {
|
1148
|
+
// If the class if marked final and it matches, then
|
1149
|
+
// we can eliminate it in the negative case.
|
1150
|
+
if (matches && types_1.ClassType.isFinal(subtype)) {
|
1151
|
+
return undefined;
|
1152
|
+
}
|
1153
|
+
// We can't eliminate the subtype in the negative
|
1154
|
+
// case because it could be a subclass of the type,
|
1155
|
+
// in which case `type(x) is y` would fail.
|
1156
|
+
return subtype;
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
else if ((0, types_1.isNoneInstance)(subtype)) {
|
1160
|
+
return isPositiveTest ? undefined : subtype;
|
1161
|
+
}
|
1162
|
+
else if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
1163
|
+
return isPositiveTest ? types_1.ClassType.cloneAsInstance(classType) : subtype;
|
1164
|
+
}
|
1165
|
+
return subtype;
|
1166
|
+
});
|
1167
|
+
}
|
1168
|
+
// Attempts to narrow a type (make it more constrained) based on a comparison
|
1169
|
+
// (equal or not equal) to a literal value. It also handles "is" or "is not"
|
1170
|
+
// operators if isIsOperator is true.
|
1171
|
+
function narrowTypeForLiteralComparison(evaluator, referenceType, literalType, isPositiveTest, isIsOperator) {
|
1172
|
+
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
1173
|
+
subtype = evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
1174
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isSameGenericClass(literalType, subtype)) {
|
1175
|
+
if (subtype.literalValue !== undefined) {
|
1176
|
+
const literalValueMatches = types_1.ClassType.isLiteralValueSame(subtype, literalType);
|
1177
|
+
if ((literalValueMatches && !isPositiveTest) || (!literalValueMatches && isPositiveTest)) {
|
1178
|
+
return undefined;
|
1179
|
+
}
|
1180
|
+
return subtype;
|
1181
|
+
}
|
1182
|
+
else if (isPositiveTest) {
|
1183
|
+
return literalType;
|
1184
|
+
}
|
1185
|
+
else {
|
1186
|
+
// If we're able to enumerate all possible literal values
|
1187
|
+
// (for bool or enum), we can eliminate all others in a negative test.
|
1188
|
+
const allLiteralTypes = enumerateLiteralsForType(evaluator, subtype);
|
1189
|
+
if (allLiteralTypes && allLiteralTypes.length > 0) {
|
1190
|
+
return (0, types_1.combineTypes)(allLiteralTypes.filter((type) => !types_1.ClassType.isLiteralValueSame(type, literalType)));
|
1191
|
+
}
|
1192
|
+
}
|
1193
|
+
}
|
1194
|
+
else if (isPositiveTest) {
|
1195
|
+
if (isIsOperator || (0, types_1.isNoneInstance)(subtype)) {
|
1196
|
+
return undefined;
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
return subtype;
|
1200
|
+
});
|
1201
|
+
}
|
1202
|
+
function enumerateLiteralsForType(evaluator, type) {
|
1203
|
+
if (types_1.ClassType.isBuiltIn(type, 'bool')) {
|
1204
|
+
// Booleans have only two types: True and False.
|
1205
|
+
return [
|
1206
|
+
types_1.ClassType.cloneWithLiteral(type, /* value */ true),
|
1207
|
+
types_1.ClassType.cloneWithLiteral(type, /* value */ false),
|
1208
|
+
];
|
1209
|
+
}
|
1210
|
+
if (types_1.ClassType.isEnumClass(type)) {
|
1211
|
+
// Enumerate all of the values in this enumeration.
|
1212
|
+
const enumList = [];
|
1213
|
+
const fields = type.details.fields;
|
1214
|
+
fields.forEach((symbol) => {
|
1215
|
+
if (!symbol.isIgnoredForProtocolMatch()) {
|
1216
|
+
const symbolType = evaluator.getEffectiveTypeOfSymbol(symbol);
|
1217
|
+
if ((0, types_1.isClassInstance)(symbolType) &&
|
1218
|
+
types_1.ClassType.isSameGenericClass(type, symbolType) &&
|
1219
|
+
symbolType.literalValue !== undefined) {
|
1220
|
+
enumList.push(symbolType);
|
1221
|
+
}
|
1222
|
+
}
|
1223
|
+
});
|
1224
|
+
return enumList;
|
1225
|
+
}
|
1226
|
+
return undefined;
|
1227
|
+
}
|
1228
|
+
exports.enumerateLiteralsForType = enumerateLiteralsForType;
|
1229
|
+
// Attempts to narrow a type (make it more constrained) based on a
|
1230
|
+
// call to "callable". For example, if the original type of expression "x" is
|
1231
|
+
// Union[Callable[..., Any], Type[int], int], it would remove the "int" because
|
1232
|
+
// it's not callable.
|
1233
|
+
function narrowTypeForCallable(evaluator, type, isPositiveTest, errorNode, allowIntersections) {
|
1234
|
+
return evaluator.mapSubtypesExpandTypeVars(type, /* conditionFilter */ undefined, (subtype) => {
|
1235
|
+
switch (subtype.category) {
|
1236
|
+
case 5 /* Function */:
|
1237
|
+
case 6 /* OverloadedFunction */: {
|
1238
|
+
return isPositiveTest ? subtype : undefined;
|
1239
|
+
}
|
1240
|
+
case 3 /* None */:
|
1241
|
+
case 8 /* Module */: {
|
1242
|
+
return isPositiveTest ? undefined : subtype;
|
1243
|
+
}
|
1244
|
+
case 7 /* Class */: {
|
1245
|
+
if (types_1.TypeBase.isInstantiable(subtype)) {
|
1246
|
+
return isPositiveTest ? subtype : undefined;
|
1247
|
+
}
|
1248
|
+
// See if the object is callable.
|
1249
|
+
const callMemberType = (0, typeUtils_1.lookUpClassMember)(subtype, '__call__');
|
1250
|
+
if (!callMemberType) {
|
1251
|
+
if (!isPositiveTest) {
|
1252
|
+
return subtype;
|
1253
|
+
}
|
1254
|
+
if (allowIntersections) {
|
1255
|
+
// The type appears to not be callable. It's possible that the
|
1256
|
+
// two type is a subclass that is callable. We'll synthesize a
|
1257
|
+
// new intersection type.
|
1258
|
+
const className = `<callable subtype of ${subtype.details.name}>`;
|
1259
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
1260
|
+
let newClassType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, 0 /* None */, ParseTreeUtils.getTypeSourceId(errorNode),
|
1261
|
+
/* declaredMetaclass */ undefined, subtype.details.effectiveMetaclass, subtype.details.docString);
|
1262
|
+
newClassType.details.baseClasses = [types_1.ClassType.cloneAsInstantiable(subtype)];
|
1263
|
+
(0, typeUtils_1.computeMroLinearization)(newClassType);
|
1264
|
+
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, subtype.condition);
|
1265
|
+
// Add a __call__ method to the new class.
|
1266
|
+
const callMethod = types_1.FunctionType.createSynthesizedInstance('__call__');
|
1267
|
+
const selfParam = {
|
1268
|
+
category: 0 /* Simple */,
|
1269
|
+
name: 'self',
|
1270
|
+
type: types_1.ClassType.cloneAsInstance(newClassType),
|
1271
|
+
hasDeclaredType: true,
|
1272
|
+
};
|
1273
|
+
types_1.FunctionType.addParameter(callMethod, selfParam);
|
1274
|
+
types_1.FunctionType.addDefaultParameters(callMethod);
|
1275
|
+
callMethod.details.declaredReturnType = types_1.UnknownType.create();
|
1276
|
+
newClassType.details.fields.set('__call__', symbol_1.Symbol.createWithType(4 /* ClassMember */, callMethod));
|
1277
|
+
return types_1.ClassType.cloneAsInstance(newClassType);
|
1278
|
+
}
|
1279
|
+
return undefined;
|
1280
|
+
}
|
1281
|
+
else {
|
1282
|
+
return isPositiveTest ? subtype : undefined;
|
1283
|
+
}
|
1284
|
+
}
|
1285
|
+
default: {
|
1286
|
+
// For all other types, we can't determine whether it's
|
1287
|
+
// callable or not, so we can't eliminate them.
|
1288
|
+
return subtype;
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
});
|
1292
|
+
}
|
1293
|
+
//# sourceMappingURL=typeGuards.js.map
|