@zzzen/pyright-internal 1.2.0-dev.20260614 → 1.2.0-dev.20260628
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 +17 -7
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.d.ts +11 -0
- package/dist/analyzer/binder.js +31 -8
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +23 -8
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +6 -0
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/dataClasses.js +19 -8
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +1 -0
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/docStringUtils.d.ts +1 -0
- package/dist/analyzer/docStringUtils.js +78 -0
- package/dist/analyzer/docStringUtils.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -0
- package/dist/analyzer/importResolver.js +107 -12
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +36 -8
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +17 -7
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/parseTreeCleaner.js +17 -7
- package/dist/analyzer/parseTreeCleaner.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +27 -9
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +17 -7
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +44 -0
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -0
- package/dist/analyzer/program.js +44 -8
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +34 -8
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.js +43 -11
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceEnumerator.js +6 -0
- package/dist/analyzer/sourceEnumerator.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +1 -0
- package/dist/analyzer/sourceFile.js +25 -7
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +11 -1
- package/dist/analyzer/sourceMapper.js +220 -19
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +91 -19
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +17 -7
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +17 -7
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +8 -0
- package/dist/analyzer/typeDocStringUtils.js +101 -27
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +122 -89
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +71 -13
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +50 -8
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +17 -7
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -0
- package/dist/analyzer/typeUtils.js +9 -0
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +1 -1
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +19 -9
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/typeshedInfoProvider.js +17 -7
- package/dist/analyzer/typeshedInfoProvider.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +17 -7
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +17 -7
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +17 -7
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/configOptions.js +17 -7
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +17 -7
- package/dist/common/console.js.map +1 -1
- package/dist/common/docStringService.d.ts +2 -0
- package/dist/common/docStringService.js +5 -1
- package/dist/common/docStringService.js.map +1 -1
- package/dist/common/envVarUtils.js +17 -7
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +2 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +17 -7
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +4 -2
- package/dist/common/fullAccessHost.js +69 -16
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +33 -2
- package/dist/common/host.js +4 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/languageInfoUtils.js +12 -12
- package/dist/common/memUtils.js +18 -7
- package/dist/common/memUtils.js.map +1 -1
- package/dist/common/pathUtils.js +17 -7
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/positionUtils.js +19 -0
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/common/processUtils.js +17 -7
- package/dist/common/processUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +19 -19
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js +17 -7
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/streamUtils.d.ts +1 -1
- package/dist/common/textEditTracker.d.ts +1 -0
- package/dist/common/textEditTracker.js +31 -12
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/uri/fileUri.d.ts +1 -0
- package/dist/common/uri/fileUri.js +20 -0
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +5 -1
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uriMap.d.ts +4 -4
- package/dist/common/uri/uriMap.js +1 -0
- package/dist/common/uri/uriMap.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +2 -0
- package/dist/common/uri/uriUtils.js +22 -0
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/workspaceEditUtils.d.ts +1 -0
- package/dist/common/workspaceEditUtils.js +10 -0
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js +19 -4
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/autoImporter.js +17 -7
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +17 -7
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +11 -2
- package/dist/languageService/completionProvider.js +319 -65
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +18 -0
- package/dist/languageService/completionProviderUtils.js +42 -0
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +1 -1
- package/dist/languageService/definitionProvider.js +69 -10
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +17 -7
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +18 -0
- package/dist/languageService/documentSymbolCollector.js +102 -15
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +1 -1
- package/dist/languageService/hoverProvider.js +98 -23
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importStatementCandidates.d.ts +16 -0
- package/dist/languageService/importStatementCandidates.js +100 -0
- package/dist/languageService/importStatementCandidates.js.map +1 -0
- package/dist/languageService/referencesProvider.d.ts +16 -9
- package/dist/languageService/referencesProvider.js +205 -39
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.d.ts +7 -2
- package/dist/languageService/renameProvider.js +45 -17
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +54 -16
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js +17 -7
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +11 -0
- package/dist/languageService/tooltipUtils.js +67 -33
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +17 -7
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +8 -0
- package/dist/localization/localize.js +6 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +5 -0
- package/dist/parser/characters.js +17 -7
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +4 -0
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +1 -0
- package/dist/parser/parser.js +91 -38
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +23 -7
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js +16 -15
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.d.ts +15 -14
- package/dist/parser/tokenizerTypes.js +22 -15
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/pyright.js +17 -7
- package/dist/pyright.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.js +13 -6
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/benchmarks/parserBenchmark.test.js +17 -7
- package/dist/tests/benchmarks/parserBenchmark.test.js.map +1 -1
- package/dist/tests/benchmarks/tokenizerBenchmark.test.js +17 -7
- package/dist/tests/benchmarks/tokenizerBenchmark.test.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +17 -7
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +21 -7
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/collectionUtils.test.js +17 -7
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/common.test.js +17 -7
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/completionProviderUtils.test.d.ts +1 -0
- package/dist/tests/completionProviderUtils.test.js +56 -0
- package/dist/tests/completionProviderUtils.test.js.map +1 -0
- package/dist/tests/completions.test.js +118 -9
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +69 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js +17 -7
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/deferred.test.js +18 -8
- package/dist/tests/deferred.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +17 -7
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/diagnostics.test.js +35 -0
- package/dist/tests/diagnostics.test.js.map +1 -1
- package/dist/tests/docStringReturnExtraction.test.d.ts +1 -0
- package/dist/tests/docStringReturnExtraction.test.js +125 -0
- package/dist/tests/docStringReturnExtraction.test.js.map +1 -0
- package/dist/tests/envVarUtils.test.js +17 -7
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +17 -7
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +17 -7
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js +17 -7
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.call.unpackedGenericTypedDict.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.unpackedGenericTypedDict.fourslash.js +35 -0
- package/dist/tests/fourslash/completions.call.unpackedGenericTypedDict.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.keywords.expressionContext.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.keywords.expressionContext.fourslash.js +86 -0
- package/dist/tests/fourslash/completions.keywords.expressionContext.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js +20 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.compiledModule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.compiledModule.fourslash.js +122 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.compiledModule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.nativeSubmodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.nativeSubmodule.fourslash.js +61 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.nativeSubmodule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.js +1 -5
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.posonly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.posonly.fourslash.js +58 -0
- package/dist/tests/fourslash/signature.posonly.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js +17 -7
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.js +17 -7
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +17 -7
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.js +17 -7
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +17 -7
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +17 -7
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +17 -7
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testAccessHost.d.ts +1 -1
- package/dist/tests/harness/testAccessHost.js +1 -1
- package/dist/tests/harness/testAccessHost.js.map +1 -1
- package/dist/tests/harness/testHost.js +17 -7
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.d.ts +4 -4
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js +17 -7
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +19 -11
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +17 -7
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importResolver.test.js +137 -0
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +92 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/languageServer.test.js +91 -0
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/localizer.test.js +17 -7
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/logger.test.js +17 -7
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +17 -7
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.d.ts +1 -5
- package/dist/tests/lsp/languageServerTestUtils.js +77 -22
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parser.test.js +264 -7
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +17 -7
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js +26 -0
- package/dist/tests/positionUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +25 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/realTempFile.test.js +17 -7
- package/dist/tests/realTempFile.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js +73 -0
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +17 -7
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +192 -0
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/stringUtils.test.js +17 -7
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symbolNameUtils.test.js +17 -7
- package/dist/tests/symbolNameUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +17 -7
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testUtils.js +17 -7
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textRange.test.js +17 -7
- package/dist/tests/textRange.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +17 -7
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +21 -7
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +23 -7
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +23 -7
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +45 -7
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +17 -7
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +17 -7
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +17 -7
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +40 -28
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +82 -7
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/uri.test.js +17 -7
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +48 -7
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +17 -7
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +10 -10
- package/dist/tests/lsp/rspack.testserver.config.d.ts +0 -63
- package/dist/tests/lsp/rspack.testserver.config.js +0 -60
- package/dist/tests/lsp/rspack.testserver.config.js.map +0 -1
|
@@ -30,13 +30,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
30
30
|
}) : function(o, v) {
|
|
31
31
|
o["default"] = v;
|
|
32
32
|
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
40
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
51
|
exports.maxCodeComplexity = void 0;
|
|
42
52
|
exports.createTypeEvaluator = createTypeEvaluator;
|
|
@@ -554,9 +564,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
554
564
|
const anySpecialForm = types_1.AnyType.createSpecialForm();
|
|
555
565
|
if ((0, types_1.isAny)(anySpecialForm)) {
|
|
556
566
|
types_1.TypeBase.setSpecialForm(anySpecialForm, anyClass);
|
|
557
|
-
|
|
558
|
-
types_1.TypeBase.setTypeForm(anySpecialForm, (0, typeUtils_1.convertToInstance)(anySpecialForm));
|
|
559
|
-
}
|
|
567
|
+
types_1.TypeBase.setTypeForm(anySpecialForm, (0, typeUtils_1.convertToInstance)(anySpecialForm));
|
|
560
568
|
}
|
|
561
569
|
}
|
|
562
570
|
}
|
|
@@ -685,7 +693,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
685
693
|
// reported them when analyzing the contents of the string.
|
|
686
694
|
expectingInstantiable = false;
|
|
687
695
|
}
|
|
688
|
-
typeResult = getTypeOfStringList(node, flags);
|
|
696
|
+
typeResult = getTypeOfStringList(node, flags, inferenceContext);
|
|
689
697
|
break;
|
|
690
698
|
}
|
|
691
699
|
case 40 /* ParseNodeType.Number */: {
|
|
@@ -956,7 +964,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
956
964
|
}
|
|
957
965
|
return typeResult;
|
|
958
966
|
}
|
|
959
|
-
function getTypeOfStringList(node, flags) {
|
|
967
|
+
function getTypeOfStringList(node, flags, inferenceContext) {
|
|
960
968
|
let typeResult;
|
|
961
969
|
if ((flags & 8 /* EvalFlags.StrLiteralAsType */) !== 0 && (flags & 1073741824 /* EvalFlags.TypeFormArg */) === 0) {
|
|
962
970
|
return getTypeOfStringListAsType(node, flags);
|
|
@@ -1021,9 +1029,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
1021
1029
|
isIncomplete,
|
|
1022
1030
|
};
|
|
1023
1031
|
}
|
|
1024
|
-
if (node.d.strings.length !== 1 ||
|
|
1025
|
-
|
|
1026
|
-
|
|
1032
|
+
if (node.d.strings.length !== 1 || node.d.strings[0].nodeType !== 49 /* ParseNodeType.String */) {
|
|
1033
|
+
return typeResult;
|
|
1034
|
+
}
|
|
1035
|
+
// Only attempt to interpret the string as a TypeForm forward reference when
|
|
1036
|
+
// there's a signal that a TypeForm value is wanted in this context. Doing it
|
|
1037
|
+
// unconditionally can trigger expensive (and recursion-prone) type lookups
|
|
1038
|
+
// for plain string literals in non-type contexts.
|
|
1039
|
+
const wantsTypeForm = (flags & 1073741824 /* EvalFlags.TypeFormArg */) !== 0 ||
|
|
1040
|
+
(inferenceContext !== undefined && expectedTypeWantsTypeForm(inferenceContext.expectedType));
|
|
1041
|
+
if (!wantsTypeForm) {
|
|
1027
1042
|
return typeResult;
|
|
1028
1043
|
}
|
|
1029
1044
|
// For performance reasons, do not attempt to treat the string literal
|
|
@@ -1705,15 +1720,35 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
1705
1720
|
let signatures = [];
|
|
1706
1721
|
function addOneFunctionToSignature(type) {
|
|
1707
1722
|
let callResult;
|
|
1723
|
+
const constraints = new constraintTracker_1.ConstraintTracker();
|
|
1708
1724
|
useSpeculativeMode(callNode, () => {
|
|
1709
|
-
callResult = validateArgs(exprNode, argList, { type },
|
|
1710
|
-
/* constraints */ undefined,
|
|
1725
|
+
callResult = validateArgs(exprNode, argList, { type }, constraints,
|
|
1711
1726
|
/* skipUnknownArgCheck */ true,
|
|
1712
1727
|
/* inferenceContext */ undefined);
|
|
1713
1728
|
});
|
|
1729
|
+
const specializedType = solveAndApplyConstraints(type, constraints);
|
|
1730
|
+
const finalType = (0, types_1.isFunction)(specializedType) ? specializedType : type;
|
|
1731
|
+
const hasActiveArg = argList.some((arg) => arg.active);
|
|
1732
|
+
// If the type was specialized (e.g. ParamSpec expansion), the activeParam
|
|
1733
|
+
// from the original validateArgs refers to parameters in the unspecialized
|
|
1734
|
+
// type and won't match the specialized type's parameters. Re-run validateArgs
|
|
1735
|
+
// against the specialized type to get the correct activeParam mapping.
|
|
1736
|
+
let activeParam = callResult?.activeParam;
|
|
1737
|
+
if (hasActiveArg && finalType !== type) {
|
|
1738
|
+
let specializedActiveParam;
|
|
1739
|
+
useSpeculativeMode(callNode, () => {
|
|
1740
|
+
const specializedResult = validateArgs(exprNode, argList, { type: finalType }, new constraintTracker_1.ConstraintTracker(),
|
|
1741
|
+
/* skipUnknownArgCheck */ true,
|
|
1742
|
+
/* inferenceContext */ undefined);
|
|
1743
|
+
specializedActiveParam = specializedResult?.activeParam;
|
|
1744
|
+
});
|
|
1745
|
+
if (specializedActiveParam) {
|
|
1746
|
+
activeParam = specializedActiveParam;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1714
1749
|
signatures.push({
|
|
1715
|
-
type: expandTypedKwargs(
|
|
1716
|
-
activeParam
|
|
1750
|
+
type: expandTypedKwargs(finalType),
|
|
1751
|
+
activeParam,
|
|
1717
1752
|
});
|
|
1718
1753
|
}
|
|
1719
1754
|
function addFunctionToSignature(type) {
|
|
@@ -1796,11 +1831,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
1796
1831
|
types_1.FunctionType.addKeywordOnlyParamSeparator(newFunction);
|
|
1797
1832
|
}
|
|
1798
1833
|
tdEntries.forEach((tdEntry, name) => {
|
|
1799
|
-
|
|
1834
|
+
// A TypedDict entry type may carry the TypedDict's own type parameters (e.g. an unpacked
|
|
1835
|
+
// generic TypedDict `**kwargs: Unpack[TD[int]]`), so specialize each entry against the
|
|
1836
|
+
// (possibly generic) TypedDict instance. Specializing an already-concrete type is a
|
|
1837
|
+
// no-op, so this is safe for non-generic TypedDicts.
|
|
1838
|
+
const specializedValueType = (0, typeUtils_1.partiallySpecializeType)(tdEntry.valueType, kwargsType,
|
|
1839
|
+
/* typeClassType */ undefined);
|
|
1840
|
+
types_1.FunctionType.addParam(newFunction, types_1.FunctionParam.create(0 /* ParamCategory.Simple */, specializedValueType, types_1.FunctionParamFlags.TypeDeclared, name, tdEntry.isRequired ? undefined : specializedValueType));
|
|
1800
1841
|
});
|
|
1801
1842
|
const extraItemsType = kwargsType.shared.typedDictEntries?.extraItems?.valueType;
|
|
1802
1843
|
if (extraItemsType && !(0, types_1.isNever)(extraItemsType)) {
|
|
1803
|
-
|
|
1844
|
+
// Specialized for the same reason as the per-entry types above. This PEP 728
|
|
1845
|
+
// `extra_items` branch uses the identical mechanism and is intentionally not
|
|
1846
|
+
// separately tested.
|
|
1847
|
+
const specializedExtraItemsType = (0, typeUtils_1.partiallySpecializeType)(extraItemsType, kwargsType,
|
|
1848
|
+
/* typeClassType */ undefined);
|
|
1849
|
+
types_1.FunctionType.addParam(newFunction, types_1.FunctionParam.create(2 /* ParamCategory.KwargsDict */, specializedExtraItemsType, types_1.FunctionParamFlags.TypeDeclared, 'kwargs'));
|
|
1804
1850
|
}
|
|
1805
1851
|
return newFunction;
|
|
1806
1852
|
}
|
|
@@ -3359,9 +3405,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
3359
3405
|
return { type, isIncomplete };
|
|
3360
3406
|
}
|
|
3361
3407
|
function addTypeFormForSymbol(node, type, flags, includesVarDecl) {
|
|
3362
|
-
if (!isTypeFormSupported(node)) {
|
|
3363
|
-
return type;
|
|
3364
|
-
}
|
|
3365
3408
|
const isValid = isSymbolValidTypeExpression(type, includesVarDecl);
|
|
3366
3409
|
// If the type already has type information associated with it, don't replace.
|
|
3367
3410
|
if (type.props?.typeForm) {
|
|
@@ -5267,9 +5310,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
5267
5310
|
...aliasInfo,
|
|
5268
5311
|
typeArgs: aliasTypeArgs,
|
|
5269
5312
|
});
|
|
5270
|
-
|
|
5271
|
-
type = types_1.TypeBase.cloneWithTypeForm(type, reportedError ? undefined : (0, typeUtils_1.convertToInstance)(type));
|
|
5272
|
-
}
|
|
5313
|
+
type = types_1.TypeBase.cloneWithTypeForm(type, reportedError ? undefined : (0, typeUtils_1.convertToInstance)(type));
|
|
5273
5314
|
if (baseType.props?.typeAliasInfo) {
|
|
5274
5315
|
return { type, node };
|
|
5275
5316
|
}
|
|
@@ -6153,7 +6194,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
6153
6194
|
return { type: types_1.UnknownType.create() };
|
|
6154
6195
|
}
|
|
6155
6196
|
const typeFormResult = getTypeOfArgExpectingType(convertNodeToArg(node.d.args[0]), {
|
|
6156
|
-
typeFormArg:
|
|
6197
|
+
typeFormArg: true,
|
|
6157
6198
|
noNonTypeSpecialForms: true,
|
|
6158
6199
|
typeExpression: true,
|
|
6159
6200
|
});
|
|
@@ -9548,7 +9589,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
9548
9589
|
if (node.d.constType === 15 /* KeywordType.False */) {
|
|
9549
9590
|
return false;
|
|
9550
9591
|
}
|
|
9551
|
-
else if (node.d.constType ===
|
|
9592
|
+
else if (node.d.constType === 34 /* KeywordType.True */) {
|
|
9552
9593
|
return true;
|
|
9553
9594
|
}
|
|
9554
9595
|
}
|
|
@@ -9669,25 +9710,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
9669
9710
|
}
|
|
9670
9711
|
function getTypeOfConstant(node, flags) {
|
|
9671
9712
|
let type;
|
|
9672
|
-
if (node.d.constType ===
|
|
9713
|
+
if (node.d.constType === 27 /* KeywordType.None */) {
|
|
9673
9714
|
if (prefetched?.noneTypeClass) {
|
|
9674
9715
|
type =
|
|
9675
9716
|
(flags & 128 /* EvalFlags.InstantiableType */) !== 0
|
|
9676
9717
|
? prefetched.noneTypeClass
|
|
9677
9718
|
: (0, typeUtils_1.convertToInstance)(prefetched.noneTypeClass);
|
|
9678
|
-
|
|
9679
|
-
type = types_1.TypeBase.cloneWithTypeForm(type, (0, typeUtils_1.convertToInstance)(type));
|
|
9680
|
-
}
|
|
9719
|
+
type = types_1.TypeBase.cloneWithTypeForm(type, (0, typeUtils_1.convertToInstance)(type));
|
|
9681
9720
|
}
|
|
9682
9721
|
}
|
|
9683
|
-
else if (node.d.constType ===
|
|
9722
|
+
else if (node.d.constType === 34 /* KeywordType.True */ ||
|
|
9684
9723
|
node.d.constType === 15 /* KeywordType.False */ ||
|
|
9685
9724
|
node.d.constType === 9 /* KeywordType.Debug */) {
|
|
9686
9725
|
type = getBuiltInObject(node, 'bool');
|
|
9687
9726
|
// For True and False, we can create truthy and falsy
|
|
9688
9727
|
// versions of 'bool'.
|
|
9689
9728
|
if (type && (0, types_1.isClassInstance)(type)) {
|
|
9690
|
-
if (node.d.constType ===
|
|
9729
|
+
if (node.d.constType === 34 /* KeywordType.True */) {
|
|
9691
9730
|
type = types_1.ClassType.cloneWithLiteral(type, /* value */ true);
|
|
9692
9731
|
}
|
|
9693
9732
|
else if (node.d.constType === 15 /* KeywordType.False */) {
|
|
@@ -10987,7 +11026,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
10987
11026
|
if (paramSpec) {
|
|
10988
11027
|
types_1.FunctionType.addParamSpecVariadics(functionType, (0, typeUtils_1.convertToInstance)(paramSpec));
|
|
10989
11028
|
}
|
|
10990
|
-
if (
|
|
11029
|
+
if (isValidTypeForm) {
|
|
10991
11030
|
functionType = types_1.TypeBase.cloneWithTypeForm(functionType, (0, typeUtils_1.convertToInstance)(functionType));
|
|
10992
11031
|
}
|
|
10993
11032
|
return functionType;
|
|
@@ -11092,13 +11131,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11092
11131
|
}
|
|
11093
11132
|
}
|
|
11094
11133
|
else if (itemExpr.nodeType === 14 /* ParseNodeType.Constant */) {
|
|
11095
|
-
if (itemExpr.d.constType ===
|
|
11134
|
+
if (itemExpr.d.constType === 34 /* KeywordType.True */) {
|
|
11096
11135
|
type = cloneBuiltinClassWithLiteral(node, classType, 'bool', true);
|
|
11097
11136
|
}
|
|
11098
11137
|
else if (itemExpr.d.constType === 15 /* KeywordType.False */) {
|
|
11099
11138
|
type = cloneBuiltinClassWithLiteral(node, classType, 'bool', false);
|
|
11100
11139
|
}
|
|
11101
|
-
else if (itemExpr.d.constType ===
|
|
11140
|
+
else if (itemExpr.d.constType === 27 /* KeywordType.None */) {
|
|
11102
11141
|
type = prefetched?.noneTypeClass ?? types_1.UnknownType.create();
|
|
11103
11142
|
}
|
|
11104
11143
|
}
|
|
@@ -11152,7 +11191,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11152
11191
|
if ((0, types_1.isUnion)(result) && prefetched?.unionTypeClass && (0, types_1.isInstantiableClass)(prefetched.unionTypeClass)) {
|
|
11153
11192
|
result = types_1.TypeBase.cloneAsSpecialForm(result, types_1.ClassType.cloneAsInstance(prefetched.unionTypeClass));
|
|
11154
11193
|
}
|
|
11155
|
-
if (
|
|
11194
|
+
if (isValidTypeForm) {
|
|
11156
11195
|
result = types_1.TypeBase.cloneWithTypeForm(result, (0, typeUtils_1.convertToInstance)(result));
|
|
11157
11196
|
}
|
|
11158
11197
|
return result;
|
|
@@ -11198,9 +11237,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11198
11237
|
return (0, typeUtils_1.convertToInstance)(validateTypeArg(typeArg) ? typeArg.type : types_1.UnknownType.create());
|
|
11199
11238
|
});
|
|
11200
11239
|
let resultType = types_1.ClassType.specialize(classType, convertedTypeArgs);
|
|
11201
|
-
|
|
11202
|
-
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
11203
|
-
}
|
|
11240
|
+
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
11204
11241
|
return resultType;
|
|
11205
11242
|
}
|
|
11206
11243
|
// Creates a "TypeGuard" and "TypeIs" type.
|
|
@@ -11222,9 +11259,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11222
11259
|
return (0, typeUtils_1.convertToInstance)(validateTypeArg(typeArg) ? typeArg.type : types_1.UnknownType.create());
|
|
11223
11260
|
});
|
|
11224
11261
|
let resultType = types_1.ClassType.specialize(classType, convertedTypeArgs);
|
|
11225
|
-
|
|
11226
|
-
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
11227
|
-
}
|
|
11262
|
+
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
11228
11263
|
return resultType;
|
|
11229
11264
|
}
|
|
11230
11265
|
function createSelfType(classType, errorNode, typeArgs, flags) {
|
|
@@ -11657,7 +11692,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11657
11692
|
unionType = types_1.TypeBase.cloneWithTypeForm(unionType, undefined);
|
|
11658
11693
|
}
|
|
11659
11694
|
}
|
|
11660
|
-
else
|
|
11695
|
+
else {
|
|
11661
11696
|
const typeFormType = (0, types_1.combineTypes)(types.map((t) => t.props.typeForm));
|
|
11662
11697
|
unionType = types_1.TypeBase.cloneWithTypeForm(unionType, typeFormType);
|
|
11663
11698
|
}
|
|
@@ -11923,16 +11958,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
11923
11958
|
if (assignedName === 'LiteralString') {
|
|
11924
11959
|
specialType.shared.baseClasses.push(prefetched?.strClass ?? types_1.AnyType.create());
|
|
11925
11960
|
(0, typeUtils_1.computeMroLinearization)(specialType);
|
|
11926
|
-
|
|
11927
|
-
specialType = types_1.TypeBase.cloneWithTypeForm(specialType, (0, typeUtils_1.convertToInstance)(specialType));
|
|
11928
|
-
}
|
|
11961
|
+
specialType = types_1.TypeBase.cloneWithTypeForm(specialType, (0, typeUtils_1.convertToInstance)(specialType));
|
|
11929
11962
|
}
|
|
11930
11963
|
// Handle 'Never' and 'NoReturn' specially.
|
|
11931
11964
|
if (assignedName === 'Never' || assignedName === 'NoReturn') {
|
|
11932
11965
|
specialType = types_1.TypeBase.cloneAsSpecialForm(assignedName === 'Never' ? types_1.NeverType.createNever() : types_1.NeverType.createNoReturn(), specialType);
|
|
11933
|
-
|
|
11934
|
-
specialType = types_1.TypeBase.cloneWithTypeForm(specialType, (0, typeUtils_1.convertToInstance)(specialType));
|
|
11935
|
-
}
|
|
11966
|
+
specialType = types_1.TypeBase.cloneWithTypeForm(specialType, (0, typeUtils_1.convertToInstance)(specialType));
|
|
11936
11967
|
}
|
|
11937
11968
|
writeTypeCache(node, { type: specialType }, 0 /* EvalFlags.None */);
|
|
11938
11969
|
return specialType;
|
|
@@ -13625,7 +13656,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
13625
13656
|
// of the specified type and 'None'). Skip this step if the type is already
|
|
13626
13657
|
// optional to avoid losing alias names when combining the types.
|
|
13627
13658
|
if (param.d.defaultValue?.nodeType === 14 /* ParseNodeType.Constant */ &&
|
|
13628
|
-
param.d.defaultValue.d.constType ===
|
|
13659
|
+
param.d.defaultValue.d.constType === 27 /* KeywordType.None */ &&
|
|
13629
13660
|
!(0, typeUtils_1.isOptionalType)(type) &&
|
|
13630
13661
|
!AnalyzerNodeInfo.getFileInfo(param).diagnosticRuleSet.strictParameterNoneValue) {
|
|
13631
13662
|
return (0, types_1.combineTypes)([type, getNoneType()]);
|
|
@@ -14736,6 +14767,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
14736
14767
|
evaluateTypesForAssignmentStatement(parent);
|
|
14737
14768
|
return;
|
|
14738
14769
|
}
|
|
14770
|
+
case 5 /* ParseNodeType.AugmentedAssignment */: {
|
|
14771
|
+
evaluateTypesForAugmentedAssignment(parent);
|
|
14772
|
+
return;
|
|
14773
|
+
}
|
|
14739
14774
|
}
|
|
14740
14775
|
if (nodeToEvaluate.nodeType === 54 /* ParseNodeType.TypeAnnotation */) {
|
|
14741
14776
|
evaluateTypesForTypeAnnotationNode(nodeToEvaluate);
|
|
@@ -15010,9 +15045,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15010
15045
|
}
|
|
15011
15046
|
let resultType = aliasedName === 'Never' ? types_1.NeverType.createNever() : types_1.NeverType.createNoReturn();
|
|
15012
15047
|
resultType = types_1.TypeBase.cloneAsSpecialForm(resultType, classType);
|
|
15013
|
-
|
|
15014
|
-
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
15015
|
-
}
|
|
15048
|
+
resultType = types_1.TypeBase.cloneWithTypeForm(resultType, (0, typeUtils_1.convertToInstance)(resultType));
|
|
15016
15049
|
return { type: resultType };
|
|
15017
15050
|
}
|
|
15018
15051
|
case 'Optional': {
|
|
@@ -15025,9 +15058,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15025
15058
|
if ((0, types_1.isInstantiableClass)(typeType)) {
|
|
15026
15059
|
typeType = (0, typeUtils_1.explodeGenericClass)(typeType);
|
|
15027
15060
|
}
|
|
15028
|
-
|
|
15029
|
-
typeType = types_1.TypeBase.cloneWithTypeForm(typeType, (0, typeUtils_1.convertToInstance)(typeType));
|
|
15030
|
-
}
|
|
15061
|
+
typeType = types_1.TypeBase.cloneWithTypeForm(typeType, (0, typeUtils_1.convertToInstance)(typeType));
|
|
15031
15062
|
return { type: typeType };
|
|
15032
15063
|
}
|
|
15033
15064
|
case 'ClassVar': {
|
|
@@ -15136,9 +15167,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15136
15167
|
if ((0, types_1.isInstantiableClass)(typeType)) {
|
|
15137
15168
|
typeType = (0, typeUtils_1.explodeGenericClass)(typeType);
|
|
15138
15169
|
}
|
|
15139
|
-
|
|
15140
|
-
typeType = types_1.TypeBase.cloneWithTypeForm(typeType, (0, typeUtils_1.convertToInstance)(typeType));
|
|
15141
|
-
}
|
|
15170
|
+
typeType = types_1.TypeBase.cloneWithTypeForm(typeType, (0, typeUtils_1.convertToInstance)(typeType));
|
|
15142
15171
|
return { type: typeType };
|
|
15143
15172
|
}
|
|
15144
15173
|
}
|
|
@@ -15149,9 +15178,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15149
15178
|
/* paramLimit */ undefined,
|
|
15150
15179
|
/* allowParamSpec */ undefined,
|
|
15151
15180
|
/* isSpecialForm */ false);
|
|
15152
|
-
|
|
15153
|
-
specializedClass = types_1.TypeBase.cloneWithTypeForm(specializedClass, (0, typeUtils_1.convertToInstance)(specializedClass));
|
|
15154
|
-
}
|
|
15181
|
+
specializedClass = types_1.TypeBase.cloneWithTypeForm(specializedClass, (0, typeUtils_1.convertToInstance)(specializedClass));
|
|
15155
15182
|
return { type: specializedClass };
|
|
15156
15183
|
}
|
|
15157
15184
|
}
|
|
@@ -15343,9 +15370,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15343
15370
|
typeArgTypes = typeArgs.map((t) => (0, typeUtils_1.convertToInstance)(t.type));
|
|
15344
15371
|
}
|
|
15345
15372
|
let specializedClass = types_1.ClassType.specialize(classType, typeArgTypes, typeArgs !== undefined);
|
|
15346
|
-
|
|
15347
|
-
specializedClass = types_1.TypeBase.cloneWithTypeForm(specializedClass, isValidTypeForm ? (0, typeUtils_1.convertToInstance)(specializedClass) : undefined);
|
|
15348
|
-
}
|
|
15373
|
+
specializedClass = types_1.TypeBase.cloneWithTypeForm(specializedClass, isValidTypeForm ? (0, typeUtils_1.convertToInstance)(specializedClass) : undefined);
|
|
15349
15374
|
return { type: specializedClass };
|
|
15350
15375
|
}
|
|
15351
15376
|
// PEP 612 says that if the class has only one type parameter consisting
|
|
@@ -18256,6 +18281,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
18256
18281
|
});
|
|
18257
18282
|
return isAssignable;
|
|
18258
18283
|
}
|
|
18284
|
+
function expectedTypeWantsTypeForm(expectedType) {
|
|
18285
|
+
return (0, typeUtils_1.someSubtypes)(expectedType, (subtype) => (0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'TypeForm'));
|
|
18286
|
+
}
|
|
18259
18287
|
// If the expected type is an explicit TypeForm type, see if the source
|
|
18260
18288
|
// type has an implicit TypeForm type that can be assigned to it. If so,
|
|
18261
18289
|
// convert to an explicit TypeForm type.
|
|
@@ -19174,9 +19202,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19174
19202
|
continue;
|
|
19175
19203
|
}
|
|
19176
19204
|
const nonDefaultSrcParamCount = srcParamDetails.params.filter((p) => !!p.param.name && !p.defaultType && p.param.category === 0 /* ParamCategory.Simple */).length;
|
|
19177
|
-
diag?.createAddendum().addMessage(localize_1.LocAddendum.
|
|
19178
|
-
expected:
|
|
19179
|
-
received:
|
|
19205
|
+
diag?.createAddendum().addMessage(localize_1.LocAddendum.functionTooManyParams().format({
|
|
19206
|
+
expected: destPositionalCount,
|
|
19207
|
+
received: nonDefaultSrcParamCount,
|
|
19180
19208
|
}));
|
|
19181
19209
|
canAssign = false;
|
|
19182
19210
|
break;
|
|
@@ -19228,9 +19256,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19228
19256
|
}
|
|
19229
19257
|
}
|
|
19230
19258
|
if (srcPositionalCount < adjDestPositionalCount) {
|
|
19231
|
-
diag?.addMessage(localize_1.LocAddendum.
|
|
19232
|
-
expected:
|
|
19233
|
-
received:
|
|
19259
|
+
diag?.addMessage(localize_1.LocAddendum.functionTooFewParams().format({
|
|
19260
|
+
expected: adjDestPositionalCount,
|
|
19261
|
+
received: srcPositionalCount,
|
|
19234
19262
|
}));
|
|
19235
19263
|
canAssign = false;
|
|
19236
19264
|
}
|
|
@@ -19780,15 +19808,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19780
19808
|
}
|
|
19781
19809
|
}
|
|
19782
19810
|
else if (overrideParamDetails.positionParamCount > baseParamDetails.positionParamCount) {
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
|
|
19811
|
+
const isCallableAttrOverriddenByInstanceMethod = baseParamDetails.positionParamCount === 0 &&
|
|
19812
|
+
overrideParamDetails.positionParamCount === 1 &&
|
|
19813
|
+
types_1.FunctionType.isInstanceMethod(overrideMethod) &&
|
|
19814
|
+
!types_1.FunctionType.isStaticMethod(baseMethod) &&
|
|
19815
|
+
!types_1.FunctionType.isClassMethod(baseMethod);
|
|
19816
|
+
if (!isCallableAttrOverriddenByInstanceMethod) {
|
|
19817
|
+
// Verify that all of the override parameters that extend the
|
|
19818
|
+
// signature are either *args, **kwargs or parameters with
|
|
19819
|
+
// default values.
|
|
19820
|
+
for (let i = baseParamDetails.positionParamCount; i < overrideParamDetails.positionParamCount; i++) {
|
|
19821
|
+
const overrideParam = overrideParamDetails.params[i].param;
|
|
19822
|
+
if (overrideParam.category === 0 /* ParamCategory.Simple */ &&
|
|
19823
|
+
overrideParam.name &&
|
|
19824
|
+
!overrideParamDetails.params[i].defaultType) {
|
|
19825
|
+
foundParamCountMismatch = true;
|
|
19826
|
+
}
|
|
19792
19827
|
}
|
|
19793
19828
|
}
|
|
19794
19829
|
}
|
|
@@ -20311,7 +20346,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
20311
20346
|
case 49 /* ParseNodeType.String */:
|
|
20312
20347
|
return allowStrLiteral;
|
|
20313
20348
|
case 14 /* ParseNodeType.Constant */:
|
|
20314
|
-
return node.d.constType ===
|
|
20349
|
+
return node.d.constType === 27 /* KeywordType.None */;
|
|
20315
20350
|
case 7 /* ParseNodeType.BinaryOperation */:
|
|
20316
20351
|
return (node.d.operator === 6 /* OperatorType.BitwiseOr */ &&
|
|
20317
20352
|
isLegalTypeAliasExpressionForm(node.d.leftExpr, /* allowStrLiteral */ true) &&
|
|
@@ -20396,11 +20431,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
20396
20431
|
}
|
|
20397
20432
|
return { sourceType: simpleSrcType, destType: simpleDestType };
|
|
20398
20433
|
}
|
|
20399
|
-
function isTypeFormSupported(node) {
|
|
20400
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
20401
|
-
// For now, enable only if enableExperimentalFeatures is true.
|
|
20402
|
-
return fileInfo.diagnosticRuleSet.enableExperimentalFeatures;
|
|
20403
|
-
}
|
|
20404
20434
|
function printType(type, options) {
|
|
20405
20435
|
let flags = evaluatorOptions.printTypeFlags;
|
|
20406
20436
|
if (options?.expandTypeAlias) {
|
|
@@ -20424,6 +20454,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
20424
20454
|
if (options?.useFullyQualifiedNames) {
|
|
20425
20455
|
flags |= 4096 /* TypePrinter.PrintTypeFlags.UseFullyQualifiedNames */;
|
|
20426
20456
|
}
|
|
20457
|
+
if (options?.disablePep604) {
|
|
20458
|
+
flags &= ~8 /* TypePrinter.PrintTypeFlags.PEP604 */;
|
|
20459
|
+
}
|
|
20427
20460
|
return TypePrinter.printType(type, flags, getEffectiveReturnType);
|
|
20428
20461
|
}
|
|
20429
20462
|
// Calls back into the parser to parse the contents of a string literal.
|