@zzzen/pyright-internal 1.2.0-dev.20240804 → 1.2.0-dev.20240818
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/analysis.js +2 -2
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.js +2 -3
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +20 -21
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +1 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.d.ts +0 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +2 -0
- package/dist/analyzer/checker.js +272 -207
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/circularDependency.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +6 -6
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +17 -17
- package/dist/analyzer/codeFlowTypes.js +5 -5
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +1 -2
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/commentUtils.js +1 -2
- package/dist/analyzer/commentUtils.js.map +1 -1
- package/dist/analyzer/constraintSolution.d.ts +2 -1
- package/dist/analyzer/constraintSolution.js +7 -1
- package/dist/analyzer/constraintSolution.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +1 -2
- package/dist/analyzer/constraintSolver.js +139 -163
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.d.ts +5 -4
- package/dist/analyzer/constraintTracker.js +14 -9
- package/dist/analyzer/constraintTracker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +8 -8
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +15 -16
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +38 -27
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js +11 -11
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +8 -9
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.d.ts +1 -1
- package/dist/analyzer/decorators.js +33 -29
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +2 -3
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/docStringUtils.js +2 -3
- package/dist/analyzer/docStringUtils.js.map +1 -1
- package/dist/analyzer/enums.js +18 -15
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.d.ts +2 -2
- package/dist/analyzer/functionTransform.js +1 -2
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +0 -1
- package/dist/analyzer/importResolver.js +8 -8
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +15 -15
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +2 -3
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +142 -124
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +3 -3
- package/dist/analyzer/packageTypeReport.js +2 -2
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +9 -9
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -5
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +94 -92
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +2 -2
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +18 -22
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +5 -1
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +7 -9
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +2 -2
- package/dist/analyzer/protocols.js +55 -50
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pyTypedUtils.js +2 -3
- package/dist/analyzer/pyTypedUtils.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +8 -7
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +5 -6
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +3 -0
- package/dist/analyzer/service.js +173 -103
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/serviceUtils.js +5 -5
- package/dist/analyzer/serviceUtils.js.map +1 -1
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +4 -5
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +5 -4
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.js +1 -2
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +11 -12
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolNameUtils.js +8 -9
- package/dist/analyzer/symbolNameUtils.js.map +1 -1
- package/dist/analyzer/symbolUtils.js +4 -5
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +5 -4
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +1 -1
- package/dist/analyzer/tuples.js +9 -10
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeComplexity.js +2 -3
- package/dist/analyzer/typeComplexity.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +2 -2
- package/dist/analyzer/typeDocStringUtils.js +34 -25
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +487 -483
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -10
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +1 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +31 -30
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +11 -11
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +12 -15
- package/dist/analyzer/typeUtils.js +181 -219
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.d.ts +2 -2
- package/dist/analyzer/typeWalker.js +9 -4
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +41 -41
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +18 -16
- package/dist/analyzer/types.js +74 -74
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +0 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +0 -1
- package/dist/backgroundThreadBase.js +7 -14
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +2 -2
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/cancellationUtils.js +9 -9
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +3 -3
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/collectionUtils.js +23 -23
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +19 -12
- package/dist/common/commandLineOptions.js +26 -9
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/commandUtils.js +1 -2
- package/dist/common/commandUtils.js.map +1 -1
- package/dist/common/configOptions.d.ts +2 -2
- package/dist/common/configOptions.js +30 -40
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +4 -4
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js +21 -21
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js +1 -2
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/debug.js +9 -10
- package/dist/common/debug.js.map +1 -1
- package/dist/common/deferred.js +3 -4
- package/dist/common/deferred.js.map +1 -1
- package/dist/common/diagnostic.js +3 -3
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/envVarUtils.js +2 -3
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +4 -4
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -2
- package/dist/common/fileWatcher.js +2 -2
- package/dist/common/fileWatcher.js.map +1 -1
- package/dist/common/fullAccessHost.js +1 -1
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/logTracker.js +2 -2
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.d.ts +1 -1
- package/dist/common/lspUtils.js +3 -4
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/memUtils.js +2 -2
- package/dist/common/memUtils.js.map +1 -1
- package/dist/common/pathUtils.js +32 -32
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/positionUtils.js +7 -8
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/pythonVersion.d.ts +17 -20
- package/dist/common/pythonVersion.js +81 -85
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +0 -2
- package/dist/common/realFileSystem.js +2 -2
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +1 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.js +12 -13
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.js +13 -13
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/textRangeCollection.js +2 -2
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/timing.js.map +1 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +3 -4
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +0 -1
- package/dist/common/uri/uriUtils.js +20 -20
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +8 -9
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +30 -29
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +4 -4
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +4 -4
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +4 -5
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +5 -5
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +3 -3
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +2 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/dynamicFeature.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +6 -6
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/navigationUtils.js +3 -4
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/quickActions.js +1 -2
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +5 -5
- package/dist/languageService/tooltipUtils.js +31 -31
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +7 -4
- package/dist/localization/localize.js +9 -8
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +0 -2
- package/dist/localization/package.nls.de.json +0 -2
- package/dist/localization/package.nls.en-us.json +4 -3
- package/dist/localization/package.nls.es.json +0 -2
- package/dist/localization/package.nls.fr.json +0 -2
- package/dist/localization/package.nls.it.json +0 -2
- package/dist/localization/package.nls.ja.json +0 -2
- package/dist/localization/package.nls.ko.json +0 -2
- package/dist/localization/package.nls.pl.json +0 -2
- package/dist/localization/package.nls.pt-br.json +0 -2
- package/dist/localization/package.nls.qps-ploc.json +0 -2
- package/dist/localization/package.nls.ru.json +0 -2
- package/dist/localization/package.nls.tr.json +0 -2
- package/dist/localization/package.nls.zh-cn.json +0 -2
- package/dist/localization/package.nls.zh-tw.json +0 -2
- package/dist/nodeMain.js +1 -2
- package/dist/nodeMain.js.map +1 -1
- package/dist/nodeServer.js +2 -3
- package/dist/nodeServer.js.map +1 -1
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js +10 -11
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +8 -8
- package/dist/parser/parseNodes.js +5 -5
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +32 -23
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +2 -2
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/unicode.js +468 -468
- package/dist/parser/unicode.js.map +1 -1
- package/dist/pprof/profiler.js +2 -3
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js +22 -23
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +0 -2
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +0 -2
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/cacheManager.test.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +3 -3
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/config.test.js +160 -24
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +1 -2
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.comment.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.for.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.method.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dunderNew.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.enums.members.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.errorNodes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.excluded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.dunderNames.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.js.map +1 -1
- package/dist/tests/fourslash/completions.import.submodule.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inList.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.included.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.literals.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.localCode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.importStub.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.property.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.parameters.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.params.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolder.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolders.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.private.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.property.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.self.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.triggers.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.typeAlias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.typeshed.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.with.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.variable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.async.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByBuiltin.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByUserCode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.classNoInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.formatted.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.import.django.view.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.import.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inferred.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.init.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.overloadedFunction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.slots.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.multipart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.nameconflict.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.publicSymbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.wildcard.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/importnotresolved.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/noerrors.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/orderImports1.command.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/orderImports2.command.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.args.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.function.untitledFile.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.function.untitledFile.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.init.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.library.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.parens.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.parens.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.excluded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.cornercases.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.dunderNew.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.overload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.simple.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/typeVerifier.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/typeVerifier.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +1 -2
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.d.ts +0 -1
- package/dist/tests/harness/fourslash/runner.js +2 -3
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +7 -7
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +4 -5
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +7 -8
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.d.ts +0 -2
- package/dist/tests/harness/utils.js +7 -7
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js +3 -3
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +0 -2
- package/dist/tests/harness/vfs/filesystem.js +2 -2
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +2 -2
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +1 -2
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +14 -14
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/lsp/webpack.testserver.config.d.ts +2 -2
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/serialization.test.js +1 -2
- package/dist/tests/serialization.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +5 -6
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.js +8 -9
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +6 -6
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +8 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +2 -2
- package/dist/tests/typeEvaluator4.test.js +6 -2
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +17 -9
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +2 -2
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/workspaceFactory.js +3 -3
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
@@ -38,7 +38,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
38
38
|
return result;
|
39
39
|
};
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
41
|
-
exports.
|
41
|
+
exports.maxCodeComplexity = void 0;
|
42
|
+
exports.createTypeEvaluator = createTypeEvaluator;
|
42
43
|
const cancellationUtils_1 = require("../common/cancellationUtils");
|
43
44
|
const collectionUtils_1 = require("../common/collectionUtils");
|
44
45
|
const debug_1 = require("../common/debug");
|
@@ -55,6 +56,7 @@ const analyzerFileInfo_1 = require("./analyzerFileInfo");
|
|
55
56
|
const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
56
57
|
const codeFlowEngine_1 = require("./codeFlowEngine");
|
57
58
|
const codeFlowTypes_1 = require("./codeFlowTypes");
|
59
|
+
const constraintSolution_1 = require("./constraintSolution");
|
58
60
|
const constraintSolver_1 = require("./constraintSolver");
|
59
61
|
const constraintTracker_1 = require("./constraintTracker");
|
60
62
|
const constructors_1 = require("./constructors");
|
@@ -571,8 +573,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
571
573
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
572
574
|
// Make sure the resulting type is assignable to the expected type.
|
573
575
|
if (!assignType(inferenceContext.expectedType, typeResult.type, diag,
|
574
|
-
/*
|
575
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
576
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
576
577
|
typeResult.typeErrors = true;
|
577
578
|
typeResult.expectedTypeDiagAddendum = diag;
|
578
579
|
diag.addTextRange(node);
|
@@ -1123,7 +1124,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1123
1124
|
return (0, types_1.findSubtype)(type, (subtype) => canBeFalsy(subtype, recursionCount)) !== undefined;
|
1124
1125
|
}
|
1125
1126
|
case 4 /* TypeCategory.Function */:
|
1126
|
-
case 5 /* TypeCategory.
|
1127
|
+
case 5 /* TypeCategory.Overloaded */:
|
1127
1128
|
case 7 /* TypeCategory.Module */:
|
1128
1129
|
case 9 /* TypeCategory.TypeVar */: {
|
1129
1130
|
return false;
|
@@ -1142,9 +1143,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1142
1143
|
return (0, typeUtils_1.isUnboundedTupleClass)(tupleBaseClass) || tupleBaseClass.priv.tupleTypeArgs.length === 0;
|
1143
1144
|
}
|
1144
1145
|
// Check for bool, int, str and bytes literals that are never falsy.
|
1145
|
-
if (type.priv.literalValue !== undefined
|
1146
|
-
types_1.ClassType.isBuiltIn(type, ['bool', 'int', 'str', 'bytes'])) {
|
1147
|
-
|
1146
|
+
if (type.priv.literalValue !== undefined) {
|
1147
|
+
if (types_1.ClassType.isBuiltIn(type, ['bool', 'int', 'str', 'bytes'])) {
|
1148
|
+
return !type.priv.literalValue || type.priv.literalValue === BigInt(0);
|
1149
|
+
}
|
1150
|
+
if (type.priv.literalValue instanceof types_1.EnumLiteral) {
|
1151
|
+
// Does the Enum class forward the truthiness check to the
|
1152
|
+
// underlying member type?
|
1153
|
+
if (type.priv.literalValue.isReprEnum) {
|
1154
|
+
return canBeFalsy(type.priv.literalValue.itemType, recursionCount);
|
1155
|
+
}
|
1156
|
+
}
|
1148
1157
|
}
|
1149
1158
|
// If this is a protocol class, don't make any assumptions about the absence
|
1150
1159
|
// of specific methods. These could be provided by a class that conforms
|
@@ -1189,7 +1198,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1189
1198
|
switch (type.category) {
|
1190
1199
|
case 1 /* TypeCategory.Unknown */:
|
1191
1200
|
case 4 /* TypeCategory.Function */:
|
1192
|
-
case 5 /* TypeCategory.
|
1201
|
+
case 5 /* TypeCategory.Overloaded */:
|
1193
1202
|
case 7 /* TypeCategory.Module */:
|
1194
1203
|
case 9 /* TypeCategory.TypeVar */:
|
1195
1204
|
case 3 /* TypeCategory.Never */:
|
@@ -1214,9 +1223,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1214
1223
|
return false;
|
1215
1224
|
}
|
1216
1225
|
// Check for bool, int, str and bytes literals that are never falsy.
|
1217
|
-
if (type.priv.literalValue !== undefined
|
1218
|
-
types_1.ClassType.isBuiltIn(type, ['bool', 'int', 'str', 'bytes'])) {
|
1219
|
-
|
1226
|
+
if (type.priv.literalValue !== undefined) {
|
1227
|
+
if (types_1.ClassType.isBuiltIn(type, ['bool', 'int', 'str', 'bytes'])) {
|
1228
|
+
return !!type.priv.literalValue && type.priv.literalValue !== BigInt(0);
|
1229
|
+
}
|
1230
|
+
if (type.priv.literalValue instanceof types_1.EnumLiteral) {
|
1231
|
+
// Does the Enum class forward the truthiness check to the
|
1232
|
+
// underlying member type?
|
1233
|
+
if (type.priv.literalValue.isReprEnum) {
|
1234
|
+
return canBeTruthy(type.priv.literalValue.itemType, recursionCount);
|
1235
|
+
}
|
1236
|
+
}
|
1220
1237
|
}
|
1221
1238
|
// If this is a protocol class, don't make any assumptions about the absence
|
1222
1239
|
// of specific methods. These could be provided by a class that conforms
|
@@ -1344,9 +1361,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1344
1361
|
});
|
1345
1362
|
}
|
1346
1363
|
function solveAndApplyConstraints(type, constraints, applyOptions, solveOptions) {
|
1347
|
-
if (solveOptions === null || solveOptions === void 0 ? void 0 : solveOptions.applyUnificationVars) {
|
1348
|
-
(0, constraintSolver_1.applyUnificationVars)(evaluatorInterface, constraints);
|
1349
|
-
}
|
1350
1364
|
const solution = (0, constraintSolver_1.solveConstraints)(evaluatorInterface, constraints, solveOptions);
|
1351
1365
|
return (0, typeUtils_1.applySolvedTypeVars)(type, solution, applyOptions);
|
1352
1366
|
}
|
@@ -1484,7 +1498,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1484
1498
|
if (!boundMethodResult || boundMethodResult.typeErrors) {
|
1485
1499
|
return undefined;
|
1486
1500
|
}
|
1487
|
-
if ((0, types_1.isFunction)(boundMethodResult.type) || (0, types_1.
|
1501
|
+
if ((0, types_1.isFunction)(boundMethodResult.type) || (0, types_1.isOverloaded)(boundMethodResult.type)) {
|
1488
1502
|
return boundMethodResult.type;
|
1489
1503
|
}
|
1490
1504
|
if ((0, types_1.isClassInstance)(boundMethodResult.type)) {
|
@@ -1557,7 +1571,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1557
1571
|
addOneFunctionToSignature(type);
|
1558
1572
|
}
|
1559
1573
|
else {
|
1560
|
-
types_1.
|
1574
|
+
types_1.OverloadedType.getOverloads(type).forEach((func) => {
|
1561
1575
|
addOneFunctionToSignature(func);
|
1562
1576
|
});
|
1563
1577
|
}
|
@@ -1565,7 +1579,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1565
1579
|
(0, typeUtils_1.doForEachSubtype)(callType, (subtype) => {
|
1566
1580
|
switch (subtype.category) {
|
1567
1581
|
case 4 /* TypeCategory.Function */:
|
1568
|
-
case 5 /* TypeCategory.
|
1582
|
+
case 5 /* TypeCategory.Overloaded */: {
|
1569
1583
|
addFunctionToSignature(subtype);
|
1570
1584
|
break;
|
1571
1585
|
}
|
@@ -1574,7 +1588,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1574
1588
|
const constructorType = (0, constructors_1.createFunctionFromConstructor)(evaluatorInterface, subtype);
|
1575
1589
|
if (constructorType) {
|
1576
1590
|
(0, typeUtils_1.doForEachSubtype)(constructorType, (subtype) => {
|
1577
|
-
if ((0, types_1.isFunction)(subtype) || (0, types_1.
|
1591
|
+
if ((0, types_1.isFunction)(subtype) || (0, types_1.isOverloaded)(subtype)) {
|
1578
1592
|
addFunctionToSignature(subtype);
|
1579
1593
|
}
|
1580
1594
|
});
|
@@ -1629,7 +1643,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1629
1643
|
}
|
1630
1644
|
const kwSeparatorIndex = functionType.shared.parameters.findIndex((param) => param.category === 1 /* ParamCategory.ArgsList */);
|
1631
1645
|
// Add a keyword separator if necessary.
|
1632
|
-
if (kwSeparatorIndex < 0) {
|
1646
|
+
if (kwSeparatorIndex < 0 && tdEntries.size > 0) {
|
1633
1647
|
types_1.FunctionType.addKeywordOnlyParamSeparator(newFunction);
|
1634
1648
|
}
|
1635
1649
|
tdEntries.forEach((tdEntry, name) => {
|
@@ -1747,7 +1761,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
1747
1761
|
if (memberAccessClass && (0, types_1.isInstantiableClass)(memberAccessClass)) {
|
1748
1762
|
declaredType = (0, typeUtils_1.partiallySpecializeType)(declaredType, memberAccessClass, getTypeClassType());
|
1749
1763
|
}
|
1750
|
-
if ((0, types_1.isFunction)(declaredType) || (0, types_1.
|
1764
|
+
if ((0, types_1.isFunction)(declaredType) || (0, types_1.isOverloaded)(declaredType)) {
|
1751
1765
|
if (bindFunction) {
|
1752
1766
|
declaredType = bindFunctionToClassOrObject(classOrObjectBase, declaredType);
|
1753
1767
|
}
|
@@ -2726,6 +2740,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
2726
2740
|
if (variance !== 3 /* Variance.Covariant */) {
|
2727
2741
|
return typeArg;
|
2728
2742
|
}
|
2743
|
+
// Don't expand recursive type aliases because they can
|
2744
|
+
// cause infinite recursion.
|
2745
|
+
if ((0, types_1.isTypeVar)(typeArg) && typeArg.shared.recursiveAlias) {
|
2746
|
+
return typeArg;
|
2747
|
+
}
|
2729
2748
|
const filteredTypeArg = mapSubtypesExpandTypeVars(typeArg, { conditionFilter }, (expandedSubtype) => {
|
2730
2749
|
return expandedSubtype;
|
2731
2750
|
}, recursionCount);
|
@@ -3392,7 +3411,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3392
3411
|
}
|
3393
3412
|
else if ((0, types_1.isTypeVarTuple)(param) && tupleClass && (0, types_1.isInstantiableClass)(tupleClass)) {
|
3394
3413
|
defaultType = makeTupleObject([{ type: types_1.UnknownType.create(), isUnbounded: true }],
|
3395
|
-
/*
|
3414
|
+
/* isUnpacked */ true);
|
3396
3415
|
}
|
3397
3416
|
else {
|
3398
3417
|
defaultType = types_1.UnknownType.create();
|
@@ -3771,12 +3790,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3771
3790
|
if (usage.method === 'get') {
|
3772
3791
|
const getAttrSymbol = types_1.ModuleType.getField(baseType, '__getattr__');
|
3773
3792
|
if (getAttrSymbol) {
|
3774
|
-
const isModuleGetAttrSupported = fileInfo.executionEnvironment.pythonVersion
|
3775
|
-
getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi'));
|
3793
|
+
const isModuleGetAttrSupported = pythonVersion_1.PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_7) || getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi'));
|
3776
3794
|
if (isModuleGetAttrSupported) {
|
3777
3795
|
const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol);
|
3778
3796
|
if ((0, types_1.isFunction)(getAttrTypeResult.type)) {
|
3779
|
-
type =
|
3797
|
+
type = getEffectiveReturnType(getAttrTypeResult.type);
|
3780
3798
|
if (getAttrTypeResult.isIncomplete) {
|
3781
3799
|
isIncomplete = true;
|
3782
3800
|
}
|
@@ -3841,12 +3859,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3841
3859
|
break;
|
3842
3860
|
}
|
3843
3861
|
case 4 /* TypeCategory.Function */:
|
3844
|
-
case 5 /* TypeCategory.
|
3862
|
+
case 5 /* TypeCategory.Overloaded */: {
|
3845
3863
|
if (memberName === '__self__') {
|
3846
3864
|
// The "__self__" member is not currently defined in the "function"
|
3847
3865
|
// class, so we'll special-case it here.
|
3848
|
-
|
3849
|
-
if (
|
3866
|
+
let functionType;
|
3867
|
+
if ((0, types_1.isFunction)(baseType)) {
|
3868
|
+
functionType = baseType;
|
3869
|
+
}
|
3870
|
+
else {
|
3871
|
+
const overloads = types_1.OverloadedType.getOverloads(baseType);
|
3872
|
+
if (overloads.length > 0) {
|
3873
|
+
functionType = overloads[0];
|
3874
|
+
}
|
3875
|
+
}
|
3876
|
+
if (functionType &&
|
3877
|
+
functionType.priv.preBoundFlags !== undefined &&
|
3850
3878
|
(functionType.priv.preBoundFlags & 4 /* FunctionTypeFlags.StaticMethod */) === 0) {
|
3851
3879
|
type = functionType.priv.boundToType;
|
3852
3880
|
}
|
@@ -3863,7 +3891,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3863
3891
|
// member could not be accessed.
|
3864
3892
|
if (!type) {
|
3865
3893
|
const isFunctionRule = (0, types_1.isFunction)(baseType) ||
|
3866
|
-
(0, types_1.
|
3894
|
+
(0, types_1.isOverloaded)(baseType) ||
|
3867
3895
|
((0, types_1.isClassInstance)(baseType) && types_1.ClassType.isBuiltIn(baseType, 'function'));
|
3868
3896
|
if (!baseTypeResult.isIncomplete) {
|
3869
3897
|
let diagMessage = localize_1.LocMessage.memberAccess();
|
@@ -4058,7 +4086,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4058
4086
|
}
|
4059
4087
|
resultType = descResult.type;
|
4060
4088
|
}
|
4061
|
-
else if ((0, types_1.isFunction)(concreteSubtype) || (0, types_1.
|
4089
|
+
else if ((0, types_1.isFunction)(concreteSubtype) || (0, types_1.isOverloaded)(concreteSubtype)) {
|
4062
4090
|
const typeResult = bindMethodForMemberAccess(subtype, concreteSubtype, memberInfo, classType, selfType, flags, memberName, usage, diag, recursionCount);
|
4063
4091
|
resultType = typeResult.type;
|
4064
4092
|
if (typeResult.typeErrors) {
|
@@ -4184,7 +4212,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4184
4212
|
if (methodTypeResult.typeErrors || !methodClassType) {
|
4185
4213
|
return { type: types_1.UnknownType.create(), typeErrors: true };
|
4186
4214
|
}
|
4187
|
-
if (!(0, types_1.isFunction)(methodType) && !(0, types_1.
|
4215
|
+
if (!(0, types_1.isFunction)(methodType) && !(0, types_1.isOverloaded)(methodType)) {
|
4188
4216
|
if ((0, types_1.isAnyOrUnknown)(methodType)) {
|
4189
4217
|
return { type: methodType };
|
4190
4218
|
}
|
@@ -4228,7 +4256,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4228
4256
|
/* diag */ undefined, constraints);
|
4229
4257
|
accessMethodClass = solveAndApplyConstraints(accessMethodClass, constraints);
|
4230
4258
|
const specializedType = (0, typeUtils_1.partiallySpecializeType)(methodType, accessMethodClass, getTypeClassType(), selfType ? (0, typeUtils_1.convertToInstantiable)(selfType) : classType);
|
4231
|
-
if ((0, types_1.isFunction)(specializedType) || (0, types_1.
|
4259
|
+
if ((0, types_1.isFunction)(specializedType) || (0, types_1.isOverloaded)(specializedType)) {
|
4232
4260
|
methodType = specializedType;
|
4233
4261
|
}
|
4234
4262
|
}
|
@@ -4342,10 +4370,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4342
4370
|
function bindMethodForMemberAccess(type, concreteType, memberInfo, classType, selfType, flags, memberName, usage, diag, recursionCount = 0) {
|
4343
4371
|
// Check for an attempt to overwrite a final method.
|
4344
4372
|
if (usage.method === 'set') {
|
4345
|
-
const impl = (0, types_1.isFunction)(concreteType)
|
4346
|
-
|
4347
|
-
: types_1.OverloadedFunctionType.getImplementation(concreteType);
|
4348
|
-
if (impl && types_1.FunctionType.isFinal(impl) && memberInfo && (0, types_1.isClass)(memberInfo.classType)) {
|
4373
|
+
const impl = (0, types_1.isFunction)(concreteType) ? concreteType : types_1.OverloadedType.getImplementation(concreteType);
|
4374
|
+
if (impl && (0, types_1.isFunction)(impl) && types_1.FunctionType.isFinal(impl) && memberInfo && (0, types_1.isClass)(memberInfo.classType)) {
|
4349
4375
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocMessage.finalMethodOverride().format({
|
4350
4376
|
name: memberName,
|
4351
4377
|
className: memberInfo.classType.shared.name,
|
@@ -4474,7 +4500,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4474
4500
|
},
|
4475
4501
|
});
|
4476
4502
|
}
|
4477
|
-
if (!(0, types_1.isFunction)(accessMemberType) && !(0, types_1.
|
4503
|
+
if (!(0, types_1.isFunction)(accessMemberType) && !(0, types_1.isOverloaded)(accessMemberType)) {
|
4478
4504
|
if ((0, types_1.isAnyOrUnknown)(accessMemberType)) {
|
4479
4505
|
return { type: accessMemberType };
|
4480
4506
|
}
|
@@ -4524,7 +4550,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4524
4550
|
!baseTypeResult.type.priv.aliasName) {
|
4525
4551
|
const minPythonVersion = nonSubscriptableBuiltinTypes.get(baseTypeResult.type.shared.fullName);
|
4526
4552
|
if (minPythonVersion !== undefined &&
|
4527
|
-
fileInfo.executionEnvironment.pythonVersion
|
4553
|
+
pythonVersion_1.PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, minPythonVersion) &&
|
4528
4554
|
!fileInfo.isStubFile) {
|
4529
4555
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIndexIssue, localize_1.LocMessage.classNotRuntimeSubscriptable().format({
|
4530
4556
|
name: baseTypeResult.type.priv.aliasName || baseTypeResult.type.shared.name,
|
@@ -4661,7 +4687,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4661
4687
|
}
|
4662
4688
|
});
|
4663
4689
|
}
|
4664
|
-
const tupleObject = makeTupleObject(variadicTypes, /*
|
4690
|
+
const tupleObject = makeTupleObject(variadicTypes, /* isUnpacked */ true);
|
4665
4691
|
typeArgs = [
|
4666
4692
|
...typeArgs.slice(0, variadicIndex),
|
4667
4693
|
{ node: typeArgs[variadicIndex].node, type: tupleObject },
|
@@ -4673,7 +4699,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4673
4699
|
// Add an empty tuple that maps to the TypeVarTuple type parameter.
|
4674
4700
|
typeArgs.push({
|
4675
4701
|
node: errorNode,
|
4676
|
-
type: makeTupleObject([], /*
|
4702
|
+
type: makeTupleObject([], /* isUnpacked */ true),
|
4677
4703
|
});
|
4678
4704
|
}
|
4679
4705
|
}
|
@@ -4717,7 +4743,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4717
4743
|
typeArgs = [
|
4718
4744
|
{
|
4719
4745
|
type: types_1.UnknownType.create(),
|
4720
|
-
node: typeArgs[0].node,
|
4746
|
+
node: typeArgs.length > 0 ? typeArgs[0].node : node,
|
4721
4747
|
typeList: typeArgs,
|
4722
4748
|
},
|
4723
4749
|
];
|
@@ -5122,9 +5148,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5122
5148
|
}
|
5123
5149
|
});
|
5124
5150
|
}
|
5125
|
-
function makeTupleObject(typeArgs,
|
5151
|
+
function makeTupleObject(typeArgs, isUnpacked = false) {
|
5126
5152
|
if (tupleClass && (0, types_1.isInstantiableClass)(tupleClass)) {
|
5127
|
-
return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClass, typeArgs, /* isTypeArgExplicit */ true,
|
5153
|
+
return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClass, typeArgs, /* isTypeArgExplicit */ true, isUnpacked));
|
5128
5154
|
}
|
5129
5155
|
return types_1.UnknownType.create();
|
5130
5156
|
}
|
@@ -5288,23 +5314,28 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5288
5314
|
function getTypeArgs(node, flags, options) {
|
5289
5315
|
const typeArgs = [];
|
5290
5316
|
let adjFlags = flags | 33554432 /* EvalFlags.NoConvertSpecialForm */;
|
5291
|
-
|
5292
|
-
adjFlags |= 131072 /* EvalFlags.NoClassVar */ | 16 /* EvalFlags.NoFinal */;
|
5293
|
-
}
|
5294
|
-
else if (options === null || options === void 0 ? void 0 : options.isClassVarAnnotation) {
|
5295
|
-
adjFlags |= 131072 /* EvalFlags.NoClassVar */;
|
5317
|
+
const allowFinalClassVar = () => {
|
5296
5318
|
// If the annotation is a variable within the body of a dataclass, a
|
5297
|
-
// Final is allowed
|
5319
|
+
// Final is allowed with a ClassVar annotation. In all other cases,
|
5298
5320
|
// it's disallowed.
|
5299
|
-
let disallowFinal = true;
|
5300
5321
|
const enclosingClassNode = ParseTreeUtils.getEnclosingClass(node, /* stopeAtFunction */ true);
|
5301
5322
|
if (enclosingClassNode) {
|
5302
5323
|
const classTypeInfo = getTypeOfClass(enclosingClassNode);
|
5303
5324
|
if (classTypeInfo && types_1.ClassType.isDataClass(classTypeInfo.classType)) {
|
5304
|
-
|
5325
|
+
return true;
|
5305
5326
|
}
|
5306
5327
|
}
|
5307
|
-
|
5328
|
+
return false;
|
5329
|
+
};
|
5330
|
+
if (options === null || options === void 0 ? void 0 : options.isFinalAnnotation) {
|
5331
|
+
adjFlags |= 16 /* EvalFlags.NoFinal */;
|
5332
|
+
if (!allowFinalClassVar()) {
|
5333
|
+
adjFlags |= 131072 /* EvalFlags.NoClassVar */;
|
5334
|
+
}
|
5335
|
+
}
|
5336
|
+
else if (options === null || options === void 0 ? void 0 : options.isClassVarAnnotation) {
|
5337
|
+
adjFlags |= 131072 /* EvalFlags.NoClassVar */;
|
5338
|
+
if (!allowFinalClassVar()) {
|
5308
5339
|
adjFlags |= 16 /* EvalFlags.NoFinal */;
|
5309
5340
|
}
|
5310
5341
|
}
|
@@ -6334,7 +6365,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6334
6365
|
const speculativeNode = getSpeculativeNodeForCall(errorNode);
|
6335
6366
|
useSignatureTracker(errorNode, () => {
|
6336
6367
|
// Create a list of potential overload matches based on arguments.
|
6337
|
-
types_1.
|
6368
|
+
types_1.OverloadedType.getOverloads(typeResult.type).forEach((overload) => {
|
6338
6369
|
useSpeculativeMode(speculativeNode, () => {
|
6339
6370
|
const matchResults = matchArgsToParams(errorNode, argList, { type: overload, isIncomplete: typeResult.isIncomplete }, overloadIndex);
|
6340
6371
|
if (!matchResults.argumentErrors) {
|
@@ -6381,7 +6412,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6381
6412
|
// cache or record any diagnostics at this stage.
|
6382
6413
|
useSpeculativeMode(speculativeNode, () => {
|
6383
6414
|
let overloadIndex = 0;
|
6384
|
-
types_1.
|
6415
|
+
types_1.OverloadedType.getOverloads(type).forEach((overload) => {
|
6385
6416
|
// Consider only the functions that have the @overload decorator,
|
6386
6417
|
// not the final function that omits the overload. This is the
|
6387
6418
|
// intended behavior according to PEP 484.
|
@@ -6399,7 +6430,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6399
6430
|
// Skip the error message if we're in speculative mode because it's very
|
6400
6431
|
// expensive, and we're going to suppress the diagnostic anyway.
|
6401
6432
|
if (!canSkipDiagnosticForNode(errorNode)) {
|
6402
|
-
const
|
6433
|
+
const overloads = types_1.OverloadedType.getOverloads(type);
|
6434
|
+
const functionName = overloads.length > 0 && overloads[0].shared.name
|
6435
|
+
? overloads[0].shared.name
|
6436
|
+
: '<anonymous function>';
|
6403
6437
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
6404
6438
|
const argTypes = argList.map((t) => {
|
6405
6439
|
const typeString = printType(getTypeOfArg(t, /* inferenceContext */ undefined).type);
|
@@ -6620,8 +6654,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6620
6654
|
case 4 /* TypeCategory.Function */: {
|
6621
6655
|
return validateCallForFunction(errorNode, argList, expandedCallType, isCallTypeIncomplete, constraints, skipUnknownArgCheck, inferenceContext);
|
6622
6656
|
}
|
6623
|
-
case 5 /* TypeCategory.
|
6624
|
-
return
|
6657
|
+
case 5 /* TypeCategory.Overloaded */: {
|
6658
|
+
return validateCallForOverloaded(errorNode, argList, expandedCallType, isCallTypeIncomplete, constraints, skipUnknownArgCheck, inferenceContext);
|
6625
6659
|
}
|
6626
6660
|
case 6 /* TypeCategory.Class */: {
|
6627
6661
|
if ((0, typeUtils_1.isNoneInstance)(expandedCallType)) {
|
@@ -6776,10 +6810,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6776
6810
|
}
|
6777
6811
|
return { symbol, symbolName, classType, hasImplementation };
|
6778
6812
|
}
|
6779
|
-
function
|
6813
|
+
function validateCallForOverloaded(errorNode, argList, expandedCallType, isCallTypeIncomplete, constraints, skipUnknownArgCheck, inferenceContext) {
|
6780
6814
|
var _a, _b;
|
6815
|
+
const overloads = types_1.OverloadedType.getOverloads(expandedCallType);
|
6781
6816
|
// Handle the 'cast' call as a special case.
|
6782
|
-
if (
|
6817
|
+
if (overloads.length > 0 &&
|
6818
|
+
types_1.FunctionType.isBuiltIn(overloads[0], ['typing.cast', 'typing_extensions.cast']) &&
|
6819
|
+
argList.length === 2) {
|
6783
6820
|
return { returnType: evaluateCastCall(argList, errorNode) };
|
6784
6821
|
}
|
6785
6822
|
const callResult = validateOverloadedArgTypes(errorNode, argList, { type: expandedCallType, isIncomplete: isCallTypeIncomplete }, constraints, skipUnknownArgCheck, inferenceContext);
|
@@ -6890,7 +6927,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6890
6927
|
};
|
6891
6928
|
const initTypeResult = (0, constructors_1.getBoundInitMethod)(evaluatorInterface, errorNode, types_1.ClassType.cloneAsInstance(expandedCallType),
|
6892
6929
|
/* diag */ undefined, 0 /* MemberAccessFlags.Default */);
|
6893
|
-
if (initTypeResult && (0, types_1.
|
6930
|
+
if (initTypeResult && (0, types_1.isOverloaded)(initTypeResult.type)) {
|
6894
6931
|
validateOverloadedArgTypes(errorNode, argList, { type: initTypeResult.type },
|
6895
6932
|
/* constraints */ undefined, skipUnknownArgCheck,
|
6896
6933
|
/* inferenceContext */ undefined);
|
@@ -7159,7 +7196,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7159
7196
|
}
|
7160
7197
|
else {
|
7161
7198
|
positionalOnlyLimitIndex = varArgListParamIndex;
|
7162
|
-
positionalArgCount = varArgListParamIndex;
|
7199
|
+
positionalArgCount = Math.min(varArgListParamIndex, positionalArgCount);
|
7163
7200
|
positionParamLimitIndex = varArgListParamIndex;
|
7164
7201
|
}
|
7165
7202
|
}
|
@@ -7240,6 +7277,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7240
7277
|
argType.priv.tupleTypeArgs.length > 0) {
|
7241
7278
|
tooManyPositionals = true;
|
7242
7279
|
}
|
7280
|
+
else {
|
7281
|
+
matchedUnpackedListOfUnknownLength = true;
|
7282
|
+
}
|
7243
7283
|
}
|
7244
7284
|
else {
|
7245
7285
|
tooManyPositionals = true;
|
@@ -7495,7 +7535,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7495
7535
|
}
|
7496
7536
|
}
|
7497
7537
|
if (!reportedArgError) {
|
7498
|
-
let
|
7538
|
+
let unpackedDictKeyNames;
|
7539
|
+
let unpackedDictArgType;
|
7499
7540
|
// Now consume any keyword arguments.
|
7500
7541
|
while (argIndex < argList.length) {
|
7501
7542
|
if (argList[argIndex].argCategory === 2 /* ArgCategory.UnpackedDictionary */) {
|
@@ -7506,7 +7547,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7506
7547
|
isTypeIncomplete = true;
|
7507
7548
|
}
|
7508
7549
|
if ((0, types_1.isAnyOrUnknown)(argType)) {
|
7509
|
-
|
7550
|
+
unpackedDictArgType = argType;
|
7510
7551
|
}
|
7511
7552
|
else if ((0, types_1.isClassInstance)(argType) && types_1.ClassType.isTypedDictClass(argType)) {
|
7512
7553
|
// Handle the special case where it is a TypedDict and we know which
|
@@ -7575,7 +7616,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7575
7616
|
}
|
7576
7617
|
}
|
7577
7618
|
else if (paramSpec && (0, parameterUtils_1.isParamSpecKwargs)(paramSpec, argType)) {
|
7578
|
-
|
7619
|
+
unpackedDictArgType = types_1.AnyType.create();
|
7579
7620
|
if (!paramSpecArgList) {
|
7580
7621
|
validateArgTypeParams.push({
|
7581
7622
|
paramCategory: 2 /* ParamCategory.KwargsDict */,
|
@@ -7608,20 +7649,29 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7608
7649
|
if (assignType(strObjType, typeArgs[0])) {
|
7609
7650
|
isValidMappingType = true;
|
7610
7651
|
}
|
7611
|
-
|
7652
|
+
unpackedDictKeyNames = [];
|
7653
|
+
(0, typeUtils_1.doForEachSubtype)(typeArgs[0], (keyType) => {
|
7654
|
+
if ((0, types_1.isClassInstance)(keyType) && typeof keyType.priv.literalValue === 'string') {
|
7655
|
+
unpackedDictKeyNames === null || unpackedDictKeyNames === void 0 ? void 0 : unpackedDictKeyNames.push(keyType.priv.literalValue);
|
7656
|
+
}
|
7657
|
+
else {
|
7658
|
+
unpackedDictKeyNames = undefined;
|
7659
|
+
}
|
7660
|
+
});
|
7661
|
+
unpackedDictArgType = typeArgs[1];
|
7612
7662
|
}
|
7613
7663
|
else {
|
7614
7664
|
isValidMappingType = true;
|
7615
|
-
|
7665
|
+
unpackedDictArgType = types_1.UnknownType.create();
|
7616
7666
|
}
|
7617
7667
|
}
|
7618
|
-
if (paramDetails.kwargsIndex !== undefined &&
|
7668
|
+
if (paramDetails.kwargsIndex !== undefined && unpackedDictArgType) {
|
7619
7669
|
const paramType = paramDetails.params[paramDetails.kwargsIndex].type;
|
7620
7670
|
validateArgTypeParams.push({
|
7621
7671
|
paramCategory: 0 /* ParamCategory.Simple */,
|
7622
7672
|
paramType,
|
7623
7673
|
requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
|
7624
|
-
argType:
|
7674
|
+
argType: unpackedDictArgType,
|
7625
7675
|
argument: argList[argIndex],
|
7626
7676
|
errorNode: argList[argIndex].valueExpression || errorNode,
|
7627
7677
|
paramName: paramDetails.params[paramDetails.kwargsIndex].param.name,
|
@@ -7748,7 +7798,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7748
7798
|
}
|
7749
7799
|
// If there are keyword-only parameters that haven't been matched but we
|
7750
7800
|
// have an unpacked dictionary arg, assume that it applies to them.
|
7751
|
-
if (
|
7801
|
+
if (unpackedDictArgType && (!foundUnpackedListArg || paramDetails.argsIndex !== undefined)) {
|
7752
7802
|
// Don't consider any position-only parameters, since they cannot be matched to
|
7753
7803
|
// **kwargs arguments. Consider parameters that are either positional or keyword
|
7754
7804
|
// if there is no *args argument.
|
@@ -7761,19 +7811,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7761
7811
|
paramMap.has(param.name) &&
|
7762
7812
|
paramMap.get(param.name).argsReceived === 0) {
|
7763
7813
|
const paramType = paramDetails.params[paramIndex].type;
|
7764
|
-
|
7765
|
-
|
7766
|
-
|
7767
|
-
|
7768
|
-
|
7769
|
-
|
7770
|
-
|
7771
|
-
|
7772
|
-
|
7773
|
-
|
7774
|
-
|
7775
|
-
|
7776
|
-
|
7814
|
+
if (!unpackedDictKeyNames || unpackedDictKeyNames.includes(param.name)) {
|
7815
|
+
validateArgTypeParams.push({
|
7816
|
+
paramCategory: 0 /* ParamCategory.Simple */,
|
7817
|
+
paramType,
|
7818
|
+
requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
|
7819
|
+
argument: {
|
7820
|
+
argCategory: 0 /* ArgCategory.Simple */,
|
7821
|
+
typeResult: { type: unpackedDictArgType },
|
7822
|
+
},
|
7823
|
+
errorNode: (_b = (_a = argList.find((arg) => arg.argCategory === 2 /* ArgCategory.UnpackedDictionary */)) === null || _a === void 0 ? void 0 : _a.valueExpression) !== null && _b !== void 0 ? _b : errorNode,
|
7824
|
+
paramName: param.name,
|
7825
|
+
isParamNameSynthesized: types_1.FunctionParam.isNameSynthesized(param),
|
7826
|
+
});
|
7827
|
+
paramMap.get(param.name).argsReceived = 1;
|
7828
|
+
}
|
7777
7829
|
}
|
7778
7830
|
});
|
7779
7831
|
}
|
@@ -7781,7 +7833,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7781
7833
|
// but have not yet received them. If we received a dictionary argument
|
7782
7834
|
// (i.e. an arg starting with a "**"), we will assume that all parameters
|
7783
7835
|
// are matched.
|
7784
|
-
if (!
|
7836
|
+
if (!unpackedDictArgType && !types_1.FunctionType.isDefaultParamCheckDisabled(overload)) {
|
7785
7837
|
const unassignedParams = Array.from(paramMap.keys()).filter((name) => {
|
7786
7838
|
const entry = paramMap.get(name);
|
7787
7839
|
return !entry || entry.argsReceived < entry.argsNeeded;
|
@@ -7878,7 +7930,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7878
7930
|
specializedTuple = tupleTypeArgs[0].type;
|
7879
7931
|
}
|
7880
7932
|
else {
|
7881
|
-
specializedTuple = makeTupleObject(tupleTypeArgs, /*
|
7933
|
+
specializedTuple = makeTupleObject(tupleTypeArgs, /* isUnpacked */ true);
|
7882
7934
|
}
|
7883
7935
|
const combinedArg = {
|
7884
7936
|
paramCategory: 1 /* ParamCategory.ArgsList */,
|
@@ -7933,7 +7985,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7933
7985
|
let expectedType = inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.expectedType;
|
7934
7986
|
// Can we safely ignore the inference context, either because it's not provided
|
7935
7987
|
// or will have no effect? If so, avoid the extra work.
|
7936
|
-
const returnType = (_a = inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnTypeOverride) !== null && _a !== void 0 ? _a :
|
7988
|
+
const returnType = (_a = inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnTypeOverride) !== null && _a !== void 0 ? _a : getEffectiveReturnType(type);
|
7937
7989
|
if (!returnType || !(0, typeUtils_1.requiresSpecialization)(returnType)) {
|
7938
7990
|
expectedType = undefined;
|
7939
7991
|
}
|
@@ -7950,8 +8002,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7950
8002
|
: callResult.returnType;
|
7951
8003
|
if (assignType(expectedSubtype, returnType,
|
7952
8004
|
/* diag */ undefined,
|
7953
|
-
/*
|
7954
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
8005
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
7955
8006
|
const anyOrUnknown = (0, typeUtils_1.containsAnyOrUnknown)(callResult.returnType, /* recurse */ true);
|
7956
8007
|
// Prefer return types that have no unknown or Any.
|
7957
8008
|
if (!anyOrUnknown) {
|
@@ -8003,7 +8054,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8003
8054
|
}
|
8004
8055
|
function validateArgTypesWithExpectedType(errorNode, matchResults, constraints, skipUnknownArgCheck = false, expectedType, returnType) {
|
8005
8056
|
const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(errorNode);
|
8006
|
-
let assignFlags = 2048 /* AssignTypeFlags.
|
8057
|
+
let assignFlags = 2048 /* AssignTypeFlags.PopulateExpectedType */;
|
8007
8058
|
if ((0, typeUtils_1.containsLiteralType)(expectedType, /* includeTypeArgs */ true)) {
|
8008
8059
|
assignFlags |= 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
8009
8060
|
}
|
@@ -8026,9 +8077,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8026
8077
|
}
|
8027
8078
|
}
|
8028
8079
|
expectedType = (0, typeUtils_1.transformExpectedType)(expectedType, liveTypeVarScopes, errorNode.start);
|
8029
|
-
assignType(returnType, expectedType,
|
8030
|
-
/* diag */ undefined, constraints,
|
8031
|
-
/* srcConstraints */ undefined, assignFlags);
|
8080
|
+
assignType(returnType, expectedType, /* diag */ undefined, constraints, assignFlags);
|
8032
8081
|
return validateArgTypes(errorNode, matchResults, constraints, skipUnknownArgCheck);
|
8033
8082
|
}
|
8034
8083
|
function validateArgTypes(errorNode, matchResults, constraints, skipUnknownArgCheck) {
|
@@ -8072,38 +8121,28 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8072
8121
|
}
|
8073
8122
|
// Special-case a few built-in calls that are often used for
|
8074
8123
|
// casting or checking for unknown types.
|
8075
|
-
if (types_1.FunctionType.isBuiltIn(type, [
|
8124
|
+
if (types_1.FunctionType.isBuiltIn(type, [
|
8125
|
+
'typing.cast',
|
8126
|
+
'typing_extensions.cast',
|
8127
|
+
'builtins.isinstance',
|
8128
|
+
'builtins.issubclass',
|
8129
|
+
])) {
|
8076
8130
|
skipUnknownArgCheck = true;
|
8077
8131
|
}
|
8078
8132
|
// Run through all args and validate them against their matched parameter.
|
8079
|
-
// We'll do two
|
8080
|
-
//
|
8081
|
-
// are no type vars to
|
8082
|
-
const
|
8083
|
-
if (
|
8084
|
-
//
|
8085
|
-
|
8086
|
-
// can provide bidirectional type hints for earlier matches. The best
|
8087
|
-
// example of this is the built-in "map" method whose first parameter is
|
8088
|
-
// a lambda and second parameter indicates what type the lambda should accept.
|
8089
|
-
// In practice, we will limit the number of passes to 2 because it can get
|
8090
|
-
// very expensive to go beyond this, and we don't generally see cases
|
8091
|
-
// where more than two passes are needed.
|
8092
|
-
let passCount = Math.min(typeVarMatchingCount, 2);
|
8133
|
+
// We'll do two phases. The first one establishes constraints for type
|
8134
|
+
// variables. The second perform type validation using the solved
|
8135
|
+
// types. We can skip the first pass if there are no type vars to solve.
|
8136
|
+
const typeVarCount = matchResults.argParams.filter((arg) => arg.requiresTypeVarMatching).length;
|
8137
|
+
if (typeVarCount > 0) {
|
8138
|
+
// Do up to two passes.
|
8139
|
+
let passCount = Math.min(typeVarCount, 2);
|
8093
8140
|
for (let i = 0; i < passCount; i++) {
|
8094
8141
|
useSpeculativeMode(speculativeNode, () => {
|
8095
8142
|
matchResults.argParams.forEach((argParam) => {
|
8096
8143
|
if (!argParam.requiresTypeVarMatching) {
|
8097
8144
|
return;
|
8098
8145
|
}
|
8099
|
-
// Populate the constraints for the argument. If the argument
|
8100
|
-
// is an overload function, skip it during the first pass
|
8101
|
-
// because the selection of the proper overload may depend
|
8102
|
-
// on type arguments supplied by other function arguments.
|
8103
|
-
// If the param type is a "bare" TypeVar, don't use it as an
|
8104
|
-
// expected type during the first pass. This causes problems for
|
8105
|
-
// cases where the the call expression result can influence the
|
8106
|
-
// type of the TypeVar, such as in the expression "min(1, max(2, 0.5))".
|
8107
8146
|
const argResult = validateArgType(argParam, constraints, { type, isIncomplete: matchResults.isTypeIncomplete }, {
|
8108
8147
|
skipUnknownArgCheck,
|
8109
8148
|
isArgFirstPass: passCount > 1 && i === 0,
|
@@ -8113,9 +8152,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8113
8152
|
if (argResult.isTypeIncomplete) {
|
8114
8153
|
isTypeIncomplete = true;
|
8115
8154
|
}
|
8116
|
-
// If we skipped
|
8117
|
-
//
|
8118
|
-
if (i === 0 &&
|
8155
|
+
// If we skipped a bare type var during the first pass, add
|
8156
|
+
// another pass to ensure that we handle all of the type variables.
|
8157
|
+
if (i === 0 && passCount < 2 && argResult.skippedBareTypeVarExpectedType) {
|
8119
8158
|
passCount++;
|
8120
8159
|
}
|
8121
8160
|
});
|
@@ -8187,7 +8226,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8187
8226
|
}
|
8188
8227
|
}
|
8189
8228
|
// Calculate the return type.
|
8190
|
-
let returnType =
|
8229
|
+
let returnType = getEffectiveReturnType(type, {
|
8230
|
+
callSiteInfo: { args: matchResults.argParams, errorNode },
|
8231
|
+
});
|
8191
8232
|
if (condition.length > 0) {
|
8192
8233
|
returnType = types_1.TypeBase.cloneForCondition(returnType, condition);
|
8193
8234
|
}
|
@@ -8195,7 +8236,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8195
8236
|
// If the function is returning a callable, don't eliminate unsolved
|
8196
8237
|
// type vars within a union. There are legit uses for unsolved type vars
|
8197
8238
|
// within a callable.
|
8198
|
-
if ((0, types_1.isFunction)(returnType) || (0, types_1.
|
8239
|
+
if ((0, types_1.isFunction)(returnType) || (0, types_1.isOverloaded)(returnType)) {
|
8199
8240
|
eliminateUnsolvedInUnions = false;
|
8200
8241
|
}
|
8201
8242
|
let specializedReturnType = solveAndApplyConstraints(returnType, constraints, {
|
@@ -8205,7 +8246,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8205
8246
|
tupleClassType: getTupleClassType(),
|
8206
8247
|
eliminateUnsolvedInUnions,
|
8207
8248
|
},
|
8208
|
-
}
|
8249
|
+
});
|
8209
8250
|
specializedReturnType = (0, typeUtils_1.addConditionToType)(specializedReturnType, typeCondition);
|
8210
8251
|
// If the function includes a ParamSpec and the captured signature(s) includes
|
8211
8252
|
// generic types, we may need to apply those solved TypeVars.
|
@@ -8216,16 +8257,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8216
8257
|
// It's possible that one or more of the TypeVars or ParamSpecs
|
8217
8258
|
// in the constraints refer to TypeVars that were solved in
|
8218
8259
|
// the paramSpecConstraints. Apply these solved TypeVars accordingly.
|
8219
|
-
(0,
|
8260
|
+
(0, constraintSolver_1.applySourceSolutionToConstraints)(constraints, (0, constraintSolver_1.solveConstraints)(evaluatorInterface, paramSpecConstraints));
|
8220
8261
|
}
|
8221
8262
|
});
|
8222
8263
|
}
|
8223
8264
|
// If the final return type is an unpacked tuple, turn it into a normal (unpacked) tuple.
|
8224
8265
|
if ((0, types_1.isUnpackedClass)(specializedReturnType)) {
|
8225
|
-
specializedReturnType = types_1.ClassType.cloneForUnpacked(specializedReturnType, /*
|
8266
|
+
specializedReturnType = types_1.ClassType.cloneForUnpacked(specializedReturnType, /* isUnpacked */ false);
|
8226
8267
|
}
|
8227
8268
|
const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(errorNode);
|
8228
|
-
specializedReturnType = adjustCallableReturnType(
|
8269
|
+
specializedReturnType = adjustCallableReturnType(errorNode, specializedReturnType, liveTypeVarScopes);
|
8229
8270
|
if (specializedInitSelfType) {
|
8230
8271
|
specializedInitSelfType = solveAndApplyConstraints(specializedInitSelfType, constraints);
|
8231
8272
|
}
|
@@ -8272,20 +8313,30 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8272
8313
|
// to allow these type vars to be solved. This won't work with overloads
|
8273
8314
|
// or unions of callables. It's intended for a specific use case. We may
|
8274
8315
|
// need to make this more sophisticated in the future.
|
8275
|
-
function adjustCallableReturnType(
|
8276
|
-
|
8277
|
-
|
8278
|
-
|
8279
|
-
|
8280
|
-
|
8281
|
-
|
8282
|
-
|
8283
|
-
|
8284
|
-
|
8285
|
-
|
8286
|
-
|
8287
|
-
|
8288
|
-
|
8316
|
+
function adjustCallableReturnType(callNode, returnType, liveTypeVarScopes) {
|
8317
|
+
if (!(0, types_1.isFunction)(returnType)) {
|
8318
|
+
return returnType;
|
8319
|
+
}
|
8320
|
+
// What type variables are referenced in the callable return type? Do not include any live type variables.
|
8321
|
+
const typeParams = (0, typeUtils_1.getTypeVarArgsRecursive)(returnType).filter((t) => !liveTypeVarScopes.some((scopeId) => t.priv.scopeId === scopeId));
|
8322
|
+
// If there are no unsolved type variables, we're done. If there are
|
8323
|
+
// unsolved type variables, rescope them to the callable.
|
8324
|
+
if (typeParams.length === 0) {
|
8325
|
+
return returnType;
|
8326
|
+
}
|
8327
|
+
inferReturnTypeIfNecessary(returnType);
|
8328
|
+
// Create a new scope ID based on the caller's position. This
|
8329
|
+
// will guarantee uniqueness. If another caller uses the same
|
8330
|
+
// call and arguments, the type vars will not conflict.
|
8331
|
+
const newScopeId = ParseTreeUtils.getScopeIdForNode(callNode);
|
8332
|
+
const solution = new constraintSolution_1.ConstraintSolution();
|
8333
|
+
const newTypeParams = typeParams.map((typeVar) => {
|
8334
|
+
const newTypeParam = types_1.TypeVarType.cloneForScopeId(typeVar, newScopeId, typeVar.priv.scopeName, 1 /* TypeVarScopeType.Function */);
|
8335
|
+
solution.setType(typeVar, newTypeParam);
|
8336
|
+
return newTypeParam;
|
8337
|
+
});
|
8338
|
+
return (0, typeUtils_1.applySolvedTypeVars)(types_1.FunctionType.cloneWithNewTypeVarScopeId(returnType, newScopeId,
|
8339
|
+
/* constructorTypeVarScopeId */ undefined, newTypeParams), solution);
|
8289
8340
|
}
|
8290
8341
|
// Tries to assign the call arguments to the function parameter
|
8291
8342
|
// list and reports any mismatches in types or counts. Returns the
|
@@ -8344,7 +8395,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8344
8395
|
paramSpecType = (0, typeUtils_1.convertTypeToParamSpecValue)(paramSpecType !== null && paramSpecType !== void 0 ? paramSpecType : paramSpec);
|
8345
8396
|
const matchResults = matchArgsToParams(errorNode, argList, { type: paramSpecType }, 0);
|
8346
8397
|
const functionType = matchResults.overload;
|
8347
|
-
const
|
8398
|
+
const constraints = new constraintTracker_1.ConstraintTracker();
|
8348
8399
|
if (matchResults.argumentErrors) {
|
8349
8400
|
// Evaluate types of all args. This will ensure that referenced symbols are
|
8350
8401
|
// not reported as unaccessed.
|
@@ -8353,7 +8404,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8353
8404
|
getTypeOfExpression(arg.valueExpression);
|
8354
8405
|
}
|
8355
8406
|
});
|
8356
|
-
return { argumentErrors: true, constraintTrackers: [
|
8407
|
+
return { argumentErrors: true, constraintTrackers: [constraints] };
|
8357
8408
|
}
|
8358
8409
|
const functionParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(functionType);
|
8359
8410
|
const functionWithoutParamSpec = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(functionType);
|
@@ -8393,10 +8444,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8393
8444
|
type: printType(functionParamSpec),
|
8394
8445
|
}), argErrorNode !== null && argErrorNode !== void 0 ? argErrorNode : errorNode);
|
8395
8446
|
}
|
8396
|
-
return { argumentErrors, constraintTrackers: [
|
8447
|
+
return { argumentErrors, constraintTrackers: [constraints] };
|
8397
8448
|
}
|
8398
|
-
const result = validateArgTypes(errorNode, matchResults,
|
8399
|
-
return { argumentErrors: !!result.argumentErrors, constraintTrackers: [
|
8449
|
+
const result = validateArgTypes(errorNode, matchResults, constraints, /* skipUnknownArgCheck */ undefined);
|
8450
|
+
return { argumentErrors: !!result.argumentErrors, constraintTrackers: [constraints] };
|
8400
8451
|
}
|
8401
8452
|
function validateArgType(argParam, constraints, typeResult, options) {
|
8402
8453
|
var _a, _b;
|
@@ -8458,8 +8509,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8458
8509
|
// values to any unification variables.
|
8459
8510
|
const clonedConstraints = constraints.clone();
|
8460
8511
|
if (assignType(expectedType, argType,
|
8461
|
-
/* diag */ undefined, clonedConstraints,
|
8462
|
-
/* srcConstraints */ undefined, (options === null || options === void 0 ? void 0 : options.isArgFirstPass) ? 8 /* AssignTypeFlags.ArgAssignmentFirstPass */ : 0 /* AssignTypeFlags.Default */)) {
|
8512
|
+
/* diag */ undefined, clonedConstraints, (options === null || options === void 0 ? void 0 : options.isArgFirstPass) ? 8 /* AssignTypeFlags.ArgAssignmentFirstPass */ : 0 /* AssignTypeFlags.Default */)) {
|
8463
8513
|
constraints.copyFromClone(clonedConstraints);
|
8464
8514
|
}
|
8465
8515
|
else {
|
@@ -8525,8 +8575,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8525
8575
|
if (options === null || options === void 0 ? void 0 : options.isArgFirstPass) {
|
8526
8576
|
assignTypeFlags |= 8 /* AssignTypeFlags.ArgAssignmentFirstPass */;
|
8527
8577
|
}
|
8528
|
-
if (!assignType(argParam.paramType, argType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints,
|
8529
|
-
/* srcConstraints */ undefined, assignTypeFlags)) {
|
8578
|
+
if (!assignType(argParam.paramType, argType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, assignTypeFlags)) {
|
8530
8579
|
if (!(options === null || options === void 0 ? void 0 : options.skipReportError)) {
|
8531
8580
|
// Mismatching parameter types are common in untyped code; don't bother spending time
|
8532
8581
|
// printing types if the diagnostic is disabled.
|
@@ -8706,7 +8755,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8706
8755
|
typeVar.shared.isDefaultExplicit = true;
|
8707
8756
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
8708
8757
|
if (!fileInfo.isStubFile &&
|
8709
|
-
fileInfo.executionEnvironment.pythonVersion
|
8758
|
+
pythonVersion_1.PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_13) &&
|
8710
8759
|
classType.shared.moduleName !== 'typing_extensions') {
|
8711
8760
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarDefaultIllegal(), defaultValueNode);
|
8712
8761
|
}
|
@@ -8810,7 +8859,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8810
8859
|
}
|
8811
8860
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
8812
8861
|
if (!fileInfo.isStubFile &&
|
8813
|
-
fileInfo.executionEnvironment.pythonVersion
|
8862
|
+
pythonVersion_1.PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_13) &&
|
8814
8863
|
classType.shared.moduleName !== 'typing_extensions') {
|
8815
8864
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarDefaultIllegal(), expr);
|
8816
8865
|
}
|
@@ -8871,7 +8920,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8871
8920
|
}
|
8872
8921
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
8873
8922
|
if (!fileInfo.isStubFile &&
|
8874
|
-
fileInfo.executionEnvironment.pythonVersion
|
8923
|
+
pythonVersion_1.PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_13) &&
|
8875
8924
|
classType.shared.moduleName !== 'typing_extensions') {
|
8876
8925
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarDefaultIllegal(), expr);
|
8877
8926
|
}
|
@@ -9583,8 +9632,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
9583
9632
|
const mappingConstraints = new constraintTracker_1.ConstraintTracker();
|
9584
9633
|
supportsKeysAndGetItemClass = (0, typeUtils_1.selfSpecializeClass)(supportsKeysAndGetItemClass);
|
9585
9634
|
if (assignType(types_1.ClassType.cloneAsInstance(supportsKeysAndGetItemClass), unexpandedType,
|
9586
|
-
/* diag */ undefined, mappingConstraints,
|
9587
|
-
/* srcConstraints */ undefined, 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) {
|
9635
|
+
/* diag */ undefined, mappingConstraints, 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) {
|
9588
9636
|
const specializedMapping = solveAndApplyConstraints(supportsKeysAndGetItemClass, mappingConstraints);
|
9589
9637
|
const typeArgs = specializedMapping.priv.typeArgs;
|
9590
9638
|
if (typeArgs && typeArgs.length >= 2) {
|
@@ -9851,7 +9899,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
9851
9899
|
scopeIds: [],
|
9852
9900
|
tupleClassType: getTupleClassType(),
|
9853
9901
|
},
|
9854
|
-
}
|
9902
|
+
}), (subtype) => {
|
9855
9903
|
if (entryTypes.length !== 1) {
|
9856
9904
|
return subtype;
|
9857
9905
|
}
|
@@ -9961,7 +10009,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
9961
10009
|
const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(node);
|
9962
10010
|
expectedType = (0, typeUtils_1.transformExpectedType)(expectedType, liveTypeVarScopes, node.start);
|
9963
10011
|
expectedParamDetails = (0, parameterUtils_1.getParamListDetails)(expectedType);
|
9964
|
-
expectedReturnType =
|
10012
|
+
expectedReturnType = getEffectiveReturnType(expectedType);
|
9965
10013
|
}
|
9966
10014
|
let functionType = types_1.FunctionType.createInstance('', '', '', 131072 /* FunctionTypeFlags.PartiallyEvaluated */);
|
9967
10015
|
functionType.shared.typeVarScopeId = ParseTreeUtils.getScopeIdForNode(node);
|
@@ -10072,7 +10120,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10072
10120
|
scopeIds: [],
|
10073
10121
|
tupleClassType: getTupleClassType(),
|
10074
10122
|
},
|
10075
|
-
}
|
10123
|
+
});
|
10076
10124
|
}
|
10077
10125
|
}
|
10078
10126
|
}
|
@@ -10510,7 +10558,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10510
10558
|
}
|
10511
10559
|
}
|
10512
10560
|
if (!type) {
|
10513
|
-
const exprType = getTypeOfExpression(itemExpr, (flags & 4 /* EvalFlags.ForwardRefs */
|
10561
|
+
const exprType = getTypeOfExpression(itemExpr, (flags & (4 /* EvalFlags.ForwardRefs */ | 256 /* EvalFlags.TypeExpression */)) | 33554432 /* EvalFlags.NoConvertSpecialForm */);
|
10514
10562
|
// Is this an enum type?
|
10515
10563
|
if ((0, types_1.isClassInstance)(exprType.type) &&
|
10516
10564
|
types_1.ClassType.isEnumClass(exprType.type) &&
|
@@ -10533,8 +10581,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10533
10581
|
}
|
10534
10582
|
}
|
10535
10583
|
if (!type) {
|
10536
|
-
|
10537
|
-
|
10584
|
+
if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
|
10585
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.literalUnsupportedType(), item);
|
10586
|
+
type = types_1.UnknownType.create();
|
10587
|
+
}
|
10588
|
+
else {
|
10589
|
+
return types_1.ClassType.cloneAsInstance(classType);
|
10590
|
+
}
|
10538
10591
|
}
|
10539
10592
|
literalTypes.push(type);
|
10540
10593
|
}
|
@@ -10570,10 +10623,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10570
10623
|
}
|
10571
10624
|
return type;
|
10572
10625
|
}
|
10573
|
-
// Creates a "TypeGuard" and "TypeIs" type.
|
10574
|
-
// isn't a generic type and therefore doesn't have a typeParam.
|
10575
|
-
// We'll abuse our internal types a bit by specializing it with
|
10576
|
-
// a type argument anyway.
|
10626
|
+
// Creates a "TypeGuard" and "TypeIs" type.
|
10577
10627
|
function createTypeGuardType(classType, errorNode, typeArgs, flags) {
|
10578
10628
|
// If no type arguments are provided, the resulting type
|
10579
10629
|
// depends on whether we're evaluating a type annotation or
|
@@ -10999,36 +11049,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10999
11049
|
})) {
|
11000
11050
|
typeArgType = types_1.UnknownType.create();
|
11001
11051
|
}
|
11002
|
-
|
11003
|
-
if ((0, types_1.isUnpackedClass)(typeArg.type) && typeArg.type.priv.tupleTypeArgs) {
|
11052
|
+
if ((0, types_1.isTypeVar)(typeArgType) && (0, types_1.isUnpackedTypeVarTuple)(typeArgType)) {
|
11004
11053
|
// This is an experimental feature because Unions of unpacked TypeVarTuples are not officially supported.
|
11005
11054
|
if (fileInfo.diagnosticRuleSet.enableExperimentalFeatures) {
|
11006
|
-
|
11007
|
-
|
11008
|
-
|
11055
|
+
// If this is an unpacked TypeVar, note that it is in a union so we can
|
11056
|
+
// differentiate between Unpack[Vs] and Union[Unpack[Vs]].
|
11057
|
+
typeArgType = types_1.TypeVarType.cloneForUnpacked(typeArgType, /* isInUnion */ true);
|
11009
11058
|
allowSingleTypeArg = true;
|
11010
11059
|
}
|
11011
11060
|
else {
|
11012
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.
|
11013
|
-
|
11014
|
-
}
|
11015
|
-
}
|
11016
|
-
else {
|
11017
|
-
if ((0, types_1.isTypeVar)(typeArgType) && (0, types_1.isUnpackedTypeVarTuple)(typeArgType)) {
|
11018
|
-
// This is an experimental feature because Unions of unpacked TypeVarTuples are not officially supported.
|
11019
|
-
if (fileInfo.diagnosticRuleSet.enableExperimentalFeatures) {
|
11020
|
-
// If this is an unpacked TypeVar, note that it is in a union so we can
|
11021
|
-
// differentiate between Unpack[Vs] and Union[Unpack[Vs]].
|
11022
|
-
typeArgType = types_1.TypeVarType.cloneForUnpacked(typeArgType, /* isInUnion */ true);
|
11023
|
-
allowSingleTypeArg = true;
|
11024
|
-
}
|
11025
|
-
else {
|
11026
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.unionUnpackedTypeVarTuple(), errorNode);
|
11027
|
-
typeArgType = types_1.UnknownType.create();
|
11028
|
-
}
|
11061
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.unionUnpackedTypeVarTuple(), errorNode);
|
11062
|
+
typeArgType = types_1.UnknownType.create();
|
11029
11063
|
}
|
11030
|
-
types.push(typeArgType);
|
11031
11064
|
}
|
11065
|
+
types.push(typeArgType);
|
11032
11066
|
}
|
11033
11067
|
// Validate that we received at least two type arguments. One type argument
|
11034
11068
|
// is allowed if it's an unpacked TypeVarTuple or tuple. None is also allowed
|
@@ -11185,7 +11219,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11185
11219
|
if (fileInfo.isTypingExtensionsStubFile) {
|
11186
11220
|
specialClassType.shared.flags |= 4096 /* ClassTypeFlags.TypingExtensionClass */;
|
11187
11221
|
}
|
11188
|
-
const baseClassName = aliasMapEntry.alias || 'object';
|
11222
|
+
const baseClassName = aliasMapEntry.implicitBaseClass || aliasMapEntry.alias || 'object';
|
11189
11223
|
let baseClass;
|
11190
11224
|
if (aliasMapEntry.module === 'builtins') {
|
11191
11225
|
baseClass = getBuiltInType(node, baseClassName);
|
@@ -11252,7 +11286,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11252
11286
|
['Concatenate', { alias: '', module: 'builtins', isSpecialForm: true }],
|
11253
11287
|
[
|
11254
11288
|
'TypeGuard',
|
11255
|
-
{
|
11289
|
+
{
|
11290
|
+
alias: '',
|
11291
|
+
module: 'builtins',
|
11292
|
+
implicitBaseClass: 'bool',
|
11293
|
+
isSpecialForm: true,
|
11294
|
+
typeParamVariance: 3 /* Variance.Covariant */,
|
11295
|
+
},
|
11256
11296
|
],
|
11257
11297
|
['Unpack', { alias: '', module: 'builtins', isSpecialForm: true }],
|
11258
11298
|
['Required', { alias: '', module: 'builtins', isSpecialForm: true }],
|
@@ -11262,7 +11302,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11262
11302
|
['Never', { alias: '', module: 'builtins', isSpecialForm: true }],
|
11263
11303
|
['LiteralString', { alias: '', module: 'builtins', isSpecialForm: true }],
|
11264
11304
|
['ReadOnly', { alias: '', module: 'builtins', isSpecialForm: true }],
|
11265
|
-
[
|
11305
|
+
[
|
11306
|
+
'TypeIs',
|
11307
|
+
{
|
11308
|
+
alias: '',
|
11309
|
+
module: 'builtins',
|
11310
|
+
implicitBaseClass: 'bool',
|
11311
|
+
isSpecialForm: true,
|
11312
|
+
typeParamVariance: 2 /* Variance.Invariant */,
|
11313
|
+
},
|
11314
|
+
],
|
11266
11315
|
]);
|
11267
11316
|
const aliasMapEntry = specialTypes.get(assignedName);
|
11268
11317
|
if (aliasMapEntry) {
|
@@ -11534,7 +11583,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11534
11583
|
function createSubclass(errorNode, type1, type2) {
|
11535
11584
|
var _a, _b;
|
11536
11585
|
(0, debug_1.assert)((0, types_1.isInstantiableClass)(type1) && (0, types_1.isInstantiableClass)(type2));
|
11537
|
-
const className = `<subclass of ${type1
|
11586
|
+
const className = `<subclass of ${printType((0, typeUtils_1.convertToInstance)(type1), {
|
11587
|
+
omitTypeArgsIfUnknown: true,
|
11588
|
+
})} and ${printType((0, typeUtils_1.convertToInstance)(type2), { omitTypeArgsIfUnknown: true })}>`;
|
11538
11589
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
11539
11590
|
// The effective metaclass of the intersection is the narrower of the two metaclasses.
|
11540
11591
|
let effectiveMetaclass = type1.shared.effectiveMetaclass;
|
@@ -11613,6 +11664,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11613
11664
|
classType.shared.flags |= 8192 /* ClassTypeFlags.PartiallyEvaluated */;
|
11614
11665
|
classType.shared.declaration = classDecl;
|
11615
11666
|
return (0, cancellationUtils_1.invalidateTypeCacheIfCanceled)(() => {
|
11667
|
+
var _a;
|
11616
11668
|
writeTypeCache(node, { type: classType }, /* flags */ undefined);
|
11617
11669
|
writeTypeCache(node.d.name, { type: classType }, /* flags */ undefined);
|
11618
11670
|
// Keep a list of unique type parameters that are used in the
|
@@ -11696,7 +11748,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11696
11748
|
if (types_1.ClassType.isBuiltIn(argType, 'Protocol')) {
|
11697
11749
|
if (!fileInfo.isStubFile &&
|
11698
11750
|
!types_1.ClassType.isTypingExtensionClass(argType) &&
|
11699
|
-
fileInfo.executionEnvironment.pythonVersion
|
11751
|
+
pythonVersion_1.PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_7)) {
|
11700
11752
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.protocolIllegal(), arg.d.valueExpr);
|
11701
11753
|
}
|
11702
11754
|
classType.shared.flags |= 512 /* ClassTypeFlags.ProtocolClass */;
|
@@ -11706,7 +11758,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11706
11758
|
}
|
11707
11759
|
// If the class directly derives from NamedTuple (in Python 3.6 or
|
11708
11760
|
// newer), it's considered a (read-only) dataclass.
|
11709
|
-
if (fileInfo.executionEnvironment.pythonVersion
|
11761
|
+
if (pythonVersion_1.PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_6)) {
|
11710
11762
|
if (types_1.ClassType.isBuiltIn(argType, 'NamedTuple')) {
|
11711
11763
|
isNamedTupleSubclass = true;
|
11712
11764
|
classType.shared.flags |= 524288 /* ClassTypeFlags.ReadOnlyInstanceVariables */;
|
@@ -12001,7 +12053,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12001
12053
|
let foundUnknown = false;
|
12002
12054
|
for (let i = node.d.decorators.length - 1; i >= 0; i--) {
|
12003
12055
|
const decorator = node.d.decorators[i];
|
12004
|
-
const newDecoratedType = (0, decorators_1.applyClassDecorator)(evaluatorInterface, decoratedType, classType, decorator);
|
12056
|
+
const newDecoratedType = useSignatureTracker((_a = node.parent) !== null && _a !== void 0 ? _a : node, () => (0, decorators_1.applyClassDecorator)(evaluatorInterface, decoratedType, classType, decorator));
|
12005
12057
|
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(newDecoratedType, /* recurse */ false);
|
12006
12058
|
if (unknownOrAny && (0, types_1.isUnknown)(unknownOrAny)) {
|
12007
12059
|
// Report this error only on the first unknown type.
|
@@ -12448,8 +12500,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12448
12500
|
/* skipUnknownArgCheck */ false, (0, typeUtils_1.makeInferenceContext)(getNoneType()));
|
12449
12501
|
if (callResult.argumentErrors) {
|
12450
12502
|
const diag = addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.initSubclassCallFailed(), node.d.name);
|
12451
|
-
const initSubclassFunction = (0, types_1.
|
12452
|
-
? types_1.
|
12503
|
+
const initSubclassFunction = (0, types_1.isOverloaded)(initSubclassMethodType)
|
12504
|
+
? types_1.OverloadedType.getOverloads(initSubclassMethodType)[0]
|
12453
12505
|
: initSubclassMethodType;
|
12454
12506
|
const initSubclassDecl = (0, types_1.isFunction)(initSubclassFunction)
|
12455
12507
|
? initSubclassFunction.shared.declaration
|
@@ -12471,6 +12523,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12471
12523
|
});
|
12472
12524
|
}
|
12473
12525
|
function getTypeOfFunction(node) {
|
12526
|
+
var _a;
|
12474
12527
|
initializePrefetchedTypes(node);
|
12475
12528
|
// Is this predecorated function type cached?
|
12476
12529
|
let functionType = readTypeCache(node.d.name, 0 /* EvalFlags.None */);
|
@@ -12504,7 +12557,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12504
12557
|
let foundUnknown = false;
|
12505
12558
|
for (let i = node.d.decorators.length - 1; i >= 0; i--) {
|
12506
12559
|
const decorator = node.d.decorators[i];
|
12507
|
-
const newDecoratedType = (
|
12560
|
+
const newDecoratedType = useSignatureTracker((_a = node.parent) !== null && _a !== void 0 ? _a : node, () => {
|
12561
|
+
(0, debug_1.assert)(decoratedType !== undefined);
|
12562
|
+
return (0, decorators_1.applyFunctionDecorator)(evaluatorInterface, decoratedType, functionType, decorator, node);
|
12563
|
+
});
|
12508
12564
|
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(newDecoratedType, /* recurse */ false);
|
12509
12565
|
if (unknownOrAny && (0, types_1.isUnknown)(unknownOrAny)) {
|
12510
12566
|
// Report this error only on the first unknown type.
|
@@ -12527,8 +12583,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12527
12583
|
markParamAccessed(param);
|
12528
12584
|
});
|
12529
12585
|
}
|
12530
|
-
decoratedType = (0, decorators_1.addOverloadsToFunctionType)(evaluatorInterface, node, decoratedType);
|
12531
12586
|
}
|
12587
|
+
decoratedType = (0, decorators_1.addOverloadsToFunctionType)(evaluatorInterface, node, decoratedType);
|
12532
12588
|
writeTypeCache(node, { type: decoratedType }, 0 /* EvalFlags.None */);
|
12533
12589
|
return { functionType, decoratedType };
|
12534
12590
|
}
|
@@ -12976,7 +13032,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12976
13032
|
}
|
12977
13033
|
else {
|
12978
13034
|
let skipInference = false;
|
12979
|
-
if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.
|
13035
|
+
if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloaded)(defaultValueType)) {
|
12980
13036
|
// Do not infer parameter types that use a lambda or another function as a
|
12981
13037
|
// default value. We're likely to generate false positives in this case.
|
12982
13038
|
// It's not clear whether parameters should be positional-only or not.
|
@@ -13013,7 +13069,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
13013
13069
|
return type;
|
13014
13070
|
}
|
13015
13071
|
if ((0, types_1.isUnpackedClass)(type)) {
|
13016
|
-
return types_1.ClassType.cloneForUnpacked(type, /*
|
13072
|
+
return types_1.ClassType.cloneForUnpacked(type, /* isUnpacked */ false);
|
13017
13073
|
}
|
13018
13074
|
return makeTupleObject([{ type, isUnbounded: !(0, types_1.isTypeVarTuple)(type) }]);
|
13019
13075
|
}
|
@@ -13480,13 +13536,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
13480
13536
|
reportError = true;
|
13481
13537
|
// Handle PEP 562 support for module-level __getattr__ function,
|
13482
13538
|
// introduced in Python 3.7.
|
13483
|
-
if (fileInfo.executionEnvironment.pythonVersion
|
13539
|
+
if (pythonVersion_1.PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_7) ||
|
13484
13540
|
fileInfo.isStubFile) {
|
13485
13541
|
const getAttrSymbol = importLookupInfo.symbolTable.get('__getattr__');
|
13486
13542
|
if (getAttrSymbol) {
|
13487
13543
|
const getAttrType = getEffectiveTypeOfSymbol(getAttrSymbol);
|
13488
13544
|
if ((0, types_1.isFunction)(getAttrType)) {
|
13489
|
-
symbolType =
|
13545
|
+
symbolType = getEffectiveReturnType(getAttrType);
|
13490
13546
|
reportError = false;
|
13491
13547
|
}
|
13492
13548
|
}
|
@@ -13927,7 +13983,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
13927
13983
|
if (parent.d.expr) {
|
13928
13984
|
const enclosingFunctionNode = ParseTreeUtils.getEnclosingFunction(node);
|
13929
13985
|
let declaredReturnType = enclosingFunctionNode
|
13930
|
-
?
|
13986
|
+
? getDeclaredReturnType(enclosingFunctionNode)
|
13931
13987
|
: undefined;
|
13932
13988
|
if (declaredReturnType) {
|
13933
13989
|
const liveScopeIds = ParseTreeUtils.getTypeVarScopesForNode(node);
|
@@ -14309,7 +14365,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14309
14365
|
}
|
14310
14366
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
14311
14367
|
if (fileInfo.isStubFile ||
|
14312
|
-
fileInfo.executionEnvironment.pythonVersion
|
14368
|
+
pythonVersion_1.PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion_1.pythonVersion3_9) ||
|
14313
14369
|
(0, analyzerFileInfo_1.isAnnotationEvaluationPostponed)(AnalyzerNodeInfo.getFileInfo(errorNode)) ||
|
14314
14370
|
(flags & 4 /* EvalFlags.ForwardRefs */) !== 0) {
|
14315
14371
|
// Handle "type" specially, since it needs to act like "Type"
|
@@ -14317,7 +14373,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14317
14373
|
if (types_1.ClassType.isBuiltIn(classType, 'type') && typeArgs) {
|
14318
14374
|
if (typeArgs.length >= 1) {
|
14319
14375
|
// Treat type[function] as illegal.
|
14320
|
-
if ((0, types_1.isFunction)(typeArgs[0].type) || (0, types_1.
|
14376
|
+
if ((0, types_1.isFunction)(typeArgs[0].type) || (0, types_1.isOverloaded)(typeArgs[0].type)) {
|
14321
14377
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAnnotationWithCallable(), typeArgs[0].node);
|
14322
14378
|
return { type: types_1.UnknownType.create() };
|
14323
14379
|
}
|
@@ -14801,7 +14857,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14801
14857
|
if (!tracker) {
|
14802
14858
|
return type;
|
14803
14859
|
}
|
14804
|
-
if ((0, types_1.isFunction)(type) || (0, types_1.
|
14860
|
+
if ((0, types_1.isFunction)(type) || (0, types_1.isOverloaded)(type)) {
|
14805
14861
|
return (0, typeUtils_1.ensureSignaturesAreUnique)(type, tracker, node.start);
|
14806
14862
|
}
|
14807
14863
|
return type;
|
@@ -15020,8 +15076,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
15020
15076
|
declarations.push(paramDecl);
|
15021
15077
|
}
|
15022
15078
|
}
|
15023
|
-
else if ((0, types_1.
|
15024
|
-
|
15079
|
+
else if ((0, types_1.isOverloaded)(baseType)) {
|
15080
|
+
types_1.OverloadedType.getOverloads(baseType).forEach((f) => {
|
15025
15081
|
const paramDecl = getDeclarationFromKeywordParam(f, paramName);
|
15026
15082
|
if (paramDecl) {
|
15027
15083
|
declarations.push(paramDecl);
|
@@ -15905,32 +15961,33 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
15905
15961
|
}
|
15906
15962
|
function inferReturnTypeIfNecessary(type) {
|
15907
15963
|
if ((0, types_1.isFunction)(type)) {
|
15908
|
-
|
15964
|
+
getEffectiveReturnType(type);
|
15909
15965
|
}
|
15910
|
-
else if ((0, types_1.
|
15911
|
-
|
15912
|
-
|
15966
|
+
else if ((0, types_1.isOverloaded)(type)) {
|
15967
|
+
types_1.OverloadedType.getOverloads(type).forEach((overload) => {
|
15968
|
+
getEffectiveReturnType(overload);
|
15913
15969
|
});
|
15970
|
+
const impl = types_1.OverloadedType.getImplementation(type);
|
15971
|
+
if (impl && (0, types_1.isFunction)(impl)) {
|
15972
|
+
getEffectiveReturnType(impl);
|
15973
|
+
}
|
15914
15974
|
}
|
15915
15975
|
}
|
15916
15976
|
// Returns the return type of the function. If the type is explicitly provided in
|
15917
15977
|
// a type annotation, that type is returned. If not, an attempt is made to infer
|
15918
15978
|
// the return type. If a list of args is provided, the inference logic may take
|
15919
15979
|
// into account argument types to infer the return type.
|
15920
|
-
function
|
15980
|
+
function getEffectiveReturnType(type, options) {
|
15921
15981
|
const specializedReturnType = types_1.FunctionType.getEffectiveReturnType(type, /* includeInferred */ false);
|
15922
15982
|
if (specializedReturnType && !(0, types_1.isUnknown)(specializedReturnType)) {
|
15923
|
-
|
15924
|
-
? ParseTreeUtils.getTypeVarScopesForNode(callSiteInfo === null || callSiteInfo === void 0 ? void 0 : callSiteInfo.errorNode)
|
15925
|
-
: [];
|
15926
|
-
return adjustCallableReturnType(type, specializedReturnType, liveTypeVarScopes);
|
15983
|
+
return specializedReturnType;
|
15927
15984
|
}
|
15928
|
-
if (
|
15929
|
-
return getFunctionInferredReturnType(type, callSiteInfo);
|
15985
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipInferReturnType)) {
|
15986
|
+
return getFunctionInferredReturnType(type, options === null || options === void 0 ? void 0 : options.callSiteInfo);
|
15930
15987
|
}
|
15931
15988
|
return types_1.UnknownType.create();
|
15932
15989
|
}
|
15933
|
-
function
|
15990
|
+
function _getInferredReturnType(type, callSiteInfo) {
|
15934
15991
|
var _a, _b, _c;
|
15935
15992
|
let returnType;
|
15936
15993
|
let isIncomplete = false;
|
@@ -16026,7 +16083,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16026
16083
|
// We can't use this technique if decorators or async are used because they
|
16027
16084
|
// would need to be applied to the inferred return type.
|
16028
16085
|
if (!hasDecorators && !isAsync) {
|
16029
|
-
const contextualReturnType =
|
16086
|
+
const contextualReturnType = inferReturnTypeForCallSite(type, callSiteInfo);
|
16030
16087
|
if (contextualReturnType) {
|
16031
16088
|
returnType = contextualReturnType;
|
16032
16089
|
if ((_c = type.shared.declaration) === null || _c === void 0 ? void 0 : _c.node) {
|
@@ -16039,7 +16096,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16039
16096
|
}
|
16040
16097
|
return returnType;
|
16041
16098
|
}
|
16042
|
-
function
|
16099
|
+
function inferReturnTypeForCallSite(type, callSiteInfo) {
|
16043
16100
|
const args = callSiteInfo.args;
|
16044
16101
|
let contextualReturnType;
|
16045
16102
|
if (!type.shared.declaration) {
|
@@ -16180,7 +16237,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16180
16237
|
// If the function has an explicitly-declared return type, it is returned
|
16181
16238
|
// unaltered unless the function is a generator, in which case it is
|
16182
16239
|
// modified to return only the return type for the generator.
|
16183
|
-
function
|
16240
|
+
function getDeclaredReturnType(node) {
|
16184
16241
|
const functionTypeInfo = getTypeOfFunction(node);
|
16185
16242
|
const returnType = functionTypeInfo === null || functionTypeInfo === void 0 ? void 0 : functionTypeInfo.functionType.shared.declaredReturnType;
|
16186
16243
|
if (!returnType) {
|
@@ -16230,7 +16287,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16230
16287
|
(0, typeUtils_1.requiresSpecialization)(typeResult.type, { ignoreSelf: true, ignoreImplicitTypeArgs: true })) {
|
16231
16288
|
const specializedType = (0, typeUtils_1.partiallySpecializeType)(typeResult.type, member.unspecializedClassType, getTypeClassType(), (0, typeUtils_1.selfSpecializeClass)(selfClass, { overrideTypeArgs: true }));
|
16232
16289
|
if ((0, types_1.findSubtype)(specializedType, (subtype) => !(0, types_1.isFunction)(subtype) &&
|
16233
|
-
!(0, types_1.
|
16290
|
+
!(0, types_1.isOverloaded)(subtype) &&
|
16234
16291
|
(0, typeUtils_1.requiresSpecialization)(subtype, { ignoreSelf: true, ignoreImplicitTypeArgs: true }))) {
|
16235
16292
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.genericInstanceVariableAccess(), errorNode);
|
16236
16293
|
}
|
@@ -16240,7 +16297,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16240
16297
|
isIncomplete: !!typeResult.isIncomplete,
|
16241
16298
|
};
|
16242
16299
|
}
|
16243
|
-
function assignClass(destType, srcType, diag,
|
16300
|
+
function assignClass(destType, srcType, diag, constraints, flags, recursionCount, reportErrorsUsingObjType) {
|
16244
16301
|
// If the source or dest types are partially evaluated (i.e. they are in the
|
16245
16302
|
// process of being constructed), assume they are assignable rather than risk
|
16246
16303
|
// emitting false positives.
|
@@ -16251,7 +16308,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16251
16308
|
// checking, as defined in PEP 589.
|
16252
16309
|
if (types_1.ClassType.isTypedDictClass(srcType)) {
|
16253
16310
|
if (types_1.ClassType.isTypedDictClass(destType) && !types_1.ClassType.isSameGenericClass(destType, srcType)) {
|
16254
|
-
if (!(0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, destType, srcType, diag,
|
16311
|
+
if (!(0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, destType, srcType, diag, constraints, flags, recursionCount)) {
|
16255
16312
|
return false;
|
16256
16313
|
}
|
16257
16314
|
if (types_1.ClassType.isFinal(destType) !== types_1.ClassType.isFinal(srcType)) {
|
@@ -16262,7 +16319,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16262
16319
|
return false;
|
16263
16320
|
}
|
16264
16321
|
// If invariance is being enforced, the two TypedDicts must be assignable to each other.
|
16265
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16322
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
16266
16323
|
return (0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, srcType, destType,
|
16267
16324
|
/* diag */ undefined,
|
16268
16325
|
/* constraints */ undefined, flags, recursionCount);
|
@@ -16300,7 +16357,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16300
16357
|
const promotionList = typePromotions.get(destType.shared.fullName);
|
16301
16358
|
if (promotionList &&
|
16302
16359
|
promotionList.some((srcName) => srcType.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && srcName === mroClass.shared.fullName))) {
|
16303
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16360
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) === 0) {
|
16304
16361
|
return true;
|
16305
16362
|
}
|
16306
16363
|
}
|
@@ -16313,7 +16370,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16313
16370
|
// derive from the source. We also need to use this path if we're
|
16314
16371
|
// testing to see if the metaclass matches the protocol.
|
16315
16372
|
if (types_1.ClassType.isProtocolClass(destType) && !isDerivedFrom) {
|
16316
|
-
if (!(0, protocols_1.assignClassToProtocol)(evaluatorInterface, destType, types_1.ClassType.cloneAsInstance(srcType), diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
16373
|
+
if (!(0, protocols_1.assignClassToProtocol)(evaluatorInterface, destType, types_1.ClassType.cloneAsInstance(srcType), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
16317
16374
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.protocolIncompatible().format({
|
16318
16375
|
sourceType: printType((0, typeUtils_1.convertToInstance)(srcType)),
|
16319
16376
|
destType: printType((0, typeUtils_1.convertToInstance)(destType)),
|
@@ -16322,24 +16379,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16322
16379
|
}
|
16323
16380
|
return true;
|
16324
16381
|
}
|
16325
|
-
|
16326
|
-
// considered a subtype of `bool`.
|
16327
|
-
if ((0, types_1.isInstantiableClass)(srcType) && types_1.ClassType.isBuiltIn(srcType, ['TypeGuard', 'TypeIs'])) {
|
16328
|
-
if ((0, types_1.isInstantiableClass)(destType) && types_1.ClassType.isBuiltIn(destType, 'bool')) {
|
16329
|
-
return (flags & 1 /* AssignTypeFlags.EnforceInvariance */) === 0;
|
16330
|
-
}
|
16331
|
-
}
|
16332
|
-
if ((flags & 1 /* AssignTypeFlags.EnforceInvariance */) === 0 || types_1.ClassType.isSameGenericClass(srcType, destType)) {
|
16382
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) === 0 || types_1.ClassType.isSameGenericClass(srcType, destType)) {
|
16333
16383
|
if (isDerivedFrom) {
|
16334
16384
|
(0, debug_1.assert)(inheritanceChain.length > 0);
|
16335
|
-
if (assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
16385
|
+
if (assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
16336
16386
|
return true;
|
16337
16387
|
}
|
16338
16388
|
}
|
16339
16389
|
}
|
16340
16390
|
// Everything is assignable to an object.
|
16341
16391
|
if (types_1.ClassType.isBuiltIn(destType, 'object')) {
|
16342
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16392
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) === 0) {
|
16343
16393
|
return true;
|
16344
16394
|
}
|
16345
16395
|
}
|
@@ -16421,13 +16471,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16421
16471
|
// private or protected, since these are presumably
|
16422
16472
|
// not modifiable outside of the class.
|
16423
16473
|
if (!(0, symbolNameUtils_1.isPrivateOrProtectedName)(name)) {
|
16424
|
-
flags |= 1 /* AssignTypeFlags.
|
16474
|
+
flags |= 1 /* AssignTypeFlags.Invariant */;
|
16425
16475
|
}
|
16426
16476
|
}
|
16427
16477
|
if (!assignType(destMemberType, srcMemberType,
|
16428
16478
|
/* diag */ undefined,
|
16429
|
-
/*
|
16430
|
-
/* srcConstraints */ undefined, flags | 32768 /* AssignTypeFlags.SkipSelfClsParamCheck */, recursionCount)) {
|
16479
|
+
/* constraints */ undefined, flags | 32768 /* AssignTypeFlags.SkipSelfClsParamCheck */, recursionCount)) {
|
16431
16480
|
isAssignable = false;
|
16432
16481
|
}
|
16433
16482
|
}
|
@@ -16482,12 +16531,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16482
16531
|
}
|
16483
16532
|
// Determines whether the specified type can be assigned to the
|
16484
16533
|
// specified inheritance chain, taking into account its type arguments.
|
16485
|
-
function assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag,
|
16534
|
+
function assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag, constraints, flags, recursionCount) {
|
16486
16535
|
let curSrcType = srcType;
|
16487
16536
|
let prevSrcType;
|
16488
16537
|
inferVarianceForClass(destType);
|
16489
16538
|
// If we're enforcing invariance, literal types must match.
|
16490
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16539
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
16491
16540
|
const srcIsLiteral = srcType.priv.literalValue !== undefined;
|
16492
16541
|
const destIsLiteral = destType.priv.literalValue !== undefined;
|
16493
16542
|
if (srcIsLiteral !== destIsLiteral) {
|
@@ -16537,7 +16586,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16537
16586
|
prevSrcType = curSrcType;
|
16538
16587
|
}
|
16539
16588
|
// If we're enforcing invariance, literal types must match as well.
|
16540
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16589
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
16541
16590
|
const srcIsLiteral = srcType.priv.literalValue !== undefined;
|
16542
16591
|
const destIsLiteral = destType.priv.literalValue !== undefined;
|
16543
16592
|
if (srcIsLiteral !== destIsLiteral) {
|
@@ -16546,7 +16595,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16546
16595
|
}
|
16547
16596
|
// Handle tuple, which supports a variable number of type arguments.
|
16548
16597
|
if (destType.priv.tupleTypeArgs && curSrcType.priv.tupleTypeArgs) {
|
16549
|
-
return (0, tuples_1.assignTupleTypeArgs)(evaluatorInterface, destType, curSrcType, diag,
|
16598
|
+
return (0, tuples_1.assignTupleTypeArgs)(evaluatorInterface, destType, curSrcType, diag, constraints, flags, recursionCount);
|
16550
16599
|
}
|
16551
16600
|
if (destType.priv.typeArgs) {
|
16552
16601
|
// If the dest type is specialized, make sure the specialized source
|
@@ -16555,9 +16604,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16555
16604
|
// Don't emit a diag addendum if we're in an invariant context. It's
|
16556
16605
|
// sufficient to simply indicate that the types are not the same
|
16557
16606
|
// in this case. Adding more information is unnecessary and confusing.
|
16558
|
-
(flags & 1 /* AssignTypeFlags.
|
16607
|
+
(flags & 1 /* AssignTypeFlags.Invariant */) === 0 ? diag : undefined, constraints, flags, recursionCount);
|
16559
16608
|
}
|
16560
|
-
if (
|
16609
|
+
if (constraints && curSrcType.priv.typeArgs && !constraints.isLocked()) {
|
16561
16610
|
// Populate the typeVar map with type arguments of the source.
|
16562
16611
|
const srcTypeArgs = curSrcType.priv.typeArgs;
|
16563
16612
|
for (let i = 0; i < destType.shared.typeParams.length; i++) {
|
@@ -16565,13 +16614,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16565
16614
|
const typeParam = destType.shared.typeParams[i];
|
16566
16615
|
const variance = types_1.TypeVarType.getVariance(typeParam);
|
16567
16616
|
if (curSrcType.priv.tupleTypeArgs) {
|
16568
|
-
typeArgType = (0, typeUtils_1.convertToInstance)(makeTupleObject(curSrcType.priv.tupleTypeArgs, /*
|
16617
|
+
typeArgType = (0, typeUtils_1.convertToInstance)(makeTupleObject(curSrcType.priv.tupleTypeArgs, /* isUnpacked */ true));
|
16569
16618
|
}
|
16570
16619
|
else {
|
16571
16620
|
typeArgType = i < srcTypeArgs.length ? srcTypeArgs[i] : types_1.UnknownType.create();
|
16572
16621
|
}
|
16573
|
-
|
16574
|
-
/*
|
16622
|
+
constraints.setBounds(typeParam, variance !== 4 /* Variance.Contravariant */ ? typeArgType : undefined, variance !== 3 /* Variance.Covariant */ ? typeArgType : undefined,
|
16623
|
+
/* retainLiterals */ true);
|
16575
16624
|
}
|
16576
16625
|
}
|
16577
16626
|
return true;
|
@@ -16581,12 +16630,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16581
16630
|
return undefined;
|
16582
16631
|
}
|
16583
16632
|
if (propertyClass.priv.fgetInfo) {
|
16584
|
-
return
|
16585
|
-
/* args */ undefined, inferTypeIfNeeded);
|
16633
|
+
return getEffectiveReturnType(propertyClass.priv.fgetInfo.methodType);
|
16586
16634
|
}
|
16587
16635
|
return undefined;
|
16588
16636
|
}
|
16589
|
-
function assignTypeArgs(destType, srcType, diag,
|
16637
|
+
function assignTypeArgs(destType, srcType, diag, constraints, flags, recursionCount) {
|
16590
16638
|
var _a, _b, _c;
|
16591
16639
|
(0, debug_1.assert)(types_1.ClassType.isSameGenericClass(destType, srcType));
|
16592
16640
|
inferVarianceForClass(destType);
|
@@ -16629,18 +16677,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16629
16677
|
errorSource = localize_1.LocAddendum.typeVarIsCovariant;
|
16630
16678
|
}
|
16631
16679
|
else if (variance === 4 /* Variance.Contravariant */) {
|
16632
|
-
effectiveFlags =
|
16633
|
-
(flags ^ 2 /* AssignTypeFlags.ReverseTypeVarMatching */) | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
16680
|
+
effectiveFlags = (flags ^ 2 /* AssignTypeFlags.Contravariant */) | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
16634
16681
|
errorSource = localize_1.LocAddendum.typeVarIsContravariant;
|
16635
16682
|
}
|
16636
16683
|
else {
|
16637
|
-
effectiveFlags = flags | 1 /* AssignTypeFlags.
|
16684
|
+
effectiveFlags = flags | 1 /* AssignTypeFlags.Invariant */ | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
16638
16685
|
errorSource = localize_1.LocAddendum.typeVarIsInvariant;
|
16639
16686
|
// Omit the diagnostic addendum for the invariant case because it's obvious
|
16640
16687
|
// why two types are not the same.
|
16641
16688
|
includeDiagAddendum = false;
|
16642
16689
|
}
|
16643
|
-
if (!assignType(variance === 4 /* Variance.Contravariant */ ? srcTypeArg : destTypeArg, variance === 4 /* Variance.Contravariant */ ? destTypeArg : srcTypeArg, assignmentDiag,
|
16690
|
+
if (!assignType(variance === 4 /* Variance.Contravariant */ ? srcTypeArg : destTypeArg, variance === 4 /* Variance.Contravariant */ ? destTypeArg : srcTypeArg, assignmentDiag, constraints, effectiveFlags, recursionCount)) {
|
16644
16691
|
// Don't report errors with type variables in "pseudo-random"
|
16645
16692
|
// classes since these type variables are not real.
|
16646
16693
|
if (!types_1.ClassType.isPseudoGenericClass(destType)) {
|
@@ -16682,7 +16729,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16682
16729
|
// matched against existing type variables in the map. If a type variable
|
16683
16730
|
// in the dest type is not in the type map already, it is assigned a type
|
16684
16731
|
// and added to the map.
|
16685
|
-
function assignType(destType, srcType, diag,
|
16732
|
+
function assignType(destType, srcType, diag, constraints, flags = 0 /* AssignTypeFlags.Default */, recursionCount = 0) {
|
16686
16733
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
16687
16734
|
// Handle the case where the dest and src types are the same object.
|
16688
16735
|
// We can normally shortcut this and say that they are compatible,
|
@@ -16727,7 +16774,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16727
16774
|
const srcTypeArgs = srcAliasInfo.typeArgs;
|
16728
16775
|
destAliasInfo.typeArgs.forEach((destTypeArg, index) => {
|
16729
16776
|
const srcTypeArg = index < srcTypeArgs.length ? srcTypeArgs[index] : types_1.UnknownType.create();
|
16730
|
-
if (!assignType(destTypeArg, srcTypeArg, diag,
|
16777
|
+
if (!assignType(destTypeArg, srcTypeArg, diag, constraints, flags, recursionCount)) {
|
16731
16778
|
isAssignable = false;
|
16732
16779
|
}
|
16733
16780
|
});
|
@@ -16806,8 +16853,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16806
16853
|
types_1.TypeVarType.hasBound(destType) &&
|
16807
16854
|
types_1.TypeVarType.isBound(destType) === types_1.TypeVarType.isBound(srcType) &&
|
16808
16855
|
types_1.TypeBase.isInstance(srcType) === types_1.TypeBase.isInstance(destType)) {
|
16809
|
-
if ((flags & 2 /* AssignTypeFlags.
|
16810
|
-
(0, constraintSolver_1.assignTypeVar)(evaluatorInterface, destType, srcType, diag,
|
16856
|
+
if ((flags & 2 /* AssignTypeFlags.Contravariant */) === 0 && constraints) {
|
16857
|
+
(0, constraintSolver_1.assignTypeVar)(evaluatorInterface, destType, srcType, diag, constraints, flags, recursionCount);
|
16811
16858
|
}
|
16812
16859
|
return true;
|
16813
16860
|
}
|
@@ -16822,9 +16869,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16822
16869
|
return true;
|
16823
16870
|
}
|
16824
16871
|
}
|
16825
|
-
if ((flags & 2 /* AssignTypeFlags.
|
16826
|
-
|
16827
|
-
if (!(0, constraintSolver_1.assignTypeVar)(evaluatorInterface, destType, srcType, diag, targetConstraints, flags, recursionCount)) {
|
16872
|
+
if ((flags & 2 /* AssignTypeFlags.Contravariant */) === 0 || !(0, types_1.isTypeVar)(srcType)) {
|
16873
|
+
if (!(0, constraintSolver_1.assignTypeVar)(evaluatorInterface, destType, srcType, diag, constraints, flags, recursionCount)) {
|
16828
16874
|
return false;
|
16829
16875
|
}
|
16830
16876
|
if ((0, types_1.isAnyOrUnknown)(srcType) && (flags & 16 /* AssignTypeFlags.OverloadOverlap */) !== 0) {
|
@@ -16834,29 +16880,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16834
16880
|
}
|
16835
16881
|
}
|
16836
16882
|
if ((0, types_1.isTypeVar)(srcType)) {
|
16837
|
-
if ((flags & 2 /* AssignTypeFlags.
|
16838
|
-
// The caller has requested that we solve for source type variables
|
16839
|
-
// rather than dest.
|
16883
|
+
if ((flags & 2 /* AssignTypeFlags.Contravariant */) !== 0) {
|
16840
16884
|
if (types_1.TypeVarType.isBound(srcType)) {
|
16841
16885
|
return assignType(makeTopLevelTypeVarsConcrete(destType), makeTopLevelTypeVarsConcrete(srcType), diag,
|
16842
|
-
/*
|
16843
|
-
/* srcConstraints */ undefined, flags, recursionCount);
|
16886
|
+
/* constraints */ undefined, flags, recursionCount);
|
16844
16887
|
}
|
16845
|
-
if ((0, constraintSolver_1.assignTypeVar)(evaluatorInterface, srcType, destType, diag,
|
16888
|
+
if ((0, constraintSolver_1.assignTypeVar)(evaluatorInterface, srcType, destType, diag, constraints, flags, recursionCount)) {
|
16846
16889
|
return true;
|
16847
16890
|
}
|
16848
16891
|
// If the dest type is a union, only one of the subtypes needs to match.
|
16849
16892
|
let isAssignable = false;
|
16850
16893
|
if ((0, types_1.isUnion)(destType)) {
|
16851
16894
|
(0, typeUtils_1.doForEachSubtype)(destType, (destSubtype) => {
|
16852
|
-
if ((0, constraintSolver_1.assignTypeVar)(evaluatorInterface, srcType, destSubtype, diag,
|
16895
|
+
if ((0, constraintSolver_1.assignTypeVar)(evaluatorInterface, srcType, destSubtype, diag, constraints, flags, recursionCount)) {
|
16853
16896
|
isAssignable = true;
|
16854
16897
|
}
|
16855
16898
|
});
|
16856
16899
|
}
|
16857
16900
|
return isAssignable;
|
16858
16901
|
}
|
16859
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16902
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
16860
16903
|
if ((0, types_1.isAnyOrUnknown)(destType)) {
|
16861
16904
|
return true;
|
16862
16905
|
}
|
@@ -16890,29 +16933,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16890
16933
|
return true;
|
16891
16934
|
}
|
16892
16935
|
if ((0, types_1.isAnyOrUnknown)(srcType) && !((_e = srcType.props) === null || _e === void 0 ? void 0 : _e.specialForm)) {
|
16893
|
-
|
16894
|
-
if (targetConstraints) {
|
16936
|
+
if (constraints) {
|
16895
16937
|
// If it's an ellipsis type, convert it to a regular "Any"
|
16896
16938
|
// type. These are functionally equivalent, but "Any" looks
|
16897
16939
|
// better in the text representation.
|
16898
16940
|
const typeVarSubstitution = (0, typeUtils_1.isEllipsisType)(srcType) ? types_1.AnyType.create() : srcType;
|
16899
|
-
(
|
16941
|
+
setConstraintsForFreeTypeVars(destType, typeVarSubstitution, constraints);
|
16900
16942
|
}
|
16901
16943
|
if ((flags & 16 /* AssignTypeFlags.OverloadOverlap */) === 0) {
|
16902
16944
|
return true;
|
16903
16945
|
}
|
16904
16946
|
}
|
16905
16947
|
if ((0, types_1.isNever)(srcType)) {
|
16906
|
-
if ((flags & 1 /* AssignTypeFlags.
|
16948
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
16907
16949
|
if ((0, types_1.isNever)(destType)) {
|
16908
16950
|
return true;
|
16909
16951
|
}
|
16910
16952
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
|
16911
16953
|
return false;
|
16912
16954
|
}
|
16913
|
-
|
16914
|
-
|
16915
|
-
(0, typeUtils_1.setTypeArgsRecursive)(destType, types_1.UnknownType.create(), targetConstraints, recursionCount);
|
16955
|
+
if (constraints) {
|
16956
|
+
setConstraintsForFreeTypeVars(destType, types_1.UnknownType.create(), constraints);
|
16916
16957
|
}
|
16917
16958
|
return true;
|
16918
16959
|
}
|
@@ -16920,28 +16961,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16920
16961
|
// If both the source and dest are unions, use assignFromUnionType which has
|
16921
16962
|
// special-case logic to handle this case.
|
16922
16963
|
if ((0, types_1.isUnion)(srcType)) {
|
16923
|
-
return assignFromUnionType(destType, srcType,
|
16924
|
-
/* diag */ undefined, destConstraints, srcConstraints, flags, recursionCount);
|
16964
|
+
return assignFromUnionType(destType, srcType, /* diag */ undefined, constraints, flags, recursionCount);
|
16925
16965
|
}
|
16926
|
-
const
|
16927
|
-
|
16928
|
-
|
16929
|
-
|
16930
|
-
if (destConstraints && clonedDestConstraints) {
|
16931
|
-
destConstraints.copyFromClone(clonedDestConstraints);
|
16932
|
-
}
|
16933
|
-
if (srcConstraints && clonedSrcConstraints) {
|
16934
|
-
srcConstraints.copyFromClone(clonedSrcConstraints);
|
16966
|
+
const clonedConstraints = constraints === null || constraints === void 0 ? void 0 : constraints.clone();
|
16967
|
+
if (assignToUnionType(destType, srcType, /* diag */ undefined, clonedConstraints, flags, recursionCount)) {
|
16968
|
+
if (constraints && clonedConstraints) {
|
16969
|
+
constraints.copyFromClone(clonedConstraints);
|
16935
16970
|
}
|
16936
16971
|
return true;
|
16937
16972
|
}
|
16938
16973
|
}
|
16939
16974
|
const expandedSrcType = makeTopLevelTypeVarsConcrete(srcType);
|
16940
16975
|
if ((0, types_1.isUnion)(expandedSrcType)) {
|
16941
|
-
return assignFromUnionType(destType, expandedSrcType, diag,
|
16976
|
+
return assignFromUnionType(destType, expandedSrcType, diag, constraints, flags, recursionCount);
|
16942
16977
|
}
|
16943
16978
|
if ((0, types_1.isUnion)(destType)) {
|
16944
|
-
return assignToUnionType(destType, srcType, diag,
|
16979
|
+
return assignToUnionType(destType, srcType, diag, constraints, flags, recursionCount);
|
16945
16980
|
}
|
16946
16981
|
// Is the src a specialized "type" object?
|
16947
16982
|
if ((0, types_1.isClassInstance)(expandedSrcType) && types_1.ClassType.isBuiltIn(expandedSrcType, 'type')) {
|
@@ -16959,7 +16994,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16959
16994
|
}
|
16960
16995
|
}
|
16961
16996
|
else if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
|
16962
|
-
if (assignType(destType, (0, typeUtils_1.convertToInstantiable)(typeTypeArg), diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
16997
|
+
if (assignType(destType, (0, typeUtils_1.convertToInstantiable)(typeTypeArg), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
16963
16998
|
return true;
|
16964
16999
|
}
|
16965
17000
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
|
@@ -16986,10 +17021,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16986
17021
|
}
|
16987
17022
|
if (isSpecialFormClass(expandedSrcType, flags)) {
|
16988
17023
|
if ((_h = destType.props) === null || _h === void 0 ? void 0 : _h.specialForm) {
|
16989
|
-
return assignType(destType.props.specialForm, expandedSrcType, diag,
|
17024
|
+
return assignType(destType.props.specialForm, expandedSrcType, diag, constraints, flags, recursionCount);
|
16990
17025
|
}
|
16991
17026
|
}
|
16992
|
-
else if (assignClass(destType, expandedSrcType, diag,
|
17027
|
+
else if (assignClass(destType, expandedSrcType, diag, constraints, flags, recursionCount,
|
16993
17028
|
/* reportErrorsUsingObjType */ false)) {
|
16994
17029
|
return true;
|
16995
17030
|
}
|
@@ -17001,7 +17036,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17001
17036
|
// the metaclass of the instantiable dest type.
|
17002
17037
|
const destMetaclass = destType.shared.effectiveMetaclass;
|
17003
17038
|
if (destMetaclass && (0, types_1.isInstantiableClass)(destMetaclass)) {
|
17004
|
-
if (assignClass(types_1.ClassType.cloneAsInstance(destMetaclass), expandedSrcType, diag,
|
17039
|
+
if (assignClass(types_1.ClassType.cloneAsInstance(destMetaclass), expandedSrcType, diag, constraints, flags, recursionCount,
|
17005
17040
|
/* reportErrorsUsingObjType */ false)) {
|
17006
17041
|
return true;
|
17007
17042
|
}
|
@@ -17021,7 +17056,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17021
17056
|
const destTypeArgs = destType.priv.typeArgs;
|
17022
17057
|
if (destTypeArgs && destTypeArgs.length >= 1) {
|
17023
17058
|
if (types_1.TypeBase.isInstance(destTypeArgs[0]) && types_1.TypeBase.isInstantiable(srcType)) {
|
17024
|
-
return assignType(destTypeArgs[0], (0, typeUtils_1.convertToInstance)(srcType), diag,
|
17059
|
+
return assignType(destTypeArgs[0], (0, typeUtils_1.convertToInstance)(srcType), diag, constraints, flags, recursionCount);
|
17025
17060
|
}
|
17026
17061
|
}
|
17027
17062
|
// Is the dest a "type" object? Assume that all instantiable
|
@@ -17057,7 +17092,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17057
17092
|
if (types_1.ClassType.isBuiltIn(destType, 'LiteralString')) {
|
17058
17093
|
if (types_1.ClassType.isBuiltIn(concreteSrcType, 'str') &&
|
17059
17094
|
concreteSrcType.priv.literalValue !== undefined) {
|
17060
|
-
return (flags & 1 /* AssignTypeFlags.
|
17095
|
+
return (flags & 1 /* AssignTypeFlags.Invariant */) === 0;
|
17061
17096
|
}
|
17062
17097
|
else if (types_1.ClassType.isBuiltIn(concreteSrcType, 'LiteralString')) {
|
17063
17098
|
return true;
|
@@ -17066,24 +17101,24 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17066
17101
|
else if (types_1.ClassType.isBuiltIn(concreteSrcType, 'LiteralString') &&
|
17067
17102
|
strClass &&
|
17068
17103
|
(0, types_1.isInstantiableClass)(strClass) &&
|
17069
|
-
(flags & 1 /* AssignTypeFlags.
|
17104
|
+
(flags & 1 /* AssignTypeFlags.Invariant */) === 0) {
|
17070
17105
|
concreteSrcType = types_1.ClassType.cloneAsInstance(strClass);
|
17071
17106
|
}
|
17072
|
-
if (!assignClass(types_1.ClassType.cloneAsInstantiable(destType), types_1.ClassType.cloneAsInstantiable(concreteSrcType), diag,
|
17107
|
+
if (!assignClass(types_1.ClassType.cloneAsInstantiable(destType), types_1.ClassType.cloneAsInstantiable(concreteSrcType), diag, constraints, flags, recursionCount,
|
17073
17108
|
/* reportErrorsUsingObjType */ true)) {
|
17074
17109
|
return false;
|
17075
17110
|
}
|
17076
17111
|
return true;
|
17077
17112
|
}
|
17078
|
-
else if ((0, types_1.isFunction)(concreteSrcType) || (0, types_1.
|
17113
|
+
else if ((0, types_1.isFunction)(concreteSrcType) || (0, types_1.isOverloaded)(concreteSrcType)) {
|
17079
17114
|
// Is the destination a callback protocol (defined in PEP 544)?
|
17080
17115
|
const destCallbackType = getCallbackProtocolType(destType, recursionCount);
|
17081
17116
|
if (destCallbackType) {
|
17082
|
-
return assignType(destCallbackType, concreteSrcType, diag,
|
17117
|
+
return assignType(destCallbackType, concreteSrcType, diag, constraints, flags, recursionCount);
|
17083
17118
|
}
|
17084
17119
|
// All functions are considered instances of "builtins.function".
|
17085
17120
|
if (functionClass) {
|
17086
|
-
return assignType(destType, (0, typeUtils_1.convertToInstance)(functionClass), diag,
|
17121
|
+
return assignType(destType, (0, typeUtils_1.convertToInstance)(functionClass), diag, constraints, flags, recursionCount);
|
17087
17122
|
}
|
17088
17123
|
}
|
17089
17124
|
else if ((0, types_1.isModule)(concreteSrcType)) {
|
@@ -17092,7 +17127,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17092
17127
|
return true;
|
17093
17128
|
}
|
17094
17129
|
if (types_1.ClassType.isProtocolClass(destType)) {
|
17095
|
-
return (0, protocols_1.assignModuleToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), concreteSrcType, diag,
|
17130
|
+
return (0, protocols_1.assignModuleToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), concreteSrcType, diag, constraints, flags, recursionCount);
|
17096
17131
|
}
|
17097
17132
|
}
|
17098
17133
|
else if ((0, types_1.isInstantiableClass)(concreteSrcType)) {
|
@@ -17100,12 +17135,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17100
17135
|
// class that is effectively a function.
|
17101
17136
|
const callbackType = getCallbackProtocolType(destType, recursionCount);
|
17102
17137
|
if (callbackType) {
|
17103
|
-
return assignType(callbackType, concreteSrcType, diag,
|
17138
|
+
return assignType(callbackType, concreteSrcType, diag, constraints, flags, recursionCount);
|
17104
17139
|
}
|
17105
17140
|
// If the destType is an instantiation of a Protocol,
|
17106
17141
|
// see if the class type itself satisfies the protocol.
|
17107
17142
|
if (types_1.ClassType.isProtocolClass(destType)) {
|
17108
|
-
return (0, protocols_1.assignClassToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), concreteSrcType, diag,
|
17143
|
+
return (0, protocols_1.assignClassToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), concreteSrcType, diag, constraints, flags, recursionCount);
|
17109
17144
|
}
|
17110
17145
|
// Determine if the metaclass can be assigned to the object.
|
17111
17146
|
const metaclass = concreteSrcType.shared.effectiveMetaclass;
|
@@ -17114,7 +17149,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17114
17149
|
return true;
|
17115
17150
|
}
|
17116
17151
|
else {
|
17117
|
-
return assignClass(types_1.ClassType.cloneAsInstantiable(destType), metaclass, diag,
|
17152
|
+
return assignClass(types_1.ClassType.cloneAsInstantiable(destType), metaclass, diag, constraints, flags, recursionCount,
|
17118
17153
|
/* reportErrorsUsingObjType */ false);
|
17119
17154
|
}
|
17120
17155
|
}
|
@@ -17123,7 +17158,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17123
17158
|
return (flags & 16 /* AssignTypeFlags.OverloadOverlap */) === 0;
|
17124
17159
|
}
|
17125
17160
|
else if ((0, types_1.isUnion)(concreteSrcType)) {
|
17126
|
-
return assignType(destType, concreteSrcType, diag,
|
17161
|
+
return assignType(destType, concreteSrcType, diag, constraints, flags, recursionCount);
|
17127
17162
|
}
|
17128
17163
|
}
|
17129
17164
|
if ((0, types_1.isFunction)(destType)) {
|
@@ -17144,14 +17179,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17144
17179
|
// The constructor conversion may result in a union of the
|
17145
17180
|
// __init__ and __new__ callables.
|
17146
17181
|
if ((0, types_1.isUnion)(concreteSrcType)) {
|
17147
|
-
return assignType(destType, concreteSrcType, diag,
|
17182
|
+
return assignType(destType, concreteSrcType, diag, constraints, flags, recursionCount);
|
17148
17183
|
}
|
17149
17184
|
}
|
17150
17185
|
}
|
17151
17186
|
if ((0, types_1.isAnyOrUnknown)(concreteSrcType)) {
|
17152
17187
|
return (flags & 16 /* AssignTypeFlags.OverloadOverlap */) === 0;
|
17153
17188
|
}
|
17154
|
-
if ((0, types_1.
|
17189
|
+
if ((0, types_1.isOverloaded)(concreteSrcType)) {
|
17155
17190
|
// If this is the first pass of an argument assignment, skip
|
17156
17191
|
// all attempts to assign an overloaded function to a function
|
17157
17192
|
// because we probably don't have enough information to properly
|
@@ -17161,23 +17196,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17161
17196
|
return true;
|
17162
17197
|
}
|
17163
17198
|
// Find all of the overloaded functions that match the parameters.
|
17164
|
-
const overloads = types_1.
|
17199
|
+
const overloads = types_1.OverloadedType.getOverloads(concreteSrcType);
|
17165
17200
|
const filteredOverloads = [];
|
17166
|
-
const
|
17167
|
-
const srcTypeVarSignatures = [];
|
17201
|
+
const typeVarSignatures = [];
|
17168
17202
|
overloads.forEach((overload) => {
|
17169
17203
|
var _a;
|
17170
17204
|
const overloadScopeId = (_a = (0, typeUtils_1.getTypeVarScopeId)(overload)) !== null && _a !== void 0 ? _a : '';
|
17171
|
-
const
|
17172
|
-
|
17173
|
-
if (assignType(destType, overload,
|
17174
|
-
/* diag */ undefined, destConstraintsClone, srcConstraintsClone, flags, recursionCount)) {
|
17205
|
+
const constraintsClone = constraints === null || constraints === void 0 ? void 0 : constraints.cloneWithSignature(overloadScopeId);
|
17206
|
+
if (assignType(destType, overload, /* diag */ undefined, constraintsClone, flags, recursionCount)) {
|
17175
17207
|
filteredOverloads.push(overload);
|
17176
|
-
if (
|
17177
|
-
(0, collectionUtils_1.appendArray)(
|
17178
|
-
}
|
17179
|
-
if (srcConstraintsClone) {
|
17180
|
-
(0, collectionUtils_1.appendArray)(srcTypeVarSignatures, srcConstraintsClone.getConstraintSets());
|
17208
|
+
if (constraintsClone) {
|
17209
|
+
(0, collectionUtils_1.appendArray)(typeVarSignatures, constraintsClone.getConstraintSets());
|
17181
17210
|
}
|
17182
17211
|
}
|
17183
17212
|
});
|
@@ -17186,48 +17215,46 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17186
17215
|
return false;
|
17187
17216
|
}
|
17188
17217
|
if (filteredOverloads.length === 1 || (flags & 8 /* AssignTypeFlags.ArgAssignmentFirstPass */) === 0) {
|
17189
|
-
if (
|
17190
|
-
|
17191
|
-
}
|
17192
|
-
if (srcConstraints) {
|
17193
|
-
srcConstraints.addConstraintSets(srcTypeVarSignatures);
|
17218
|
+
if (constraints) {
|
17219
|
+
constraints.addConstraintSets(typeVarSignatures);
|
17194
17220
|
}
|
17195
17221
|
}
|
17196
17222
|
return true;
|
17197
17223
|
}
|
17198
17224
|
if ((0, types_1.isFunction)(concreteSrcType)) {
|
17199
|
-
if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17225
|
+
if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints !== null && constraints !== void 0 ? constraints : new constraintTracker_1.ConstraintTracker(), flags, recursionCount)) {
|
17200
17226
|
return true;
|
17201
17227
|
}
|
17202
17228
|
}
|
17203
17229
|
}
|
17204
|
-
if ((0, types_1.
|
17230
|
+
if ((0, types_1.isOverloaded)(destType)) {
|
17205
17231
|
const overloadDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
17206
17232
|
// All overloads in the dest must be assignable.
|
17207
|
-
const destOverloads = types_1.
|
17233
|
+
const destOverloads = types_1.OverloadedType.getOverloads(destType);
|
17208
17234
|
// If the source is also an overload with the same number of overloads,
|
17209
17235
|
// there's a good chance that there's a one-to-one mapping. Try this
|
17210
17236
|
// first before using an n^2 algorithm.
|
17211
|
-
if ((0, types_1.
|
17212
|
-
const srcOverloads = types_1.
|
17237
|
+
if ((0, types_1.isOverloaded)(srcType)) {
|
17238
|
+
const srcOverloads = types_1.OverloadedType.getOverloads(srcType);
|
17213
17239
|
if (destOverloads.length === srcOverloads.length) {
|
17214
17240
|
if (destOverloads.every((destOverload, index) => {
|
17215
17241
|
const srcOverload = srcOverloads[index];
|
17216
17242
|
return assignType(destOverload, srcOverload,
|
17217
|
-
/* diag */ undefined,
|
17243
|
+
/* diag */ undefined, constraints, flags, recursionCount);
|
17218
17244
|
})) {
|
17219
17245
|
return true;
|
17220
17246
|
}
|
17221
17247
|
}
|
17222
17248
|
}
|
17223
17249
|
const isAssignable = destOverloads.every((destOverload) => {
|
17224
|
-
const result = assignType(destOverload, srcType, overloadDiag === null || overloadDiag === void 0 ? void 0 : overloadDiag.createAddendum(),
|
17250
|
+
const result = assignType(destOverload, srcType, overloadDiag === null || overloadDiag === void 0 ? void 0 : overloadDiag.createAddendum(), constraints, flags, recursionCount);
|
17225
17251
|
return result;
|
17226
17252
|
});
|
17227
17253
|
if (!isAssignable) {
|
17228
|
-
|
17254
|
+
const overloads = types_1.OverloadedType.getOverloads(destType);
|
17255
|
+
if (overloadDiag && overloads.length > 0) {
|
17229
17256
|
overloadDiag.addMessage(localize_1.LocAddendum.overloadNotAssignable().format({
|
17230
|
-
name:
|
17257
|
+
name: overloads[0].shared.name,
|
17231
17258
|
}));
|
17232
17259
|
}
|
17233
17260
|
return false;
|
@@ -17236,8 +17263,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17236
17263
|
}
|
17237
17264
|
if ((0, types_1.isClass)(destType) && types_1.ClassType.isBuiltIn(destType, 'object')) {
|
17238
17265
|
if (((0, types_1.isInstantiableClass)(destType) && types_1.TypeBase.isInstantiable(srcType)) || (0, types_1.isClassInstance)(destType)) {
|
17239
|
-
if ((flags & 1 /* AssignTypeFlags.
|
17240
|
-
// All types (including None, Module,
|
17266
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) === 0) {
|
17267
|
+
// All types (including None, Module, Overloaded) derive from object.
|
17241
17268
|
return true;
|
17242
17269
|
}
|
17243
17270
|
}
|
@@ -17245,7 +17272,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17245
17272
|
// Are we trying to assign None to a protocol?
|
17246
17273
|
if ((0, typeUtils_1.isNoneInstance)(srcType) && (0, types_1.isClassInstance)(destType) && types_1.ClassType.isProtocolClass(destType)) {
|
17247
17274
|
if (noneTypeClass && (0, types_1.isInstantiableClass)(noneTypeClass)) {
|
17248
|
-
return (0, protocols_1.assignClassToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), types_1.ClassType.cloneAsInstance(noneTypeClass), diag,
|
17275
|
+
return (0, protocols_1.assignClassToProtocol)(evaluatorInterface, types_1.ClassType.cloneAsInstantiable(destType), types_1.ClassType.cloneAsInstance(noneTypeClass), diag, constraints, flags, recursionCount);
|
17249
17276
|
}
|
17250
17277
|
}
|
17251
17278
|
if ((0, typeUtils_1.isNoneInstance)(destType)) {
|
@@ -17255,7 +17282,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17255
17282
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
|
17256
17283
|
return false;
|
17257
17284
|
}
|
17258
|
-
function assignFromUnionType(destType, srcType, diag,
|
17285
|
+
function assignFromUnionType(destType, srcType, diag, constraints, flags, recursionCount) {
|
17259
17286
|
// Start by checking for an exact match. This is needed to handle unions
|
17260
17287
|
// that contain recursive type aliases.
|
17261
17288
|
if ((0, types_1.isTypeSame)(srcType, destType, {}, recursionCount)) {
|
@@ -17272,8 +17299,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17272
17299
|
// the getattr function.
|
17273
17300
|
const nonAnySubtypes = destType.priv.subtypes.filter((t) => !(0, types_1.isAnyOrUnknown)(t));
|
17274
17301
|
if (nonAnySubtypes.length === 1 && (0, types_1.isTypeVar)(nonAnySubtypes[0])) {
|
17275
|
-
assignType(nonAnySubtypes[0], srcType,
|
17276
|
-
/* diag */ undefined, destConstraints, srcConstraints, flags, recursionCount);
|
17302
|
+
assignType(nonAnySubtypes[0], srcType, /* diag */ undefined, constraints, flags, recursionCount);
|
17277
17303
|
// This always succeeds because the destination contains Any.
|
17278
17304
|
return true;
|
17279
17305
|
}
|
@@ -17314,14 +17340,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17314
17340
|
if (types_1.ClassType.isTypedDictClass(srcSubtype) && types_1.ClassType.isTypedDictClass(destSubtype)) {
|
17315
17341
|
if (assignType(srcSubtype, destSubtype,
|
17316
17342
|
/* diag */ undefined,
|
17317
|
-
/*
|
17318
|
-
/* srcConstraints */ undefined, flags, recursionCount)) {
|
17343
|
+
/* constraints */ undefined, flags, recursionCount)) {
|
17319
17344
|
return true;
|
17320
17345
|
}
|
17321
17346
|
}
|
17322
17347
|
}
|
17323
|
-
if ((0, types_1.isFunction)(srcSubtype) || (0, types_1.
|
17324
|
-
if ((0, types_1.isFunction)(destSubtype) || (0, types_1.
|
17348
|
+
if ((0, types_1.isFunction)(srcSubtype) || (0, types_1.isOverloaded)(srcSubtype)) {
|
17349
|
+
if ((0, types_1.isFunction)(destSubtype) || (0, types_1.isOverloaded)(destSubtype)) {
|
17325
17350
|
return true;
|
17326
17351
|
}
|
17327
17352
|
}
|
@@ -17329,7 +17354,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17329
17354
|
});
|
17330
17355
|
if (destTypeIndex >= 0) {
|
17331
17356
|
if (assignType(remainingDestSubtypes[destTypeIndex], srcSubtype,
|
17332
|
-
/* diag */ undefined,
|
17357
|
+
/* diag */ undefined, constraints, flags, recursionCount)) {
|
17333
17358
|
// Note that we have matched at least one subtype indicating
|
17334
17359
|
// there is at least some overlap.
|
17335
17360
|
matchedSomeSubtypes = true;
|
@@ -17344,7 +17369,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17344
17369
|
// If there is are remaining dest subtypes and they're all type variables,
|
17345
17370
|
// attempt to assign the remaining source subtypes to them.
|
17346
17371
|
if (canUseFastPath && (remainingDestSubtypes.length !== 0 || remainingSrcSubtypes.length !== 0)) {
|
17347
|
-
if ((flags & 1 /* AssignTypeFlags.
|
17372
|
+
if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
|
17348
17373
|
// If we have no src subtypes remaining but not all dest types have been subsumed
|
17349
17374
|
// by other dest types, then the types are not compatible if we're enforcing invariance.
|
17350
17375
|
if (remainingSrcSubtypes.length === 0) {
|
@@ -17352,8 +17377,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17352
17377
|
/* allowAnyToSubsume */ true, recursionCount));
|
17353
17378
|
}
|
17354
17379
|
}
|
17355
|
-
const
|
17356
|
-
const effectiveDestSubtypes =
|
17380
|
+
const isContra = (flags & 2 /* AssignTypeFlags.Contravariant */) !== 0;
|
17381
|
+
const effectiveDestSubtypes = isContra ? remainingSrcSubtypes : remainingDestSubtypes;
|
17357
17382
|
if (effectiveDestSubtypes.length === 0 || effectiveDestSubtypes.some((t) => !(0, types_1.isTypeVar)(t))) {
|
17358
17383
|
canUseFastPath = false;
|
17359
17384
|
// We can avoid checking the source subtypes that have already been checked.
|
@@ -17366,7 +17391,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17366
17391
|
for (let srcIndex = 0; srcIndex < remainingSrcSubtypes.length; srcIndex++) {
|
17367
17392
|
let foundMatchForSrc = false;
|
17368
17393
|
for (let destIndex = 0; destIndex < reorderedDestSubtypes.length; destIndex++) {
|
17369
|
-
if (assignType(reorderedDestSubtypes[destIndex], remainingSrcSubtypes[srcIndex], diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17394
|
+
if (assignType(reorderedDestSubtypes[destIndex], remainingSrcSubtypes[srcIndex], diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17370
17395
|
foundMatchForSrc = true;
|
17371
17396
|
// Move the matched dest TypeVar to the end of the list so the other
|
17372
17397
|
// dest TypeVars have a better chance of being assigned to.
|
@@ -17383,13 +17408,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17383
17408
|
sortedSrcTypes = remainingSrcSubtypes;
|
17384
17409
|
}
|
17385
17410
|
else if (remainingSrcSubtypes.length === 0) {
|
17386
|
-
if ((flags & 2048 /* AssignTypeFlags.
|
17411
|
+
if ((flags & 2048 /* AssignTypeFlags.PopulateExpectedType */) !== 0) {
|
17387
17412
|
// If we're populating an expected type, try not to leave
|
17388
17413
|
// any TypeVars unsolved. Assign the full type to the remaining
|
17389
17414
|
// dest TypeVars.
|
17390
17415
|
remainingDestSubtypes.forEach((destSubtype) => {
|
17391
|
-
assignType(destSubtype, srcType,
|
17392
|
-
/* diag */ undefined, destConstraints, srcConstraints, flags, recursionCount);
|
17416
|
+
assignType(destSubtype, srcType, /* diag */ undefined, constraints, flags, recursionCount);
|
17393
17417
|
});
|
17394
17418
|
}
|
17395
17419
|
// If we've assigned all of the source subtypes but one or more dest
|
@@ -17398,7 +17422,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17398
17422
|
else {
|
17399
17423
|
// Try to assign a union of the remaining source types to
|
17400
17424
|
// the first destination TypeVar.
|
17401
|
-
if (!assignType(
|
17425
|
+
if (!assignType(isContra ? (0, types_1.combineTypes)(remainingDestSubtypes) : remainingDestSubtypes[0], isContra ? remainingSrcSubtypes[0] : (0, types_1.combineTypes)(remainingSrcSubtypes), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17402
17426
|
canUseFastPath = false;
|
17403
17427
|
}
|
17404
17428
|
}
|
@@ -17417,15 +17441,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17417
17441
|
if (isIncompatible) {
|
17418
17442
|
return;
|
17419
17443
|
}
|
17420
|
-
if (!assignType(destType, subtype,
|
17421
|
-
/* diag */ undefined, destConstraints, srcConstraints, flags, recursionCount)) {
|
17444
|
+
if (!assignType(destType, subtype, /* diag */ undefined, constraints, flags, recursionCount)) {
|
17422
17445
|
// Determine if the current subtype is subsumed by another subtype
|
17423
17446
|
// in the same union. If so, we can ignore this.
|
17424
17447
|
const isSubtypeSubsumed = isTypeSubsumedByOtherType(subtype, srcType,
|
17425
17448
|
/* allowAnyToSubsume */ false, recursionCount);
|
17426
17449
|
// Try again with a concrete version of the subtype.
|
17427
17450
|
if (!isSubtypeSubsumed &&
|
17428
|
-
!assignType(destType, subtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17451
|
+
!assignType(destType, subtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17429
17452
|
isIncompatible = true;
|
17430
17453
|
}
|
17431
17454
|
}
|
@@ -17450,6 +17473,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17450
17473
|
}
|
17451
17474
|
return types_1.ClassType.isSpecialFormClass(classType);
|
17452
17475
|
}
|
17476
|
+
// Finds unsolved type variables in the destType and establishes constraints
|
17477
|
+
// in the constraint tracker for them based on the srcType.
|
17478
|
+
function setConstraintsForFreeTypeVars(destType, srcType, constraints) {
|
17479
|
+
if (constraints.isLocked()) {
|
17480
|
+
return;
|
17481
|
+
}
|
17482
|
+
const typeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(destType);
|
17483
|
+
typeVars.forEach((typeVar) => {
|
17484
|
+
if (!types_1.TypeVarType.isBound(typeVar) && !constraints.getMainConstraintSet().getTypeVar(typeVar)) {
|
17485
|
+
// Don't set ParamSpecs or TypeVarTuples.
|
17486
|
+
if (!(0, types_1.isParamSpec)(srcType) && !(0, types_1.isTypeVarTuple)(srcType)) {
|
17487
|
+
constraints.setBounds(typeVar, srcType);
|
17488
|
+
}
|
17489
|
+
}
|
17490
|
+
});
|
17491
|
+
}
|
17453
17492
|
// Determines whether a type is "subsumed by" (i.e. is a proper subtype of) another type.
|
17454
17493
|
function isTypeSubsumedByOtherType(type, otherType, allowAnyToSubsume, recursionCount = 0) {
|
17455
17494
|
const concreteType = makeTopLevelTypeVarsConcrete(type);
|
@@ -17492,22 +17531,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17492
17531
|
}
|
17493
17532
|
return (assignType(destType, srcType,
|
17494
17533
|
/* diag */ undefined,
|
17495
|
-
/*
|
17496
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount) &&
|
17534
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount) &&
|
17497
17535
|
!assignType(srcType, destType,
|
17498
17536
|
/* diag */ undefined,
|
17499
|
-
/*
|
17500
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount));
|
17537
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount));
|
17501
17538
|
}
|
17502
|
-
function assignToUnionType(destType, srcType, diag,
|
17539
|
+
function assignToUnionType(destType, srcType, diag, constraints, flags, recursionCount) {
|
17503
17540
|
// If we need to enforce invariance, the source needs to be compatible
|
17504
17541
|
// with all subtypes in the dest, unless those subtypes are subclasses
|
17505
17542
|
// of other subtypes.
|
17506
|
-
if (flags & 1 /* AssignTypeFlags.
|
17543
|
+
if (flags & 1 /* AssignTypeFlags.Invariant */) {
|
17507
17544
|
let isIncompatible = false;
|
17508
17545
|
(0, typeUtils_1.doForEachSubtype)(destType, (subtype, index) => {
|
17509
17546
|
if (!isIncompatible &&
|
17510
|
-
!assignType(subtype, srcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17547
|
+
!assignType(subtype, srcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17511
17548
|
// Determine whether this subtype is subsumed by some other
|
17512
17549
|
// subtype in the union. If so, we can ignore the incompatibility.
|
17513
17550
|
let skipSubtype = false;
|
@@ -17518,8 +17555,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17518
17555
|
const adjOtherSubtype = (0, typeUtils_1.makeTypeVarsBound)(otherSubtype, /* scopeIds */ undefined);
|
17519
17556
|
if (assignType(adjOtherSubtype, adjSubtype,
|
17520
17557
|
/* diag */ undefined,
|
17521
|
-
/*
|
17522
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
17558
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
17523
17559
|
skipSubtype = true;
|
17524
17560
|
}
|
17525
17561
|
}
|
@@ -17543,7 +17579,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17543
17579
|
// If so, we need to use a slower path.
|
17544
17580
|
if (!(0, typeUtils_1.requiresSpecialization)(destType)) {
|
17545
17581
|
for (const subtype of destType.priv.subtypes) {
|
17546
|
-
if (assignType(subtype, srcType, diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(),
|
17582
|
+
if (assignType(subtype, srcType, diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(), constraints, flags, recursionCount)) {
|
17547
17583
|
foundMatch = true;
|
17548
17584
|
break;
|
17549
17585
|
}
|
@@ -17558,8 +17594,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17558
17594
|
foundMatch = true;
|
17559
17595
|
}
|
17560
17596
|
else {
|
17561
|
-
let
|
17562
|
-
let bestSrcConstraints;
|
17597
|
+
let bestConstraints;
|
17563
17598
|
let bestConstraintsScore;
|
17564
17599
|
let nakedTypeVarMatches = 0;
|
17565
17600
|
// If the srcType is a literal, try to use the fast-path lookup
|
@@ -17572,16 +17607,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17572
17607
|
(0, typeUtils_1.doForEachSubtype)(destType, (subtype) => {
|
17573
17608
|
// Make a temporary clone of the constraints. We don't want to modify
|
17574
17609
|
// the original constraints until we find the "optimal" typeVar mapping.
|
17575
|
-
const
|
17576
|
-
|
17577
|
-
if (assignType(subtype, srcType, diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(), destConstraintsClone, srcConstraintsClone, flags, recursionCount)) {
|
17610
|
+
const constraintsClone = constraints === null || constraints === void 0 ? void 0 : constraints.clone();
|
17611
|
+
if (assignType(subtype, srcType, diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(), constraintsClone, flags, recursionCount)) {
|
17578
17612
|
foundMatch = true;
|
17579
|
-
if (
|
17613
|
+
if (constraintsClone) {
|
17580
17614
|
// Ask the constraints to compute a "score" for the current
|
17581
17615
|
// contents of the table.
|
17582
|
-
let constraintsScore =
|
17616
|
+
let constraintsScore = constraintsClone.getScore();
|
17583
17617
|
if ((0, types_1.isTypeVar)(subtype)) {
|
17584
|
-
if (!(
|
17618
|
+
if (!(constraints === null || constraints === void 0 ? void 0 : constraints.getMainConstraintSet().getTypeVar(subtype))) {
|
17585
17619
|
nakedTypeVarMatches++;
|
17586
17620
|
// Handicap the solution slightly so another type var with
|
17587
17621
|
// existing constraints will be preferred.
|
@@ -17595,8 +17629,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17595
17629
|
if (bestConstraintsScore === undefined || bestConstraintsScore <= constraintsScore) {
|
17596
17630
|
// We found a typeVar mapping with a higher score than before.
|
17597
17631
|
bestConstraintsScore = constraintsScore;
|
17598
|
-
|
17599
|
-
bestSrcConstraints = srcConstraintsClone;
|
17632
|
+
bestConstraints = constraintsClone;
|
17600
17633
|
}
|
17601
17634
|
}
|
17602
17635
|
}
|
@@ -17608,15 +17641,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17608
17641
|
// Typically, they will receive some constraints via some
|
17609
17642
|
// later argument assignment.
|
17610
17643
|
if (nakedTypeVarMatches > 1 && (flags & 8 /* AssignTypeFlags.ArgAssignmentFirstPass */) !== 0) {
|
17611
|
-
|
17612
|
-
bestSrcConstraints = undefined;
|
17644
|
+
bestConstraints = undefined;
|
17613
17645
|
}
|
17614
17646
|
// If we found a winning type var mapping, copy it back to constraints.
|
17615
|
-
if (
|
17616
|
-
|
17617
|
-
}
|
17618
|
-
if (srcConstraints && bestSrcConstraints) {
|
17619
|
-
srcConstraints.copyFromClone(bestSrcConstraints);
|
17647
|
+
if (constraints && bestConstraints) {
|
17648
|
+
constraints.copyFromClone(bestConstraints);
|
17620
17649
|
}
|
17621
17650
|
}
|
17622
17651
|
}
|
@@ -17624,7 +17653,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17624
17653
|
// constraints to the union.
|
17625
17654
|
if (!foundMatch) {
|
17626
17655
|
if ((0, types_1.isTypeVar)(srcType) && types_1.TypeVarType.hasConstraints(srcType)) {
|
17627
|
-
foundMatch = assignType(destType, makeTopLevelTypeVarsConcrete(srcType), diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(),
|
17656
|
+
foundMatch = assignType(destType, makeTopLevelTypeVarsConcrete(srcType), diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum(), constraints, flags, recursionCount);
|
17628
17657
|
}
|
17629
17658
|
}
|
17630
17659
|
if (!foundMatch) {
|
@@ -17660,15 +17689,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17660
17689
|
(0, debug_1.assert)(condition.constraintIndex === 0, 'Expected constraint for bound TypeVar to have index of 0');
|
17661
17690
|
return assignType(destType.shared.boundType, srcSubtype,
|
17662
17691
|
/* diag */ undefined,
|
17663
|
-
/*
|
17664
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
17692
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
17665
17693
|
}
|
17666
17694
|
if (types_1.TypeVarType.hasConstraints(destType)) {
|
17667
17695
|
(0, debug_1.assert)(condition.constraintIndex < destType.shared.constraints.length, 'Constraint for constrained TypeVar is out of bounds');
|
17668
17696
|
return assignType(destType.shared.constraints[condition.constraintIndex], srcSubtype,
|
17669
17697
|
/* diag */ undefined,
|
17670
|
-
/*
|
17671
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
17698
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
17672
17699
|
}
|
17673
17700
|
// This is a non-bound and non-constrained type variable with a matching condition.
|
17674
17701
|
return true;
|
@@ -17704,9 +17731,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17704
17731
|
}
|
17705
17732
|
}
|
17706
17733
|
}
|
17707
|
-
|
17734
|
+
const callType = getBoundMagicMethod(objType, '__call__',
|
17735
|
+
/* selfType */ undefined,
|
17736
|
+
/* diag */ undefined, recursionCount);
|
17737
|
+
if (!callType) {
|
17738
|
+
return undefined;
|
17739
|
+
}
|
17740
|
+
return (0, typeUtils_1.makeFunctionTypeVarsBound)(callType);
|
17708
17741
|
}
|
17709
|
-
function assignParam(destType, srcType, paramIndex, diag,
|
17742
|
+
function assignParam(destType, srcType, paramIndex, diag, constraints, flags, recursionCount) {
|
17710
17743
|
// Handle the special case where the dest type is a synthesized
|
17711
17744
|
// "self" for a protocol class.
|
17712
17745
|
if ((0, types_1.isTypeVar)(destType) &&
|
@@ -17724,19 +17757,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17724
17757
|
let doSpecializationStep = false;
|
17725
17758
|
if ((flags & 16 /* AssignTypeFlags.OverloadOverlap */) === 0) {
|
17726
17759
|
const isFirstPass = (flags & 8 /* AssignTypeFlags.ArgAssignmentFirstPass */) !== 0;
|
17727
|
-
if ((flags & 2 /* AssignTypeFlags.
|
17760
|
+
if ((flags & 2 /* AssignTypeFlags.Contravariant */) === 0) {
|
17728
17761
|
if (!isFirstPass) {
|
17729
|
-
specializedDestType = solveAndApplyConstraints(destType,
|
17730
|
-
/* applyOptions */ undefined, {
|
17731
|
-
useLowerBoundOnly: true,
|
17732
|
-
});
|
17762
|
+
specializedDestType = solveAndApplyConstraints(destType, constraints,
|
17763
|
+
/* applyOptions */ undefined, { useLowerBoundOnly: true });
|
17733
17764
|
}
|
17734
17765
|
doSpecializationStep = (0, typeUtils_1.requiresSpecialization)(specializedDestType);
|
17735
17766
|
}
|
17736
17767
|
else {
|
17737
17768
|
if (!isFirstPass) {
|
17738
|
-
specializedSrcType = solveAndApplyConstraints(srcType,
|
17739
|
-
/* applyOptions */ undefined, {
|
17769
|
+
specializedSrcType = solveAndApplyConstraints(srcType, constraints, /* applyOptions */ undefined, {
|
17740
17770
|
useLowerBoundOnly: true,
|
17741
17771
|
});
|
17742
17772
|
}
|
@@ -17746,16 +17776,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17746
17776
|
// Is an additional specialization step required?
|
17747
17777
|
if (doSpecializationStep) {
|
17748
17778
|
if (assignType(specializedSrcType, specializedDestType,
|
17749
|
-
/* diag */ undefined,
|
17750
|
-
|
17751
|
-
specializedDestType = solveAndApplyConstraints(destType, destConstraints);
|
17752
|
-
}
|
17753
|
-
else {
|
17754
|
-
specializedSrcType = solveAndApplyConstraints(srcType, srcConstraints);
|
17755
|
-
}
|
17779
|
+
/* diag */ undefined, constraints, (flags ^ 2 /* AssignTypeFlags.Contravariant */) | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */, recursionCount)) {
|
17780
|
+
specializedDestType = solveAndApplyConstraints(destType, constraints);
|
17756
17781
|
}
|
17757
17782
|
}
|
17758
|
-
if (!assignType(specializedSrcType, specializedDestType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17783
|
+
if (!assignType(specializedSrcType, specializedDestType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17759
17784
|
if (diag && paramIndex !== undefined) {
|
17760
17785
|
diag.addMessage(localize_1.LocAddendum.paramAssignment().format({
|
17761
17786
|
index: paramIndex + 1,
|
@@ -17818,7 +17843,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17818
17843
|
}
|
17819
17844
|
});
|
17820
17845
|
if (srcTupleTypes.length !== 1 || !(0, types_1.isTypeVarTuple)(srcTupleTypes[0].type)) {
|
17821
|
-
const srcPositionalsType = makeTupleObject(srcTupleTypes, /*
|
17846
|
+
const srcPositionalsType = makeTupleObject(srcTupleTypes, /* isUnpacked */ true);
|
17822
17847
|
// Snip out the portion of the source positionals that map to the variadic
|
17823
17848
|
// dest parameter and replace it with a single parameter that is typed as a
|
17824
17849
|
// tuple containing the individual types of the replaced parameters.
|
@@ -17842,11 +17867,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17842
17867
|
srcDetails.positionOnlyParamCount = Math.max(0, srcDetails.params.findIndex((p) => p.kind !== parameterUtils_1.ParamKind.Positional || p.param.category !== 0 /* ParamCategory.Simple */ || !!p.defaultType));
|
17843
17868
|
}
|
17844
17869
|
}
|
17845
|
-
function assignFunction(destType, srcType, diag,
|
17870
|
+
function assignFunction(destType, srcType, diag, constraints, flags, recursionCount) {
|
17846
17871
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
17847
17872
|
let canAssign = true;
|
17848
17873
|
const checkReturnType = (flags & 64 /* AssignTypeFlags.SkipReturnTypeCheck */) === 0;
|
17849
|
-
const
|
17874
|
+
const isContra = (flags & 2 /* AssignTypeFlags.Contravariant */) !== 0;
|
17850
17875
|
flags &= ~64 /* AssignTypeFlags.SkipReturnTypeCheck */;
|
17851
17876
|
const destParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(destType);
|
17852
17877
|
if (destParamSpec) {
|
@@ -17858,8 +17883,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17858
17883
|
}
|
17859
17884
|
const destParamDetails = (0, parameterUtils_1.getParamListDetails)(destType);
|
17860
17885
|
const srcParamDetails = (0, parameterUtils_1.getParamListDetails)(srcType);
|
17861
|
-
adjustSourceParamDetailsForDestVariadic(
|
17862
|
-
const targetIncludesParamSpec =
|
17886
|
+
adjustSourceParamDetailsForDestVariadic(isContra ? destParamDetails : srcParamDetails, isContra ? srcParamDetails : destParamDetails);
|
17887
|
+
const targetIncludesParamSpec = isContra ? !!srcParamSpec : !!destParamSpec;
|
17863
17888
|
const destPositionalCount = (_a = destParamDetails.firstKeywordOnlyIndex) !== null && _a !== void 0 ? _a : destParamDetails.params.length;
|
17864
17889
|
const srcPositionalCount = (_b = srcParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : srcParamDetails.params.length;
|
17865
17890
|
const positionalsToMatch = Math.min(destPositionalCount, srcPositionalCount);
|
@@ -17924,7 +17949,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17924
17949
|
if ((0, types_1.isUnpacked)(srcParamType)) {
|
17925
17950
|
canAssign = false;
|
17926
17951
|
}
|
17927
|
-
else if (!assignParam(destParamType, srcParamType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17952
|
+
else if (!assignParam(destParamType, srcParamType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17928
17953
|
// Handle the special case where the source parameter is a synthesized
|
17929
17954
|
// TypeVar for "self" or "cls".
|
17930
17955
|
if ((flags & 512 /* AssignTypeFlags.SkipSelfClsTypeCheck */) === 0 ||
|
@@ -17961,7 +17986,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17961
17986
|
if (destParamDetails.argsIndex !== undefined) {
|
17962
17987
|
const destArgsType = destParamDetails.params[destParamDetails.argsIndex].type;
|
17963
17988
|
const srcParamType = srcParamDetails.params[i].type;
|
17964
|
-
if (!assignParam(destArgsType, srcParamType, i, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17989
|
+
if (!assignParam(destArgsType, srcParamType, i, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17965
17990
|
canAssign = false;
|
17966
17991
|
}
|
17967
17992
|
continue;
|
@@ -17974,9 +17999,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
17974
17999
|
// populating TypeVar constraints.
|
17975
18000
|
const paramInfo = srcParamDetails.params[i];
|
17976
18001
|
const defaultArgType = (_f = paramInfo.defaultType) !== null && _f !== void 0 ? _f : paramInfo.defaultType;
|
18002
|
+
// Enforce invariance below because the default arg value
|
18003
|
+
// is constructed prior to the call, so its type is already
|
18004
|
+
// fixed.
|
17977
18005
|
if (defaultArgType &&
|
17978
|
-
!assignType(paramInfo.type, defaultArgType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
17979
|
-
/* destConstraints */ undefined, flags, recursionCount)) {
|
18006
|
+
!assignType(paramInfo.type, defaultArgType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
17980
18007
|
canAssign = false;
|
17981
18008
|
}
|
17982
18009
|
continue;
|
@@ -18015,7 +18042,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18015
18042
|
canAssign = false;
|
18016
18043
|
}
|
18017
18044
|
else {
|
18018
|
-
if (!assignParam(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18045
|
+
if (!assignParam(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18019
18046
|
canAssign = false;
|
18020
18047
|
}
|
18021
18048
|
if (destParamDetails.params[paramIndex].kind !== parameterUtils_1.ParamKind.Positional &&
|
@@ -18052,12 +18079,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18052
18079
|
let destArgsType = destParamDetails.params[destParamDetails.argsIndex].type;
|
18053
18080
|
let srcArgsType = srcParamDetails.params[srcParamDetails.argsIndex].type;
|
18054
18081
|
if (!(0, types_1.isUnpacked)(destArgsType)) {
|
18055
|
-
destArgsType = makeTupleObject([{ type: destArgsType, isUnbounded: true }], /*
|
18082
|
+
destArgsType = makeTupleObject([{ type: destArgsType, isUnbounded: true }], /* isUnpacked */ true);
|
18056
18083
|
}
|
18057
18084
|
if (!(0, types_1.isUnpacked)(srcArgsType)) {
|
18058
|
-
srcArgsType = makeTupleObject([{ type: srcArgsType, isUnbounded: true }], /*
|
18085
|
+
srcArgsType = makeTupleObject([{ type: srcArgsType, isUnbounded: true }], /* isUnpacked */ true);
|
18059
18086
|
}
|
18060
|
-
if (!assignParam(destArgsType, srcArgsType, destParamDetails.params[destParamDetails.argsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18087
|
+
if (!assignParam(destArgsType, srcArgsType, destParamDetails.params[destParamDetails.argsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18061
18088
|
canAssign = false;
|
18062
18089
|
}
|
18063
18090
|
}
|
@@ -18115,7 +18142,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18115
18142
|
}
|
18116
18143
|
else if (destParamDetails.kwargsIndex !== undefined) {
|
18117
18144
|
// Make sure we can assign the type to the Kwargs.
|
18118
|
-
if (!assignParam(destParamDetails.params[destParamDetails.kwargsIndex].type, srcParamType, destParamDetails.params[destParamDetails.kwargsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18145
|
+
if (!assignParam(destParamDetails.params[destParamDetails.kwargsIndex].type, srcParamType, destParamDetails.params[destParamDetails.kwargsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18119
18146
|
canAssign = false;
|
18120
18147
|
}
|
18121
18148
|
}
|
@@ -18124,19 +18151,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18124
18151
|
// populating TypeVar constraints.
|
18125
18152
|
const defaultArgType = (_a = srcParamInfo.defaultType) !== null && _a !== void 0 ? _a : srcParamInfo.defaultType;
|
18126
18153
|
if (defaultArgType &&
|
18127
|
-
!assignType(srcParamInfo.type, defaultArgType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18128
|
-
/* destConstraints */ undefined, flags, recursionCount)) {
|
18154
|
+
!assignType(srcParamInfo.type, defaultArgType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18129
18155
|
canAssign = false;
|
18130
18156
|
}
|
18131
18157
|
}
|
18132
18158
|
}
|
18133
18159
|
else {
|
18134
18160
|
const destParamType = destParamInfo.type;
|
18135
|
-
const specializedDestParamType =
|
18136
|
-
? solveAndApplyConstraints(destParamType,
|
18161
|
+
const specializedDestParamType = constraints
|
18162
|
+
? solveAndApplyConstraints(destParamType, constraints)
|
18137
18163
|
: destParamType;
|
18138
18164
|
if (!assignParam(destParamInfo.type, srcParamType,
|
18139
|
-
/* paramIndex */ undefined, paramDiag === null || paramDiag === void 0 ? void 0 : paramDiag.createAddendum(),
|
18165
|
+
/* paramIndex */ undefined, paramDiag === null || paramDiag === void 0 ? void 0 : paramDiag.createAddendum(), constraints, flags, recursionCount)) {
|
18140
18166
|
if (paramDiag) {
|
18141
18167
|
paramDiag.addMessage(localize_1.LocAddendum.namedParamTypeMismatch().format({
|
18142
18168
|
name: srcParamInfo.param.name,
|
@@ -18162,7 +18188,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18162
18188
|
destParamMap.forEach((destParamInfo, paramName) => {
|
18163
18189
|
if (srcParamDetails.kwargsIndex !== undefined && destParamInfo.param.name) {
|
18164
18190
|
// Make sure the src kwargs type is compatible.
|
18165
|
-
if (!assignParam(destParamInfo.type, srcParamDetails.params[srcParamDetails.kwargsIndex].type, destParamInfo.index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18191
|
+
if (!assignParam(destParamInfo.type, srcParamDetails.params[srcParamDetails.kwargsIndex].type, destParamInfo.index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18166
18192
|
canAssign = false;
|
18167
18193
|
}
|
18168
18194
|
destParamMap.delete(paramName);
|
@@ -18174,7 +18200,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18174
18200
|
});
|
18175
18201
|
// If both src and dest have a "**kwargs" parameter, make sure their types are compatible.
|
18176
18202
|
if (srcParamDetails.kwargsIndex !== undefined && destParamDetails.kwargsIndex !== undefined) {
|
18177
|
-
if (!assignParam(destParamDetails.params[destParamDetails.kwargsIndex].type, srcParamDetails.params[srcParamDetails.kwargsIndex].type, destParamDetails.params[destParamDetails.kwargsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18203
|
+
if (!assignParam(destParamDetails.params[destParamDetails.kwargsIndex].type, srcParamDetails.params[srcParamDetails.kwargsIndex].type, destParamDetails.params[destParamDetails.kwargsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18178
18204
|
canAssign = false;
|
18179
18205
|
}
|
18180
18206
|
}
|
@@ -18197,26 +18223,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18197
18223
|
canAssign = false;
|
18198
18224
|
}
|
18199
18225
|
}
|
18200
|
-
// If the target function was generic and we solved some of the type variables
|
18201
|
-
// in that generic type, assign them back to the destination typeVar.
|
18202
|
-
const effectiveSrcConstraints = reverseMatching ? destConstraints : srcConstraints;
|
18203
|
-
if (!effectiveSrcConstraints.isEmpty()) {
|
18204
|
-
const srcConstraintSet = effectiveSrcConstraints.getMainConstraintSet();
|
18205
|
-
const solutionSet = (0, constraintSolver_1.solveConstraints)(evaluatorInterface, effectiveSrcConstraints).getMainSolutionSet();
|
18206
|
-
srcConstraintSet.doForEachTypeVar((entry) => {
|
18207
|
-
const solvedValue = solutionSet.getType(entry.typeVar);
|
18208
|
-
if (solvedValue) {
|
18209
|
-
assignType(entry.typeVar, solvedValue,
|
18210
|
-
/* diag */ undefined, destConstraints, srcConstraints, 0 /* AssignTypeFlags.Default */, recursionCount);
|
18211
|
-
}
|
18212
|
-
});
|
18213
|
-
}
|
18214
18226
|
// Are we assigning to a function with a ParamSpec?
|
18215
18227
|
if (targetIncludesParamSpec) {
|
18216
|
-
const effectiveSrcType =
|
18217
|
-
const effectiveDestType =
|
18218
|
-
const effectiveSrcParamSpec =
|
18219
|
-
const effectiveDestParamSpec =
|
18228
|
+
const effectiveSrcType = isContra ? destType : srcType;
|
18229
|
+
const effectiveDestType = isContra ? srcType : destType;
|
18230
|
+
const effectiveSrcParamSpec = isContra ? destParamSpec : srcParamSpec;
|
18231
|
+
const effectiveDestParamSpec = isContra ? srcParamSpec : destParamSpec;
|
18220
18232
|
if (effectiveDestParamSpec) {
|
18221
18233
|
const requiredMatchParamCount = effectiveDestType.shared.parameters.filter((p, i) => {
|
18222
18234
|
if (!p.name) {
|
@@ -18265,15 +18277,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18265
18277
|
if (effectiveSrcParamSpec) {
|
18266
18278
|
types_1.FunctionType.addParamSpecVariadics(remainingFunction, (0, typeUtils_1.convertToInstance)(effectiveSrcParamSpec));
|
18267
18279
|
}
|
18268
|
-
if (!assignType(effectiveDestParamSpec, remainingFunction,
|
18269
|
-
/* diag */ undefined, destConstraints, srcConstraints, flags)) {
|
18280
|
+
if (!assignType(effectiveDestParamSpec, remainingFunction, /* diag */ undefined, constraints, flags)) {
|
18270
18281
|
// If we couldn't assign the function to the ParamSpec, see if we can
|
18271
18282
|
// assign only the ParamSpec. This is possible if there were no
|
18272
18283
|
// remaining parameters.
|
18273
18284
|
if (remainingParams.length > 0 ||
|
18274
18285
|
!effectiveSrcParamSpec ||
|
18275
18286
|
!assignType((0, typeUtils_1.convertToInstance)(effectiveDestParamSpec), (0, typeUtils_1.convertToInstance)(effectiveSrcParamSpec),
|
18276
|
-
/* diag */ undefined,
|
18287
|
+
/* diag */ undefined, constraints, flags)) {
|
18277
18288
|
canAssign = false;
|
18278
18289
|
}
|
18279
18290
|
}
|
@@ -18282,9 +18293,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18282
18293
|
}
|
18283
18294
|
// Match the return parameter.
|
18284
18295
|
if (checkReturnType) {
|
18285
|
-
const destReturnType =
|
18296
|
+
const destReturnType = getEffectiveReturnType(destType);
|
18286
18297
|
if (!(0, types_1.isAnyOrUnknown)(destReturnType)) {
|
18287
|
-
const srcReturnType = solveAndApplyConstraints(
|
18298
|
+
const srcReturnType = solveAndApplyConstraints(getEffectiveReturnType(srcType), constraints);
|
18288
18299
|
const returnDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
18289
18300
|
let isReturnTypeCompatible = false;
|
18290
18301
|
let effectiveFlags = flags;
|
@@ -18295,7 +18306,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18295
18306
|
(0, typeUtils_1.containsLiteralType)(srcType.shared.declaredReturnType, /* includeTypeArgs */ true)) {
|
18296
18307
|
effectiveFlags |= 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
18297
18308
|
}
|
18298
|
-
if (assignType(destReturnType, srcReturnType, returnDiag === null || returnDiag === void 0 ? void 0 : returnDiag.createAddendum(),
|
18309
|
+
if (assignType(destReturnType, srcReturnType, returnDiag === null || returnDiag === void 0 ? void 0 : returnDiag.createAddendum(), constraints, effectiveFlags, recursionCount)) {
|
18299
18310
|
isReturnTypeCompatible = true;
|
18300
18311
|
}
|
18301
18312
|
else {
|
@@ -18306,7 +18317,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18306
18317
|
types_1.ClassType.isBuiltIn(srcReturnType, ['TypeGuard', 'TypeIs']) &&
|
18307
18318
|
boolClass &&
|
18308
18319
|
(0, types_1.isInstantiableClass)(boolClass)) {
|
18309
|
-
if (assignType(destReturnType, types_1.ClassType.cloneAsInstance(boolClass), returnDiag === null || returnDiag === void 0 ? void 0 : returnDiag.createAddendum(),
|
18320
|
+
if (assignType(destReturnType, types_1.ClassType.cloneAsInstance(boolClass), returnDiag === null || returnDiag === void 0 ? void 0 : returnDiag.createAddendum(), constraints, flags, recursionCount)) {
|
18310
18321
|
isReturnTypeCompatible = true;
|
18311
18322
|
}
|
18312
18323
|
}
|
@@ -18322,9 +18333,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18322
18333
|
}
|
18323
18334
|
}
|
18324
18335
|
}
|
18325
|
-
// Apply any solved source TypeVars to the dest TypeVar solutions. This
|
18326
|
-
// allows for higher-order functions to accept generic callbacks.
|
18327
|
-
(0, typeUtils_1.applySourceContextTypeVars)(destConstraints, (0, constraintSolver_1.solveConstraints)(evaluatorInterface, srcConstraints));
|
18328
18336
|
return canAssign;
|
18329
18337
|
}
|
18330
18338
|
// If the declaredType contains type arguments that are "Any" and
|
@@ -18470,7 +18478,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18470
18478
|
function validateOverrideMethod(baseMethod, overrideMethod, baseClass, diag, enforceParamNames = true) {
|
18471
18479
|
// If we're overriding a non-method with a method, report it as an error.
|
18472
18480
|
// This occurs when a non-property overrides a property.
|
18473
|
-
if (!(0, types_1.isFunction)(baseMethod) && !(0, types_1.
|
18481
|
+
if (!(0, types_1.isFunction)(baseMethod) && !(0, types_1.isOverloaded)(baseMethod)) {
|
18474
18482
|
diag.addMessage(localize_1.LocAddendum.overrideType().format({ type: printType(baseMethod) }));
|
18475
18483
|
return false;
|
18476
18484
|
}
|
@@ -18479,9 +18487,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18479
18487
|
if ((0, types_1.isFunction)(overrideMethod)) {
|
18480
18488
|
return validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames);
|
18481
18489
|
}
|
18490
|
+
const overloadsAndImpl = [...types_1.OverloadedType.getOverloads(overrideMethod)];
|
18491
|
+
const impl = types_1.OverloadedType.getImplementation(overrideMethod);
|
18492
|
+
if (impl && (0, types_1.isFunction)(impl)) {
|
18493
|
+
overloadsAndImpl.push(impl);
|
18494
|
+
}
|
18482
18495
|
// For an overload overriding a base method, at least one overload
|
18483
18496
|
// or the implementation must be compatible with the base method.
|
18484
|
-
if (
|
18497
|
+
if (overloadsAndImpl.some((overrideOverload) => {
|
18485
18498
|
return validateOverrideMethodInternal(baseMethod, overrideOverload,
|
18486
18499
|
/* diag */ undefined, enforceParamNames);
|
18487
18500
|
})) {
|
@@ -18493,7 +18506,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18493
18506
|
// For a non-overloaded method overriding an overloaded method, the
|
18494
18507
|
// override must match all of the overloads.
|
18495
18508
|
if ((0, types_1.isFunction)(overrideMethod)) {
|
18496
|
-
return types_1.
|
18509
|
+
return types_1.OverloadedType.getOverloads(baseMethod).every((overload) => {
|
18497
18510
|
// If the override isn't applicable for this base class, skip the check.
|
18498
18511
|
if (baseClass && !isOverrideMethodApplicable(overload, baseClass)) {
|
18499
18512
|
return true;
|
@@ -18505,8 +18518,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18505
18518
|
// must all match and be in the correct order. It is OK if the base method
|
18506
18519
|
// has additional overloads that are not present in the override.
|
18507
18520
|
let previousMatchIndex = -1;
|
18508
|
-
const baseOverloads = types_1.
|
18509
|
-
for (const overrideOverload of types_1.
|
18521
|
+
const baseOverloads = types_1.OverloadedType.getOverloads(baseMethod);
|
18522
|
+
for (const overrideOverload of types_1.OverloadedType.getOverloads(overrideMethod)) {
|
18510
18523
|
let possibleMatchIndex;
|
18511
18524
|
let matchIndex = baseOverloads.findIndex((baseOverload, index) => {
|
18512
18525
|
// If the override isn't applicable for this base class, skip the check.
|
@@ -18580,8 +18593,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18580
18593
|
: childClass;
|
18581
18594
|
return assignType(baseParamDetails.params[0].type, childSelfOrClsType,
|
18582
18595
|
/* diag */ undefined,
|
18583
|
-
/*
|
18584
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */);
|
18596
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */);
|
18585
18597
|
}
|
18586
18598
|
// Determines whether the override method is compatible with the overridden method.
|
18587
18599
|
// This is used both for parent/child overrides and implicit overrides for peer
|
@@ -18627,8 +18639,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18627
18639
|
const overrideArgsType = overrideParamDetails.params[overrideParamDetails.argsIndex].type;
|
18628
18640
|
for (let i = overrideParamDetails.positionParamCount; i < baseParamDetails.positionParamCount; i++) {
|
18629
18641
|
if (!assignType(overrideArgsType, baseParamDetails.params[i].type, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18630
|
-
/*
|
18631
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18642
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18632
18643
|
localize_1.LocAddendum.overrideParamType().format({
|
18633
18644
|
index: i + 1,
|
18634
18645
|
baseType: printType(baseParamDetails.params[i].type),
|
@@ -18717,8 +18728,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18717
18728
|
if (!exemptSelfClsParam || (!baseIsSynthesizedTypeVar && !overrideIsSynthesizedTypeVar)) {
|
18718
18729
|
if (baseParam.category !== overrideParam.category ||
|
18719
18730
|
!assignType(overrideParamType, baseParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18720
|
-
/*
|
18721
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18731
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18722
18732
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.overrideParamType().format({
|
18723
18733
|
index: i + 1,
|
18724
18734
|
baseType: printType(baseParamType),
|
@@ -18761,8 +18771,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18761
18771
|
const overrideParamType = overrideParamDetails.params[overrideParamDetails.argsIndex].type;
|
18762
18772
|
const baseParamType = baseParamDetails.params[baseParamDetails.argsIndex].type;
|
18763
18773
|
if (!assignType(overrideParamType, baseParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18764
|
-
/*
|
18765
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18774
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18766
18775
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.overrideParamKeywordType().format({
|
18767
18776
|
name: (_b = overrideParamDetails.params[overrideParamDetails.argsIndex].param.name) !== null && _b !== void 0 ? _b : '?',
|
18768
18777
|
baseType: printType(baseParamType),
|
@@ -18790,8 +18799,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18790
18799
|
targetParamType = overrideParamDetails.params[overrideParamDetails.kwargsIndex].type;
|
18791
18800
|
}
|
18792
18801
|
if (!assignType(targetParamType, paramInfo.type, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18793
|
-
/*
|
18794
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18802
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18795
18803
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.overrideParamKeywordType().format({
|
18796
18804
|
name: (_b = paramInfo.param.name) !== null && _b !== void 0 ? _b : '?',
|
18797
18805
|
baseType: printType(paramInfo.type),
|
@@ -18847,11 +18855,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18847
18855
|
}
|
18848
18856
|
}
|
18849
18857
|
// Now check the return type.
|
18850
|
-
const baseReturnType =
|
18851
|
-
const overrideReturnType =
|
18858
|
+
const baseReturnType = getEffectiveReturnType(baseMethod);
|
18859
|
+
const overrideReturnType = getEffectiveReturnType(overrideMethod);
|
18852
18860
|
if (!assignType(baseReturnType, overrideReturnType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
18853
|
-
/*
|
18854
|
-
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18861
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
18855
18862
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.overrideReturnType().format({
|
18856
18863
|
baseType: printType(baseReturnType),
|
18857
18864
|
overrideType: printType(overrideReturnType),
|
@@ -18883,8 +18890,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18883
18890
|
// If there's a bound type, make sure the source is derived from it.
|
18884
18891
|
if (destType.shared.boundType && !(0, typeUtils_1.isTypeAliasPlaceholder)(effectiveSrcType)) {
|
18885
18892
|
if (!assignType(destType.shared.boundType, effectiveSrcType, diag.createAddendum(),
|
18886
|
-
/*
|
18887
|
-
/* srcConstraints */ undefined)) {
|
18893
|
+
/* constraints */ undefined)) {
|
18888
18894
|
// Avoid adding a message that will confuse users if the TypeVar was
|
18889
18895
|
// synthesized for internal purposes.
|
18890
18896
|
if (!destType.shared.isSynthesized) {
|
@@ -19054,8 +19060,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19054
19060
|
}
|
19055
19061
|
else {
|
19056
19062
|
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
19057
|
-
if (!assignType(memberTypeFirstParamType, firstParamType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), constraints,
|
19058
|
-
/* srcConstraints */ undefined, 8192 /* AssignTypeFlags.AllowUnspecifiedTypeArgs */, recursionCount)) {
|
19063
|
+
if (!assignType(memberTypeFirstParamType, firstParamType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), constraints, 8192 /* AssignTypeFlags.AllowUnspecifiedTypeArgs */, recursionCount)) {
|
19059
19064
|
if (memberTypeFirstParam.name &&
|
19060
19065
|
!types_1.FunctionParam.isNameSynthesized(memberTypeFirstParam) &&
|
19061
19066
|
types_1.FunctionParam.isTypeDeclared(memberTypeFirstParam)) {
|
@@ -19073,7 +19078,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19073
19078
|
}
|
19074
19079
|
// Get the effective return type, which will have the side effect of lazily
|
19075
19080
|
// evaluating (and caching) the inferred return type if there is no defined return type.
|
19076
|
-
|
19081
|
+
getEffectiveReturnType(memberType);
|
19077
19082
|
const specializedFunction = solveAndApplyConstraints(memberType, constraints);
|
19078
19083
|
return types_1.FunctionType.clone(specializedFunction, stripFirstParam, baseType);
|
19079
19084
|
}
|
@@ -19193,11 +19198,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19193
19198
|
return false;
|
19194
19199
|
}
|
19195
19200
|
function printObjectTypeForClass(type) {
|
19196
|
-
return TypePrinter.printObjectTypeForClass(type, evaluatorOptions.printTypeFlags,
|
19201
|
+
return TypePrinter.printObjectTypeForClass(type, evaluatorOptions.printTypeFlags, getEffectiveReturnType);
|
19197
19202
|
}
|
19198
19203
|
function printFunctionParts(type, extraFlags) {
|
19199
19204
|
const flags = extraFlags ? evaluatorOptions.printTypeFlags | extraFlags : evaluatorOptions.printTypeFlags;
|
19200
|
-
return TypePrinter.printFunctionParts(type, flags,
|
19205
|
+
return TypePrinter.printFunctionParts(type, flags, getEffectiveReturnType);
|
19201
19206
|
}
|
19202
19207
|
// Prints two types and determines whether they need to be output in
|
19203
19208
|
// fully-qualified form for disambiguation.
|
@@ -19237,7 +19242,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19237
19242
|
if (options === null || options === void 0 ? void 0 : options.useFullyQualifiedNames) {
|
19238
19243
|
flags |= 4096 /* TypePrinter.PrintTypeFlags.UseFullyQualifiedNames */;
|
19239
19244
|
}
|
19240
|
-
return TypePrinter.printType(type, flags,
|
19245
|
+
return TypePrinter.printType(type, flags, getEffectiveReturnType);
|
19241
19246
|
}
|
19242
19247
|
// Calls back into the parser to parse the contents of a string literal.
|
19243
19248
|
// This is unfortunately needed in some cases — specifically where the
|
@@ -19298,7 +19303,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19298
19303
|
return codeFlowEngine.printControlFlowGraph(flowNode, reference, callName, logger);
|
19299
19304
|
}
|
19300
19305
|
// Track these apis internal usages when logging is on. otherwise, it should be noop.
|
19301
|
-
const getFunctionInferredReturnType = wrapWithLogger(
|
19306
|
+
const getFunctionInferredReturnType = wrapWithLogger(_getInferredReturnType);
|
19302
19307
|
const evaluatorInterface = {
|
19303
19308
|
runWithCancellationToken,
|
19304
19309
|
getType,
|
@@ -19355,7 +19360,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19355
19360
|
getEffectiveTypeOfSymbolForUsage,
|
19356
19361
|
getInferredTypeOfDeclaration,
|
19357
19362
|
getDeclaredTypeForExpression,
|
19358
|
-
getFunctionDeclaredReturnType,
|
19363
|
+
getFunctionDeclaredReturnType: getDeclaredReturnType,
|
19359
19364
|
getFunctionInferredReturnType,
|
19360
19365
|
getBestOverloadForArgs,
|
19361
19366
|
getBuiltInType,
|
@@ -19408,5 +19413,4 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19408
19413
|
const codeFlowEngine = (0, codeFlowEngine_1.getCodeFlowEngine)(evaluatorInterface, speculativeTypeTracker);
|
19409
19414
|
return evaluatorInterface;
|
19410
19415
|
}
|
19411
|
-
exports.createTypeEvaluator = createTypeEvaluator;
|
19412
19416
|
//# sourceMappingURL=typeEvaluator.js.map
|