@zzzen/pyright-internal 1.2.0-dev.20231203 → 1.2.0-dev.20231210
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/analyzerFileInfo.d.ts +4 -3
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +15 -14
- package/dist/analyzer/backgroundAnalysisProgram.js +38 -38
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +56 -52
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +43 -33
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/circularDependency.d.ts +3 -2
- package/dist/analyzer/circularDependency.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +29 -36
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +3 -5
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.js +1 -1
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +5 -3
- package/dist/analyzer/declaration.js +3 -2
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +3 -2
- package/dist/analyzer/declarationUtils.js +14 -12
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/enums.js +1 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +29 -25
- package/dist/analyzer/importResolver.js +300 -301
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +5 -4
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +5 -4
- package/dist/analyzer/importStatementUtils.js +23 -22
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +3 -3
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +7 -6
- package/dist/analyzer/packageTypeReport.js +4 -4
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +68 -64
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.d.ts +7 -6
- package/dist/analyzer/parentDirectoryCache.js +9 -10
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/parseTreeUtils.js +6 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +79 -14
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +27 -26
- package/dist/analyzer/program.js +162 -156
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +3 -3
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/pyTypedUtils.d.ts +3 -2
- package/dist/analyzer/pyTypedUtils.js +4 -5
- package/dist/analyzer/pyTypedUtils.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.d.ts +7 -6
- package/dist/analyzer/pythonPathUtils.js +21 -23
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +24 -23
- package/dist/analyzer/service.js +187 -183
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +4 -5
- package/dist/analyzer/sourceFile.js +68 -56
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +3 -3
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +11 -10
- package/dist/analyzer/sourceMapper.js +59 -62
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.d.ts +2 -1
- package/dist/analyzer/sourceMapperUtils.js +2 -2
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +3 -2
- package/dist/analyzer/tracePrinter.js +21 -23
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +2 -1
- package/dist/analyzer/typeDocStringUtils.js +14 -17
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +172 -102
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeGuards.js +3 -3
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +2 -0
- package/dist/analyzer/typePrinter.js +48 -8
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.d.ts +2 -1
- package/dist/analyzer/typeStubWriter.js +2 -2
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +4 -2
- package/dist/analyzer/typeUtils.js +16 -5
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +4 -4
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +5 -4
- package/dist/analyzer/types.js +4 -4
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.d.ts +1 -2
- package/dist/backgroundAnalysis.js +6 -4
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +22 -20
- package/dist/backgroundAnalysisBase.js +76 -55
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +1 -1
- package/dist/backgroundThreadBase.js +20 -11
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +3 -2
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +21 -20
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +5 -5
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/configOptions.d.ts +14 -13
- package/dist/common/configOptions.js +29 -27
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnostic.d.ts +6 -5
- package/dist/common/diagnostic.js +2 -2
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.d.ts +2 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.d.ts +6 -5
- package/dist/common/editAction.js +2 -2
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +2 -1
- package/dist/common/envVarUtils.js +20 -28
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +19 -19
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +29 -28
- package/dist/common/fileWatcher.d.ts +3 -2
- package/dist/common/fileWatcher.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +8 -7
- package/dist/common/fullAccessHost.js +21 -16
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +7 -6
- package/dist/common/host.js +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.d.ts +2 -1
- package/dist/common/logTracker.js +4 -4
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/pathUtils.d.ts +1 -28
- package/dist/common/pathUtils.js +17 -366
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +7 -3
- package/dist/common/realFileSystem.js +78 -60
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProviderExtensions.d.ts +2 -1
- package/dist/common/serviceProviderExtensions.js +5 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/textEditTracker.d.ts +2 -1
- package/dist/common/textEditTracker.js +28 -28
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.d.ts +2 -1
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/uri/baseUri.d.ts +51 -0
- package/dist/common/uri/baseUri.js +194 -0
- package/dist/common/uri/baseUri.js.map +1 -0
- package/dist/common/uri/emptyUri.d.ts +32 -0
- package/dist/common/uri/emptyUri.js +122 -0
- package/dist/common/uri/emptyUri.js.map +1 -0
- package/dist/common/uri/fileUri.d.ts +36 -0
- package/dist/common/uri/fileUri.js +180 -0
- package/dist/common/uri/fileUri.js.map +1 -0
- package/dist/common/uri/memoization.d.ts +3 -0
- package/dist/common/uri/memoization.js +72 -0
- package/dist/common/uri/memoization.js.map +1 -0
- package/dist/common/uri/uri.d.ts +50 -0
- package/dist/common/uri/uri.js +104 -0
- package/dist/common/uri/uri.js.map +1 -0
- package/dist/common/uri/uriUtils.d.ts +39 -0
- package/dist/common/uri/uriUtils.js +362 -0
- package/dist/common/uri/uriUtils.js.map +1 -0
- package/dist/common/uri/webUri.d.ts +36 -0
- package/dist/common/uri/webUri.js +207 -0
- package/dist/common/uri/webUri.js.map +1 -0
- package/dist/common/workspaceEditUtils.d.ts +8 -8
- package/dist/common/workspaceEditUtils.js +34 -37
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +19 -22
- package/dist/languageServerBase.js +91 -95
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +2 -1
- package/dist/languageService/analyzerServiceExecutor.js +14 -16
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +11 -9
- package/dist/languageService/autoImporter.js +45 -44
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +3 -2
- package/dist/languageService/callHierarchyProvider.js +23 -35
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.d.ts +2 -1
- package/dist/languageService/codeActionProvider.js +8 -10
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +7 -6
- package/dist/languageService/completionProvider.js +32 -30
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +2 -1
- package/dist/languageService/completionProviderUtils.js +1 -1
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +4 -3
- package/dist/languageService/definitionProvider.js +26 -24
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.d.ts +3 -2
- package/dist/languageService/documentHighlightProvider.js +3 -3
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +8 -7
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.d.ts +5 -4
- package/dist/languageService/documentSymbolProvider.js +9 -11
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +4 -3
- package/dist/languageService/hoverProvider.js +6 -5
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/navigationUtils.d.ts +2 -1
- package/dist/languageService/navigationUtils.js +2 -3
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/quickActions.d.ts +2 -1
- package/dist/languageService/quickActions.js +3 -3
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +10 -9
- package/dist/languageService/referencesProvider.js +28 -28
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.d.ts +4 -3
- package/dist/languageService/renameProvider.js +17 -18
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +3 -2
- package/dist/languageService/signatureHelpProvider.js +4 -4
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +2 -1
- package/dist/languageService/symbolIndexer.js +1 -1
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +10 -4
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.d.ts +4 -3
- package/dist/languageService/workspaceSymbolProvider.js +10 -11
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +1 -0
- package/dist/localization/localize.js +1 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +2 -1
- package/dist/pyright.js +18 -17
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +13 -13
- package/dist/pyrightFileSystem.js +38 -43
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +29 -28
- package/dist/readonlyAugmentedFileSystem.js +62 -65
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +21 -20
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +39 -30
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +31 -30
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/completions.test.js +7 -3
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +24 -22
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js +3 -2
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +37 -35
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +4 -4
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +27 -11
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +2 -2
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +4 -5
- package/dist/tests/harness/fourslash/testLanguageService.js +9 -15
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +4 -4
- package/dist/tests/harness/fourslash/testState.js +91 -51
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/testAccessHost.d.ts +3 -2
- package/dist/tests/harness/testAccessHost.js +2 -1
- package/dist/tests/harness/testAccessHost.js.map +1 -1
- package/dist/tests/harness/testHost.js +13 -11
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/vfs/factory.d.ts +3 -2
- package/dist/tests/harness/vfs/factory.js +5 -4
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +32 -31
- package/dist/tests/harness/vfs/filesystem.js +47 -49
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +1 -10
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importResolver.test.js +81 -58
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +10 -9
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +12 -11
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/logger.test.js +2 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +2 -1
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +3 -138
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +38 -34
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/service.test.js +37 -42
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js +3 -2
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +8 -7
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +13 -6
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +13 -9
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.d.ts +2 -5
- package/dist/tests/testStateUtils.js +27 -64
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.d.ts +3 -5
- package/dist/tests/testUtils.js +15 -64
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +4 -3
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +16 -15
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +18 -9
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +73 -62
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +20 -19
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +28 -27
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +4 -3
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/uri.test.d.ts +1 -0
- package/dist/tests/uri.test.js +695 -0
- package/dist/tests/uri.test.js.map +1 -0
- package/dist/tests/workspaceEditUtils.test.js +28 -28
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +11 -11
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +13 -14
- package/dist/workspaceFactory.js +54 -55
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
- package/dist/common/uriParser.d.ts +0 -24
- package/dist/common/uriParser.js +0 -45
- package/dist/common/uriParser.js.map +0 -1
@@ -47,6 +47,7 @@ const diagnosticRules_1 = require("../common/diagnosticRules");
|
|
47
47
|
const positionUtils_1 = require("../common/positionUtils");
|
48
48
|
const pythonVersion_1 = require("../common/pythonVersion");
|
49
49
|
const textRange_1 = require("../common/textRange");
|
50
|
+
const uri_1 = require("../common/uri/uri");
|
50
51
|
const localize_1 = require("../localization/localize");
|
51
52
|
const parseNodes_1 = require("../parser/parseNodes");
|
52
53
|
const parser_1 = require("../parser/parser");
|
@@ -262,7 +263,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
262
263
|
const message = `Type cache flag mismatch for node type ${node.nodeType} ` +
|
263
264
|
`(parent ${(_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== null && _b !== void 0 ? _b : 'none'}): ` +
|
264
265
|
`cached flags = ${expectedFlags}, access flags = ${flags}, ` +
|
265
|
-
`file = {${fileInfo.
|
266
|
+
`file = {${fileInfo.fileUri} [${position.line + 1}:${position.character + 1}]}`;
|
266
267
|
if (evaluatorOptions.verifyTypeCacheEvaluatorFlags) {
|
267
268
|
(0, debug_1.fail)(message);
|
268
269
|
}
|
@@ -1407,9 +1408,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1407
1408
|
return getBoundMagicMethod(boundMethodResult.type, '__call__', selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType), recursionCount);
|
1408
1409
|
}
|
1409
1410
|
if ((0, types_1.isAnyOrUnknown)(boundMethodResult.type)) {
|
1410
|
-
|
1411
|
-
types_1.FunctionType.addDefaultParameters(unknownFunction);
|
1412
|
-
return unknownFunction;
|
1411
|
+
return (0, typeUtils_1.getUnknownTypeForCallable)();
|
1413
1412
|
}
|
1414
1413
|
return undefined;
|
1415
1414
|
}
|
@@ -1923,7 +1922,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1923
1922
|
}
|
1924
1923
|
function getTypeOfModule(node, symbolName, nameParts) {
|
1925
1924
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
1926
|
-
const lookupResult = importLookup({ nameParts,
|
1925
|
+
const lookupResult = importLookup({ nameParts, importingFileUri: fileInfo.fileUri });
|
1927
1926
|
if (!lookupResult) {
|
1928
1927
|
return undefined;
|
1929
1928
|
}
|
@@ -2473,9 +2472,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2473
2472
|
(0, types_1.isFunction)(subtype) &&
|
2474
2473
|
subtype.details.parameters.length === 0 &&
|
2475
2474
|
subtype.details.paramSpec) {
|
2476
|
-
|
2477
|
-
types_1.FunctionType.addDefaultParameters(concreteFunction);
|
2478
|
-
return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
|
2475
|
+
return types_1.FunctionType.cloneForParamSpec(subtype, (0, typeUtils_1.getUnknownTypeForCallable)());
|
2479
2476
|
}
|
2480
2477
|
if ((0, types_1.isTypeVar)(subtype) && subtype.details.isVariadic) {
|
2481
2478
|
// If it's in a union, convert to type or object.
|
@@ -3072,7 +3069,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3072
3069
|
return type;
|
3073
3070
|
}
|
3074
3071
|
// Handles the case where a variable or parameter is defined in an outer
|
3075
|
-
// scope and captured by an inner scope (
|
3072
|
+
// scope and captured by an inner scope (a function, lambda, or comprehension).
|
3076
3073
|
function getCodeFlowTypeForCapturedVariable(node, symbolWithScope, effectiveType) {
|
3077
3074
|
// This function applies only to variables, parameters, and imports, not to other
|
3078
3075
|
// types of symbols.
|
@@ -3092,16 +3089,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3092
3089
|
// If the symbol is a variable captured by an inner function
|
3093
3090
|
// or lambda, see if we can infer the type from the outer scope.
|
3094
3091
|
const scopeHierarchy = ScopeUtils.getScopeHierarchy(node, symbolWithScope.scope);
|
3095
|
-
|
3096
|
-
// lambdas and modules. Don't allow other types of scopes.
|
3097
|
-
if (scopeHierarchy &&
|
3098
|
-
scopeHierarchy.length >= 2 &&
|
3099
|
-
scopeHierarchy.every((s) => s.type === 1 /* ScopeType.Function */ || s.type === 3 /* ScopeType.Module */)) {
|
3092
|
+
if (scopeHierarchy && scopeHierarchy.length >= 2) {
|
3100
3093
|
// Find the parse node associated with the scope that is just inside of the
|
3101
3094
|
// scope that declares the captured variable.
|
3102
3095
|
const innerScopeNode = ScopeUtils.findTopNodeInScope(node, scopeHierarchy[scopeHierarchy.length - 2]);
|
3103
|
-
if (innerScopeNode
|
3104
|
-
(innerScopeNode
|
3096
|
+
if ((innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 28 /* ParseNodeType.Function */ ||
|
3097
|
+
(innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 30 /* ParseNodeType.Lambda */ ||
|
3098
|
+
(innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 10 /* ParseNodeType.Class */) {
|
3105
3099
|
const innerScopeCodeFlowNode = AnalyzerNodeInfo.getFlowNode(innerScopeNode);
|
3106
3100
|
if (innerScopeCodeFlowNode) {
|
3107
3101
|
// See if any of the assignments of the symbol are reachable
|
@@ -3624,9 +3618,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3624
3618
|
const getAttrSymbol = types_1.ModuleType.getField(baseType, '__getattr__');
|
3625
3619
|
if (getAttrSymbol) {
|
3626
3620
|
const isModuleGetAttrSupported = fileInfo.executionEnvironment.pythonVersion >= pythonVersion_1.PythonVersion.V3_7 ||
|
3627
|
-
getAttrSymbol
|
3628
|
-
.getDeclarations()
|
3629
|
-
.some((decl) => decl.path.toLowerCase().endsWith('.pyi'));
|
3621
|
+
getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi'));
|
3630
3622
|
if (isModuleGetAttrSupported) {
|
3631
3623
|
const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol);
|
3632
3624
|
if ((0, types_1.isFunction)(getAttrTypeResult.type)) {
|
@@ -5706,9 +5698,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5706
5698
|
addError(localize_1.Localizer.Diagnostic.superCallArgCount(), node.arguments[2]);
|
5707
5699
|
}
|
5708
5700
|
const enclosingFunction = ParseTreeUtils.getEnclosingFunctionEvaluationScope(node);
|
5709
|
-
const enclosingClass = enclosingFunction
|
5710
|
-
? ParseTreeUtils.getEnclosingClass(enclosingFunction, /* stopAtFunction */ true)
|
5711
|
-
: undefined;
|
5701
|
+
const enclosingClass = enclosingFunction ? ParseTreeUtils.getEnclosingClass(enclosingFunction) : undefined;
|
5712
5702
|
const enclosingClassType = enclosingClass ? (_a = getTypeOfClass(enclosingClass)) === null || _a === void 0 ? void 0 : _a.classType : undefined;
|
5713
5703
|
// Determine which class the "super" call is applied to. If
|
5714
5704
|
// there is no first argument, then the class is implicit.
|
@@ -5771,6 +5761,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5771
5761
|
if (reportError) {
|
5772
5762
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
5773
5763
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.superCallSecondArg().format({ type: printType(targetClassType) }), node.arguments[1].valueExpression);
|
5764
|
+
return { type: types_1.UnknownType.create() };
|
5774
5765
|
}
|
5775
5766
|
}
|
5776
5767
|
else if (enclosingClassType) {
|
@@ -5838,34 +5829,77 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5838
5829
|
const lookupResults = bindToType
|
5839
5830
|
? (0, typeUtils_1.lookUpClassMember)(bindToType, memberName, 0 /* MemberAccessFlags.Default */, effectiveTargetClass)
|
5840
5831
|
: undefined;
|
5832
|
+
let resultType;
|
5841
5833
|
if (lookupResults && (0, types_1.isInstantiableClass)(lookupResults.classType)) {
|
5842
|
-
|
5843
|
-
|
5844
|
-
|
5845
|
-
|
5846
|
-
|
5847
|
-
|
5848
|
-
|
5849
|
-
|
5834
|
+
resultType = lookupResults.classType;
|
5835
|
+
}
|
5836
|
+
else if (effectiveTargetClass &&
|
5837
|
+
!(0, types_1.isAnyOrUnknown)(effectiveTargetClass) &&
|
5838
|
+
!(0, typeUtils_1.derivesFromAnyOrUnknown)(effectiveTargetClass) &&
|
5839
|
+
objectType &&
|
5840
|
+
(0, types_1.isClassInstance)(objectType)) {
|
5841
|
+
resultType = types_1.ClassType.cloneAsInstantiable(objectType);
|
5850
5842
|
}
|
5843
|
+
else {
|
5844
|
+
resultType = types_1.UnknownType.create();
|
5845
|
+
}
|
5846
|
+
return {
|
5847
|
+
type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(resultType) : resultType,
|
5848
|
+
bindToSelfType: bindToType
|
5849
|
+
? types_1.TypeBase.cloneForCondition((0, typeUtils_1.synthesizeTypeVarForSelfCls)(bindToType, /* isClsParam */ false), bindToType.condition)
|
5850
|
+
: undefined,
|
5851
|
+
};
|
5851
5852
|
}
|
5852
|
-
//
|
5853
|
-
// will be reported by the member lookup logic at a later time.
|
5853
|
+
// Handle the super() call when used outside of a member access expression.
|
5854
5854
|
if ((0, types_1.isInstantiableClass)(targetClassType)) {
|
5855
|
-
//
|
5856
|
-
//
|
5857
|
-
|
5858
|
-
|
5859
|
-
|
5860
|
-
|
5861
|
-
if (
|
5862
|
-
|
5863
|
-
if ((
|
5855
|
+
// We don't know which member is going to be accessed, so we cannot
|
5856
|
+
// deterministically determine the correct type in this case. We'll
|
5857
|
+
// use a heuristic that produces the "correct" (desired) behavior in
|
5858
|
+
// most cases. If there's a bindToType and the targetClassType is one
|
5859
|
+
// of the base classes of the bindToType, we'll return the next base
|
5860
|
+
// class.
|
5861
|
+
if (bindToType) {
|
5862
|
+
let nextBaseClassType;
|
5863
|
+
if (types_1.ClassType.isSameGenericClass(bindToType, targetClassType)) {
|
5864
|
+
if (bindToType.details.baseClasses.length > 0) {
|
5865
|
+
nextBaseClassType = bindToType.details.baseClasses[0];
|
5866
|
+
}
|
5867
|
+
}
|
5868
|
+
else {
|
5869
|
+
const baseClassIndex = bindToType.details.baseClasses.findIndex((baseClass) => (0, types_1.isClass)(baseClass) && types_1.ClassType.isSameGenericClass(baseClass, targetClassType));
|
5870
|
+
if (baseClassIndex >= 0 && baseClassIndex < bindToType.details.baseClasses.length - 1) {
|
5871
|
+
nextBaseClassType = bindToType.details.baseClasses[baseClassIndex + 1];
|
5872
|
+
}
|
5873
|
+
}
|
5874
|
+
if (nextBaseClassType) {
|
5875
|
+
if ((0, types_1.isInstantiableClass)(nextBaseClassType)) {
|
5876
|
+
nextBaseClassType = (0, typeUtils_1.specializeForBaseClass)(bindToType, nextBaseClassType);
|
5877
|
+
}
|
5878
|
+
return { type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(nextBaseClassType) : nextBaseClassType };
|
5879
|
+
}
|
5880
|
+
// There's not much we can say about the type. Simply return object or type.
|
5881
|
+
if (objectType && (0, types_1.isClassInstance)(objectType) && typeClassType && (0, types_1.isInstantiableClass)(typeClassType)) {
|
5864
5882
|
return {
|
5865
|
-
type: resultIsInstance ?
|
5883
|
+
type: resultIsInstance ? objectType : (0, typeUtils_1.convertToInstance)(typeClassType),
|
5866
5884
|
};
|
5867
5885
|
}
|
5868
5886
|
}
|
5887
|
+
else {
|
5888
|
+
// If the class derives from one or more unknown classes,
|
5889
|
+
// return unknown here to prevent spurious errors.
|
5890
|
+
if (targetClassType.details.mro.some((mroBase) => (0, types_1.isAnyOrUnknown)(mroBase))) {
|
5891
|
+
return { type: types_1.UnknownType.create() };
|
5892
|
+
}
|
5893
|
+
const baseClasses = targetClassType.details.baseClasses;
|
5894
|
+
if (baseClasses.length > 0) {
|
5895
|
+
const baseClassType = baseClasses[0];
|
5896
|
+
if ((0, types_1.isInstantiableClass)(baseClassType)) {
|
5897
|
+
return {
|
5898
|
+
type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
|
5899
|
+
};
|
5900
|
+
}
|
5901
|
+
}
|
5902
|
+
}
|
5869
5903
|
}
|
5870
5904
|
return { type: types_1.UnknownType.create() };
|
5871
5905
|
}
|
@@ -6183,7 +6217,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6183
6217
|
const diagnostic = addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noOverload().format({ name: functionName }), errorNode);
|
6184
6218
|
const overrideDecl = bestMatch.overload.details.declaration;
|
6185
6219
|
if (diagnostic && overrideDecl) {
|
6186
|
-
diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.
|
6220
|
+
diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.uri, overrideDecl.range);
|
6187
6221
|
}
|
6188
6222
|
}
|
6189
6223
|
const effectiveTypeVarContext = typeVarContext !== null && typeVarContext !== void 0 ? typeVarContext : new typeVarContext_1.TypeVarContext();
|
@@ -6663,7 +6697,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6663
6697
|
newClassName = firstArgType.literalValue;
|
6664
6698
|
}
|
6665
6699
|
}
|
6666
|
-
const newClassType = types_1.ClassType.createInstantiable(newClassName, '', '', AnalyzerNodeInfo.getFileInfo(errorNode).
|
6700
|
+
const newClassType = types_1.ClassType.createInstantiable(newClassName, '', '', AnalyzerNodeInfo.getFileInfo(errorNode).fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode), types_1.ClassType.cloneAsInstantiable(returnType), types_1.ClassType.cloneAsInstantiable(returnType));
|
6667
6701
|
newClassType.details.baseClasses.push(getBuiltInType(errorNode, 'object'));
|
6668
6702
|
newClassType.details.effectiveMetaclass = expandedCallType;
|
6669
6703
|
(0, typeUtils_1.computeMroLinearization)(newClassType);
|
@@ -7611,7 +7645,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7611
7645
|
}
|
7612
7646
|
const effectiveReturnType = getFunctionEffectiveReturnType(type);
|
7613
7647
|
let effectiveExpectedType = inferenceContext.expectedType;
|
7614
|
-
let effectiveFlags =
|
7648
|
+
let effectiveFlags = 1024 /* AssignTypeFlags.PopulatingExpectedType */;
|
7615
7649
|
if ((0, typeUtils_1.containsLiteralType)(effectiveExpectedType, /* includeTypeArgs */ true)) {
|
7616
7650
|
effectiveFlags |= 128 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
|
7617
7651
|
}
|
@@ -7623,7 +7657,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7623
7657
|
const typeVarContextCopy = typeVarContext.clone();
|
7624
7658
|
assignType(effectiveReturnType, effectiveExpectedType,
|
7625
7659
|
/* diag */ undefined, typeVarContextCopy,
|
7626
|
-
/* srcTypeVarContext */ undefined, effectiveFlags
|
7660
|
+
/* srcTypeVarContext */ undefined, effectiveFlags);
|
7627
7661
|
const speculativeResults = validateFunctionArgumentTypes(errorNode, matchResults, typeVarContextCopy, signatureTracker, skipUnknownArgCheck);
|
7628
7662
|
if (speculativeResults === null || speculativeResults === void 0 ? void 0 : speculativeResults.argumentErrors) {
|
7629
7663
|
effectiveExpectedType = undefined;
|
@@ -7669,6 +7703,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7669
7703
|
effectiveExpectedType = (0, typeUtils_1.applySolvedTypeVars)(genericReturnType, tempTypeVarContext, {
|
7670
7704
|
unknownIfNotFound: true,
|
7671
7705
|
});
|
7706
|
+
effectiveFlags |= 2048 /* AssignTypeFlags.SkipPopulateUnknownExpectedType */;
|
7672
7707
|
}
|
7673
7708
|
}
|
7674
7709
|
}
|
@@ -7684,7 +7719,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7684
7719
|
effectiveExpectedType = (0, typeUtils_1.transformExpectedType)(effectiveExpectedType, liveTypeVarScopes, errorNode.start);
|
7685
7720
|
assignType(effectiveReturnType, effectiveExpectedType,
|
7686
7721
|
/* diag */ undefined, typeVarContext,
|
7687
|
-
/* srcTypeVarContext */ undefined, effectiveFlags
|
7722
|
+
/* srcTypeVarContext */ undefined, effectiveFlags);
|
7688
7723
|
}
|
7689
7724
|
return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck);
|
7690
7725
|
}
|
@@ -8751,7 +8786,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8751
8786
|
}
|
8752
8787
|
return getTypeOfTypeAliasCommon(nameNode, nameNode, valueExpr,
|
8753
8788
|
/* isPep695Syntax */ false,
|
8754
|
-
/* typeParamNodes */ undefined, () => typeParameters
|
8789
|
+
/* typeParamNodes */ undefined, () => typeParameters);
|
8755
8790
|
}
|
8756
8791
|
function getBooleanValue(node) {
|
8757
8792
|
if (node.nodeType === 11 /* ParseNodeType.Constant */) {
|
@@ -8819,7 +8854,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8819
8854
|
}
|
8820
8855
|
let classFlags = baseClass.details.flags & ~(1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */);
|
8821
8856
|
classFlags |= 4096 /* ClassTypeFlags.Final */;
|
8822
|
-
const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.
|
8857
|
+
const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
|
8823
8858
|
/* declaredMetaclass */ undefined, baseClass.details.effectiveMetaclass);
|
8824
8859
|
classType.details.baseClasses.push(isBaseClassAny ? types_1.AnyType.create() : baseClass);
|
8825
8860
|
(0, typeUtils_1.computeMroLinearization)(classType);
|
@@ -8866,7 +8901,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8866
8901
|
if (!(0, types_1.isClassInstance)(arg1Type) || !(0, typeUtils_1.isTupleClass)(arg1Type) || arg1Type.tupleTypeArguments === undefined) {
|
8867
8902
|
return undefined;
|
8868
8903
|
}
|
8869
|
-
const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.
|
8904
|
+
const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
|
8870
8905
|
/* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
|
8871
8906
|
arg1Type.tupleTypeArguments.forEach((typeArg) => {
|
8872
8907
|
const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
|
@@ -10656,7 +10691,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10656
10691
|
}
|
10657
10692
|
return createSpecialType(classType, typeArgs, /* paramLimit */ undefined, /* allowParamSpec */ true);
|
10658
10693
|
}
|
10659
|
-
function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, typeParameters, typeParamNodes) {
|
10694
|
+
function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, isPep695TypeVarType, typeParameters, typeParamNodes) {
|
10660
10695
|
if (!types_1.TypeBase.isInstantiable(type)) {
|
10661
10696
|
return type;
|
10662
10697
|
}
|
@@ -10701,24 +10736,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10701
10736
|
names: variadics.map((v) => `"${v.details.name}"`).join(', '),
|
10702
10737
|
}), errorNode);
|
10703
10738
|
}
|
10704
|
-
|
10705
|
-
|
10706
|
-
|
10707
|
-
|
10708
|
-
|
10709
|
-
|
10739
|
+
if (!isPep695Syntax && !isPep695TypeVarType) {
|
10740
|
+
const boundTypeVars = typeParameters.filter((typeVar) => typeVar.scopeId !== typeAliasScopeId && typeVar.scopeType === 0 /* TypeVarScopeType.Class */);
|
10741
|
+
if (boundTypeVars.length > 0) {
|
10742
|
+
addError(localize_1.Localizer.Diagnostic.genericTypeAliasBoundTypeVar().format({
|
10743
|
+
names: boundTypeVars.map((t) => `${t.details.name}`).join(', '),
|
10744
|
+
}), errorNode);
|
10745
|
+
}
|
10710
10746
|
}
|
10747
|
+
const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
|
10711
10748
|
const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
|
10712
10749
|
// All PEP 695 type aliases are special forms because they are
|
10713
10750
|
// TypeAliasType objects at runtime.
|
10714
|
-
if (isPep695Syntax) {
|
10751
|
+
if (isPep695Syntax || isPep695TypeVarType) {
|
10715
10752
|
typeAlias.flags |= 8 /* TypeFlags.SpecialForm */;
|
10716
10753
|
}
|
10717
10754
|
return typeAlias;
|
10718
10755
|
}
|
10719
10756
|
function createSpecialBuiltInClass(node, assignedName, aliasMapEntry) {
|
10720
10757
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
10721
|
-
let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.
|
10758
|
+
let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.fileUri, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
|
10722
10759
|
/* typeSourceId */ 0,
|
10723
10760
|
/* declaredMetaclass */ undefined,
|
10724
10761
|
/* effectiveMetaclass */ undefined);
|
@@ -10967,7 +11004,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10967
11004
|
if (!isSpeculativeTypeAlias || isLegalImplicitTypeAliasType(rightHandType)) {
|
10968
11005
|
// If this is a type alias, record its name based on the assignment target.
|
10969
11006
|
rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, node.rightExpression,
|
10970
|
-
/* isPep695Syntax */ false
|
11007
|
+
/* isPep695Syntax */ false,
|
11008
|
+
/* isPep695TypeVarType */ false);
|
10971
11009
|
(0, debug_1.assert)(typeAliasTypeVar !== undefined);
|
10972
11010
|
if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, rightHandType)) {
|
10973
11011
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
|
@@ -11024,11 +11062,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11024
11062
|
var _a;
|
11025
11063
|
return getTypeOfTypeAliasCommon(node, node.name, node.expression,
|
11026
11064
|
/* isPep695Syntax */ true, (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.parameters, () => {
|
11027
|
-
let typeParameters = [];
|
11028
11065
|
if (node.typeParameters) {
|
11029
|
-
|
11066
|
+
return evaluateTypeParameterList(node.typeParameters);
|
11030
11067
|
}
|
11031
|
-
return
|
11068
|
+
return undefined;
|
11032
11069
|
});
|
11033
11070
|
}
|
11034
11071
|
// This function is common to the handling of "type" statements and explicit
|
@@ -11067,7 +11104,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11067
11104
|
if (aliasTypeResult.isIncomplete) {
|
11068
11105
|
isIncomplete = true;
|
11069
11106
|
}
|
11070
|
-
aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax,
|
11107
|
+
aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax,
|
11108
|
+
/* isPep695TypeVarType */ true, typeParameters, typeParamNodes);
|
11071
11109
|
if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, aliasType)) {
|
11072
11110
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(valueNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
|
11073
11111
|
name: nameNode.value,
|
@@ -11128,7 +11166,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11128
11166
|
if (fileInfo.isStubFile) {
|
11129
11167
|
classFlags |= 8388608 /* ClassTypeFlags.DefinedInStub */;
|
11130
11168
|
}
|
11131
|
-
const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.
|
11169
|
+
const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.fileUri, classFlags,
|
11132
11170
|
/* typeSourceId */ 0,
|
11133
11171
|
/* declaredMetaclass */ undefined,
|
11134
11172
|
/* effectiveMetaclass */ undefined, ParseTreeUtils.getDocString(node.suite.statements));
|
@@ -11669,7 +11707,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11669
11707
|
// Replace all of the type parameters with invariant TypeVars.
|
11670
11708
|
const updatedTypeParams = classType.details.typeParameters.map((typeParam) => types_1.TypeVarType.cloneAsInvariant(typeParam));
|
11671
11709
|
const updatedClassType = types_1.ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams);
|
11672
|
-
const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '',
|
11710
|
+
const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
|
11673
11711
|
updatedTypeParams.forEach((param, paramIndex) => {
|
11674
11712
|
// Skip variadics and ParamSpecs.
|
11675
11713
|
if (param.details.isVariadic || param.details.isParamSpec) {
|
@@ -11952,7 +11990,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11952
11990
|
if (diag && initSubclassDecl) {
|
11953
11991
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.initSubclassLocation().format({
|
11954
11992
|
name: printType((0, typeUtils_1.convertToInstance)(initSubclassMethodInfo.classType)),
|
11955
|
-
}), initSubclassDecl.
|
11993
|
+
}), initSubclassDecl.uri, initSubclassDecl.range);
|
11956
11994
|
}
|
11957
11995
|
}
|
11958
11996
|
}
|
@@ -12981,7 +13019,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
12981
13019
|
(0, debug_1.assert)(!parentNode.isWildcardImport);
|
12982
13020
|
const importInfo = AnalyzerNodeInfo.getImportInfo(parentNode.module);
|
12983
13021
|
if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib) {
|
12984
|
-
const resolvedPath = importInfo.
|
13022
|
+
const resolvedPath = importInfo.resolvedUris[importInfo.resolvedUris.length - 1];
|
12985
13023
|
const importLookupInfo = importLookup(resolvedPath);
|
12986
13024
|
let reportError = false;
|
12987
13025
|
// If we were able to resolve the import, report the error as
|
@@ -13001,7 +13039,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
13001
13039
|
}
|
13002
13040
|
}
|
13003
13041
|
}
|
13004
|
-
else if (
|
13042
|
+
else if (resolvedPath.isEmpty()) {
|
13005
13043
|
// This corresponds to the "from . import a" form.
|
13006
13044
|
reportError = true;
|
13007
13045
|
}
|
@@ -14404,13 +14442,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14404
14442
|
if (namePartIndex >= 0 &&
|
14405
14443
|
importInfo &&
|
14406
14444
|
!importInfo.isNativeLib &&
|
14407
|
-
namePartIndex < importInfo.
|
14408
|
-
if (importInfo.
|
14445
|
+
namePartIndex < importInfo.resolvedUris.length) {
|
14446
|
+
if (importInfo.resolvedUris[namePartIndex]) {
|
14409
14447
|
evaluateTypesForStatement(node);
|
14410
14448
|
// Synthesize an alias declaration for this name part. The only
|
14411
14449
|
// time this case is used is for IDE services such as
|
14412
14450
|
// the find all references, hover provider and etc.
|
14413
|
-
declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.
|
14451
|
+
declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.resolvedUris[namePartIndex]));
|
14414
14452
|
}
|
14415
14453
|
}
|
14416
14454
|
}
|
@@ -14723,8 +14761,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14723
14761
|
return evaluatorOptions.evaluateUnknownImportsAsAny ? types_1.AnyType.create() : types_1.UnknownType.create();
|
14724
14762
|
}
|
14725
14763
|
function applyLoaderActionsToModuleType(moduleType, loaderActions, importLookup) {
|
14726
|
-
if (loaderActions.
|
14727
|
-
const lookupResults = importLookup(loaderActions.
|
14764
|
+
if (!loaderActions.uri.isEmpty() && loaderActions.loadSymbolsFromPath) {
|
14765
|
+
const lookupResults = importLookup(loaderActions.uri);
|
14728
14766
|
if (lookupResults) {
|
14729
14767
|
moduleType.fields = lookupResults.symbolTable;
|
14730
14768
|
moduleType.docString = lookupResults.docString;
|
@@ -14747,7 +14785,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14747
14785
|
}
|
14748
14786
|
else {
|
14749
14787
|
const moduleName = moduleType.moduleName ? moduleType.moduleName + '.' + name : '';
|
14750
|
-
const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.
|
14788
|
+
const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.uri);
|
14751
14789
|
symbolType = applyLoaderActionsToModuleType(importedModuleType, implicitImport, importLookup);
|
14752
14790
|
}
|
14753
14791
|
const importedModuleSymbol = symbol_1.Symbol.createWithType(0 /* SymbolFlags.None */, symbolType);
|
@@ -14762,7 +14800,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14762
14800
|
if (resolvedDecl.type === 8 /* DeclarationType.Alias */) {
|
14763
14801
|
// Build a module type that corresponds to the declaration and
|
14764
14802
|
// its associated loader actions.
|
14765
|
-
const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.
|
14803
|
+
const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.uri);
|
14766
14804
|
if (resolvedDecl.symbolName && resolvedDecl.submoduleFallback) {
|
14767
14805
|
return applyLoaderActionsToModuleType(moduleType, resolvedDecl.submoduleFallback, importLookup);
|
14768
14806
|
}
|
@@ -14856,7 +14894,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14856
14894
|
// (but not an ellipsis).
|
14857
14895
|
if (isLegalImplicitTypeAliasType(inferredType)) {
|
14858
14896
|
inferredType = transformTypeForTypeAlias(inferredType, resolvedDecl.typeAliasName, resolvedDecl.node,
|
14859
|
-
/* isPep695Syntax */ false
|
14897
|
+
/* isPep695Syntax */ false,
|
14898
|
+
/* isPep695TypeVarType */ false);
|
14860
14899
|
isUnambiguousType = true;
|
14861
14900
|
}
|
14862
14901
|
}
|
@@ -15760,11 +15799,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15760
15799
|
// the length of the src type arguments list if the dest or source contain
|
15761
15800
|
// entries with indeterminate length or variadic entries. It returns true
|
15762
15801
|
// if the source is potentially compatible with the dest type, false otherwise.
|
15763
|
-
function
|
15764
|
-
const
|
15802
|
+
function adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags) {
|
15803
|
+
const destUnboundedOrVariadicIndex = destTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
|
15765
15804
|
const srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
|
15805
|
+
const srcVariadicIndex = srcTypeArgs.findIndex((t) => (0, types_1.isVariadicTypeVar)(t.type));
|
15766
15806
|
// If the src contains an unbounded type but the dest does not, it's incompatible.
|
15767
|
-
if (srcUnboundedIndex >= 0 &&
|
15807
|
+
if (srcUnboundedIndex >= 0 && destUnboundedOrVariadicIndex < 0) {
|
15768
15808
|
return false;
|
15769
15809
|
}
|
15770
15810
|
if (srcUnboundedIndex >= 0) {
|
@@ -15782,36 +15822,64 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15782
15822
|
while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
|
15783
15823
|
destTypeArgs.splice(destTypeArgs.length - 1, 1);
|
15784
15824
|
}
|
15785
|
-
|
15786
|
-
|
15787
|
-
// If the
|
15788
|
-
//
|
15789
|
-
|
15790
|
-
|
15791
|
-
|
15825
|
+
if (srcVariadicIndex >= 0) {
|
15826
|
+
const destArgsToCapture = destTypeArgs.length - srcTypeArgs.length + 1;
|
15827
|
+
// If we're doing reverse type mappings and the source contains a variadic
|
15828
|
+
// TypeVar, we need to adjust the dest so the reverse type mapping assignment
|
15829
|
+
// can be performed.
|
15830
|
+
if (destArgsToCapture >= 0 && (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0) {
|
15831
|
+
// If the only removed arg from the dest type args is itself a variadic,
|
15832
|
+
// don't bother adjusting it.
|
15833
|
+
const skipAdjustment = destArgsToCapture === 1 && (0, types_1.isVariadicTypeVar)(destTypeArgs[srcVariadicIndex].type);
|
15834
|
+
if (!skipAdjustment && tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
|
15835
|
+
const removedArgs = destTypeArgs.splice(srcVariadicIndex, destArgsToCapture);
|
15792
15836
|
// Package up the remaining type arguments into a tuple object.
|
15793
15837
|
const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
|
15794
15838
|
return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
|
15795
15839
|
}),
|
15796
15840
|
/* isTypeArgumentExplicit */ true,
|
15797
15841
|
/* isUnpackedTuple */ true));
|
15798
|
-
|
15842
|
+
destTypeArgs.splice(srcVariadicIndex, 0, {
|
15799
15843
|
type: variadicTuple,
|
15800
15844
|
isUnbounded: false,
|
15801
15845
|
});
|
15802
15846
|
}
|
15803
15847
|
}
|
15804
|
-
|
15805
|
-
|
15806
|
-
|
15807
|
-
|
15848
|
+
}
|
15849
|
+
else {
|
15850
|
+
const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
|
15851
|
+
if (destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
|
15852
|
+
// If the dest contains a variadic element, determine which source
|
15853
|
+
// args map to this element and package them up into an unpacked tuple.
|
15854
|
+
if ((0, types_1.isVariadicTypeVar)(destTypeArgs[destUnboundedOrVariadicIndex].type)) {
|
15855
|
+
if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
|
15856
|
+
const removedArgs = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture);
|
15857
|
+
// Package up the remaining type arguments into a tuple object.
|
15858
|
+
const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
|
15859
|
+
return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
|
15860
|
+
}),
|
15861
|
+
/* isTypeArgumentExplicit */ true,
|
15862
|
+
/* isUnpackedTuple */ true));
|
15863
|
+
srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
|
15864
|
+
type: variadicTuple,
|
15865
|
+
isUnbounded: false,
|
15866
|
+
});
|
15808
15867
|
}
|
15809
|
-
|
15810
|
-
|
15811
|
-
|
15812
|
-
|
15813
|
-
|
15814
|
-
|
15868
|
+
}
|
15869
|
+
else {
|
15870
|
+
const removedArgTypes = srcTypeArgs
|
15871
|
+
.splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
|
15872
|
+
.map((t) => {
|
15873
|
+
if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
|
15874
|
+
return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
|
15875
|
+
}
|
15876
|
+
return t.type;
|
15877
|
+
});
|
15878
|
+
srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
|
15879
|
+
type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
|
15880
|
+
isUnbounded: false,
|
15881
|
+
});
|
15882
|
+
}
|
15815
15883
|
}
|
15816
15884
|
}
|
15817
15885
|
return destTypeArgs.length === srcTypeArgs.length;
|
@@ -15820,8 +15888,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15820
15888
|
var _a, _b;
|
15821
15889
|
const destTypeArgs = [...((_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : [])];
|
15822
15890
|
const srcTypeArgs = [...((_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : [])];
|
15823
|
-
|
15824
|
-
if (adjustSrcTupleTypeArgs(reverseMapping ? srcTypeArgs : destTypeArgs, reverseMapping ? destTypeArgs : srcTypeArgs)) {
|
15891
|
+
if (adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags)) {
|
15825
15892
|
for (let argIndex = 0; argIndex < srcTypeArgs.length; argIndex++) {
|
15826
15893
|
const entryDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
15827
15894
|
if (!assignType(destTypeArgs[argIndex].type, srcTypeArgs[argIndex].type, entryDiag === null || entryDiag === void 0 ? void 0 : entryDiag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
@@ -16021,6 +16088,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16021
16088
|
else if (types_1.ClassType.isBuiltIn(destType, 'list')) {
|
16022
16089
|
childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionList());
|
16023
16090
|
}
|
16091
|
+
else if (types_1.ClassType.isBuiltIn(destType, 'set')) {
|
16092
|
+
childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionSet());
|
16093
|
+
}
|
16024
16094
|
}
|
16025
16095
|
}
|
16026
16096
|
else {
|
@@ -16337,7 +16407,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16337
16407
|
// PEP 544 says that if the dest type is a type[Proto] class,
|
16338
16408
|
// the source must be a "concrete" (non-protocol) class.
|
16339
16409
|
if (types_1.ClassType.isProtocolClass(destType) &&
|
16340
|
-
(flags &
|
16410
|
+
(flags & 8192 /* AssignTypeFlags.IgnoreProtocolAssignmentCheck */) === 0) {
|
16341
16411
|
if (types_1.ClassType.isProtocolClass(expandedSrcType) &&
|
16342
16412
|
(0, types_1.isInstantiableClass)(srcType) &&
|
16343
16413
|
!srcType.includeSubclasses) {
|
@@ -18249,7 +18319,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
18249
18319
|
}
|
18250
18320
|
}
|
18251
18321
|
else if (!assignType(memberTypeFirstParamType, firstParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), typeVarContext,
|
18252
|
-
/* srcTypeVarContext */ undefined,
|
18322
|
+
/* srcTypeVarContext */ undefined, 4096 /* AssignTypeFlags.AllowUnspecifiedTypeArguments */, recursionCount)) {
|
18253
18323
|
if (memberTypeFirstParam.name &&
|
18254
18324
|
!memberTypeFirstParam.isNameSynthesized &&
|
18255
18325
|
memberTypeFirstParam.hasDeclaredType) {
|