@zzzen/pyright-internal 1.2.0-dev.20240128 → 1.2.0-dev.20240225
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 +4 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +1 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -2
- package/dist/analyzer/checker.js +251 -121
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/circularDependency.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +29 -3
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/commentUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +2 -2
- package/dist/analyzer/constraintSolver.js +28 -6
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +6 -6
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +6 -6
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/deprecatedSymbols.js.map +1 -1
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/docStringUtils.js.map +1 -1
- package/dist/analyzer/enums.d.ts +4 -1
- package/dist/analyzer/enums.js +30 -16
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +12 -4
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +2 -0
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +1 -1
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +6 -0
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +1 -0
- package/dist/analyzer/parameterUtils.js +16 -2
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeCleaner.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -0
- package/dist/analyzer/parseTreeUtils.js +4 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +90 -61
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -1
- package/dist/analyzer/program.js +2 -2
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +2 -2
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pyTypedUtils.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +4 -4
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js +1 -1
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolNameUtils.js.map +1 -1
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +433 -334
- 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/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +10 -5
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +1 -1
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +0 -1
- package/dist/analyzer/typeUtils.js +22 -8
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +2 -2
- package/dist/analyzer/typeVarContext.js +10 -4
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +6 -3
- package/dist/analyzer/typedDicts.js +292 -65
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +38 -26
- package/dist/analyzer/types.js +99 -72
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/commandResult.js.map +1 -1
- package/dist/commands/commands.js.map +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +18 -18
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/commands/restartServer.js.map +1 -1
- package/dist/common/cancellationUtils.d.ts +6 -1
- package/dist/common/cancellationUtils.js +18 -4
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/charCodes.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/commandUtils.js.map +1 -1
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/debug.js.map +1 -1
- package/dist/common/deferred.js.map +1 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +2 -1
- package/dist/common/envVarUtils.js +5 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/extensions.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fileWatcher.js.map +1 -1
- package/dist/common/fullAccessHost.js +1 -1
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/memUtils.js.map +1 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.js +1 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/timing.js.map +1 -1
- package/dist/common/uri/baseUri.d.ts +2 -0
- package/dist/common/uri/baseUri.js +7 -7
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/emptyUri.d.ts +2 -0
- package/dist/common/uri/emptyUri.js +6 -0
- package/dist/common/uri/emptyUri.js.map +1 -1
- package/dist/common/uri/fileUri.d.ts +6 -4
- package/dist/common/uri/fileUri.js +18 -9
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.d.ts +8 -0
- package/dist/common/uri/uri.js +16 -7
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.d.ts +3 -1
- package/dist/common/uri/webUri.js +21 -8
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +1 -0
- package/dist/languageService/autoImporter.js +3 -1
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +11 -3
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.js +1 -1
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js +11 -1
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +45 -3
- package/dist/localization/localize.js +16 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +15 -9
- package/dist/localization/package.nls.de.json +17 -11
- package/dist/localization/package.nls.en-us.json +25 -12
- package/dist/localization/package.nls.es.json +16 -10
- package/dist/localization/package.nls.fr.json +16 -10
- package/dist/localization/package.nls.it.json +16 -10
- package/dist/localization/package.nls.ja.json +17 -11
- package/dist/localization/package.nls.ko.json +14 -8
- package/dist/localization/package.nls.pl.json +14 -8
- package/dist/localization/package.nls.pt-br.json +17 -11
- package/dist/localization/package.nls.qps-ploc.json +12 -6
- package/dist/localization/package.nls.ru.json +17 -11
- package/dist/localization/package.nls.tr.json +16 -10
- package/dist/localization/package.nls.zh-cn.json +17 -11
- package/dist/localization/package.nls.zh-tw.json +17 -11
- package/dist/nodeMain.js.map +1 -1
- package/dist/nodeServer.js.map +1 -1
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/parser/unicode.js.map +1 -1
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.js +9 -7
- package/dist/server.js.map +1 -1
- package/dist/tests/cacheManager.test.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +0 -4
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/completions.test.js +23 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +1 -2
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/deferred.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/diagnostics.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/docStringUtils.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.d.ts +1 -0
- package/dist/tests/envVarUtils.test.js +130 -0
- package/dist/tests/envVarUtils.test.js.map +1 -0
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.comment.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dunderNew.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.enums.members.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.errorNodes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.excluded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +1 -1
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importPytyped.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.included.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.default.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.default.importStub.js.map +1 -1
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.property.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.stub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.parameters.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.parentFolder.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.property.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.typeAlias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.typeshed.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.with.fourslash.js.map +1 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/fourslash.js.map +1 -1
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.async.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.formatted.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.import.django.view.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.import.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inferred.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.slots.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.multipart.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.wildcard.fourslash.js.map +1 -1
- package/dist/tests/fourslash/importnotresolved.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/noerrors.fourslash.js.map +1 -1
- package/dist/tests/fourslash/orderImports1.command.fourslash.js.map +1 -1
- package/dist/tests/fourslash/orderImports2.command.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.function.untitledFile.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.library.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +1 -1
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.parens.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/typeVerifier.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.js +1 -1
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +0 -13
- package/dist/tests/harness/fourslash/testState.js +11 -0
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testAccessHost.js.map +1 -1
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/hoverProvider.test.js.map +1 -1
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +8 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.d.ts +1 -0
- package/dist/tests/languageServer.test.js +137 -0
- package/dist/tests/languageServer.test.js.map +1 -0
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/lsp/customLsp.d.ts +112 -0
- package/dist/tests/lsp/customLsp.js +67 -0
- package/dist/tests/lsp/customLsp.js.map +1 -0
- package/dist/tests/lsp/languageServer.d.ts +1 -0
- package/dist/tests/lsp/languageServer.js +326 -0
- package/dist/tests/lsp/languageServer.js.map +1 -0
- package/dist/tests/lsp/languageServerTestUtils.d.ts +100 -0
- package/dist/tests/lsp/languageServerTestUtils.js +803 -0
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -0
- package/dist/tests/lsp/main.d.ts +1 -0
- package/dist/tests/lsp/main.js +12 -0
- package/dist/tests/lsp/main.js.map +1 -0
- package/dist/tests/lsp/webpack.testserver.config.d.ts +4 -0
- package/dist/tests/lsp/webpack.testserver.config.js +64 -0
- package/dist/tests/lsp/webpack.testserver.config.js.map +1 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/serialization.test.js.map +1 -1
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symbolNameUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/textRange.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +21 -5
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +8 -4
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +5 -9
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +43 -1
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/uri.test.js +74 -26
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -1
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +23 -15
- package/dist/analyzer/regions.d.ts +0 -11
- package/dist/analyzer/regions.js +0 -62
- package/dist/analyzer/regions.js.map +0 -1
@@ -32,7 +32,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
32
|
return result;
|
33
33
|
};
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
exports.narrowForKeyAssignment = exports.getTypeOfIndexedTypedDict = exports.assignToTypedDict = exports.assignTypedDictToTypedDict = exports.getTypedDictMembersForClass = exports.synthesizeTypedDictClassMethods = exports.createTypedDictTypeInlined = exports.createTypedDictType = void 0;
|
35
|
+
exports.narrowForKeyAssignment = exports.getTypeOfIndexedTypedDict = exports.assignToTypedDict = exports.assignTypedDictToTypedDict = exports.getEffectiveExtraItemsEntryType = exports.getTypedDictDictEquivalent = exports.getTypedDictMappingEquivalent = exports.getTypedDictMembersForClass = exports.synthesizeTypedDictClassMethods = exports.createTypedDictTypeInlined = exports.createTypedDictType = void 0;
|
36
36
|
const collectionUtils_1 = require("../common/collectionUtils");
|
37
37
|
const debug_1 = require("../common/debug");
|
38
38
|
const diagnostic_1 = require("../common/diagnostic");
|
@@ -49,7 +49,7 @@ const typeUtils_1 = require("./typeUtils");
|
|
49
49
|
const typeVarContext_1 = require("./typeVarContext");
|
50
50
|
// Creates a new custom TypedDict "alternate syntax" factory class.
|
51
51
|
function createTypedDictType(evaluator, errorNode, typedDictClass, argList) {
|
52
|
-
var _a, _b;
|
52
|
+
var _a, _b, _c;
|
53
53
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
54
54
|
// TypedDict supports two different syntaxes:
|
55
55
|
// Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
|
@@ -70,7 +70,7 @@ function createTypedDictType(evaluator, errorNode, typedDictClass, argList) {
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
const effectiveClassName = className || 'TypedDict';
|
73
|
-
const classType = types_1.ClassType.createInstantiable(effectiveClassName, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, effectiveClassName), fileInfo.moduleName, fileInfo.fileUri, 128 /* ClassTypeFlags.TypedDictClass */ |
|
73
|
+
const classType = types_1.ClassType.createInstantiable(effectiveClassName, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, effectiveClassName), fileInfo.moduleName, fileInfo.fileUri, 128 /* ClassTypeFlags.TypedDictClass */ | 1073741824 /* ClassTypeFlags.ValidTypeAliasClass */, ParseTreeUtils.getTypeSourceId(errorNode),
|
74
74
|
/* declaredMetaclass */ undefined, typedDictClass.details.effectiveMetaclass);
|
75
75
|
classType.details.baseClasses.push(typedDictClass);
|
76
76
|
(0, typeUtils_1.computeMroLinearization)(classType);
|
@@ -122,7 +122,7 @@ function createTypedDictType(evaluator, errorNode, typedDictClass, argList) {
|
|
122
122
|
}
|
123
123
|
if (usingDictSyntax) {
|
124
124
|
for (const arg of argList.slice(2)) {
|
125
|
-
if (((_a = arg.name) === null || _a === void 0 ? void 0 : _a.value) === 'total') {
|
125
|
+
if (((_a = arg.name) === null || _a === void 0 ? void 0 : _a.value) === 'total' || ((_b = arg.name) === null || _b === void 0 ? void 0 : _b.value) === 'closed') {
|
126
126
|
if (!arg.valueExpression ||
|
127
127
|
arg.valueExpression.nodeType !== 11 /* ParseNodeType.Constant */ ||
|
128
128
|
!(arg.valueExpression.constType === 15 /* KeywordType.False */ ||
|
@@ -130,7 +130,13 @@ function createTypedDictType(evaluator, errorNode, typedDictClass, argList) {
|
|
130
130
|
evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictBoolParam().format({ name: arg.name.value }), arg.valueExpression || errorNode);
|
131
131
|
}
|
132
132
|
else if (arg.name.value === 'total' && arg.valueExpression.constType === 15 /* KeywordType.False */) {
|
133
|
-
classType.details.flags |=
|
133
|
+
classType.details.flags |= 1024 /* ClassTypeFlags.CanOmitDictValues */;
|
134
|
+
}
|
135
|
+
else if (arg.name.value === 'closed' && arg.valueExpression.constType === 33 /* KeywordType.True */) {
|
136
|
+
if (AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.enableExperimentalFeatures) {
|
137
|
+
classType.details.flags |=
|
138
|
+
256 /* ClassTypeFlags.TypedDictMarkedClosed */ | 512 /* ClassTypeFlags.TypedDictEffectivelyClosed */;
|
139
|
+
}
|
134
140
|
}
|
135
141
|
}
|
136
142
|
else {
|
@@ -138,9 +144,9 @@ function createTypedDictType(evaluator, errorNode, typedDictClass, argList) {
|
|
138
144
|
}
|
139
145
|
}
|
140
146
|
}
|
141
|
-
synthesizeTypedDictClassMethods(evaluator, errorNode, classType
|
147
|
+
synthesizeTypedDictClassMethods(evaluator, errorNode, classType);
|
142
148
|
// Validate that the assigned variable name is consistent with the provided name.
|
143
|
-
if (((
|
149
|
+
if (((_c = errorNode.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 3 /* ParseNodeType.Assignment */ && className) {
|
144
150
|
const target = errorNode.parent.leftExpression;
|
145
151
|
const typedDictTarget = target.nodeType === 54 /* ParseNodeType.TypeAnnotation */ ? target.valueExpression : target;
|
146
152
|
if (typedDictTarget.nodeType === 38 /* ParseNodeType.Name */) {
|
@@ -163,11 +169,12 @@ function createTypedDictTypeInlined(evaluator, dictNode, typedDictClass) {
|
|
163
169
|
classType.details.baseClasses.push(typedDictClass);
|
164
170
|
(0, typeUtils_1.computeMroLinearization)(classType);
|
165
171
|
getTypedDictFieldsFromDictSyntax(evaluator, dictNode, classType.details.fields, /* isInline */ true);
|
166
|
-
synthesizeTypedDictClassMethods(evaluator, dictNode, classType
|
172
|
+
synthesizeTypedDictClassMethods(evaluator, dictNode, classType);
|
167
173
|
return classType;
|
168
174
|
}
|
169
175
|
exports.createTypedDictTypeInlined = createTypedDictTypeInlined;
|
170
|
-
function synthesizeTypedDictClassMethods(evaluator, node, classType
|
176
|
+
function synthesizeTypedDictClassMethods(evaluator, node, classType) {
|
177
|
+
var _a;
|
171
178
|
(0, debug_1.assert)(types_1.ClassType.isTypedDictClass(classType));
|
172
179
|
// Synthesize a __new__ method.
|
173
180
|
const newType = types_1.FunctionType.createSynthesizedInstance('__new__', 1 /* FunctionTypeFlags.ConstructorMethod */);
|
@@ -209,9 +216,9 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
209
216
|
// All parameters must be named, so insert an empty "*".
|
210
217
|
types_1.FunctionType.addKeywordOnlyParameterSeparator(initOverride2);
|
211
218
|
const entries = getTypedDictMembersForClass(evaluator, classType);
|
212
|
-
|
213
|
-
let allEntriesAreReadOnly =
|
214
|
-
entries.forEach((entry, name) => {
|
219
|
+
const extraEntriesInfo = (_a = entries.extraItems) !== null && _a !== void 0 ? _a : getEffectiveExtraItemsEntryType(evaluator, classType);
|
220
|
+
let allEntriesAreReadOnly = entries.knownItems.size > 0;
|
221
|
+
entries.knownItems.forEach((entry, name) => {
|
215
222
|
types_1.FunctionType.addParameter(initOverride1, {
|
216
223
|
category: 0 /* ParameterCategory.Simple */,
|
217
224
|
name,
|
@@ -226,13 +233,26 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
226
233
|
type: entry.valueType,
|
227
234
|
hasDeclaredType: true,
|
228
235
|
});
|
229
|
-
if (entry.isRequired) {
|
230
|
-
allEntriesAreNotRequired = false;
|
231
|
-
}
|
232
236
|
if (!entry.isReadOnly) {
|
233
237
|
allEntriesAreReadOnly = false;
|
234
238
|
}
|
235
239
|
});
|
240
|
+
if (entries.extraItems && !(0, types_1.isNever)(entries.extraItems.valueType)) {
|
241
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
242
|
+
category: 2 /* ParameterCategory.KwargsDict */,
|
243
|
+
name: 'kwargs',
|
244
|
+
hasDefault: false,
|
245
|
+
type: entries.extraItems.valueType,
|
246
|
+
hasDeclaredType: true,
|
247
|
+
});
|
248
|
+
types_1.FunctionType.addParameter(initOverride2, {
|
249
|
+
category: 2 /* ParameterCategory.KwargsDict */,
|
250
|
+
name: 'kwargs',
|
251
|
+
hasDefault: false,
|
252
|
+
type: entries.extraItems.valueType,
|
253
|
+
hasDeclaredType: true,
|
254
|
+
});
|
255
|
+
}
|
236
256
|
const symbolTable = classType.details.fields;
|
237
257
|
const initType = types_1.OverloadedFunctionType.create([initOverride1, initOverride2]);
|
238
258
|
symbolTable.set('__init__', symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, initType));
|
@@ -389,7 +409,7 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
389
409
|
updateMethod3.details.declaredReturnType = evaluator.getNoneType();
|
390
410
|
const tuplesToCombine = [];
|
391
411
|
const tupleClass = evaluator.getBuiltInType(node, 'tuple');
|
392
|
-
entries.forEach((entry, name) => {
|
412
|
+
entries.knownItems.forEach((entry, name) => {
|
393
413
|
if (!entry.isReadOnly) {
|
394
414
|
// For writable entries, add a tuple entry.
|
395
415
|
if (tupleClass && (0, types_1.isInstantiableClass)(tupleClass) && strClass && (0, types_1.isInstantiableClass)(strClass)) {
|
@@ -433,7 +453,7 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
433
453
|
const getOverloads = [];
|
434
454
|
const popOverloads = [];
|
435
455
|
const setDefaultOverloads = [];
|
436
|
-
entries.forEach((entry, name) => {
|
456
|
+
entries.knownItems.forEach((entry, name) => {
|
437
457
|
const nameLiteralType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneWithLiteral(strClass, name));
|
438
458
|
getOverloads.push(createGetMethod(nameLiteralType, entry.valueType, /* includeDefault */ false, entry.isRequired));
|
439
459
|
getOverloads.push(createGetMethod(nameLiteralType, entry.valueType,
|
@@ -448,9 +468,9 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
448
468
|
setDefaultOverloads.push(createSetDefaultMethod(nameLiteralType, entry.valueType));
|
449
469
|
}
|
450
470
|
});
|
451
|
-
// If the class is
|
471
|
+
// If the class is closed, we can assume that any other literal
|
452
472
|
// key values will return the default parameter value.
|
453
|
-
if (
|
473
|
+
if (types_1.ClassType.isTypedDictEffectivelyClosed(classType) && (0, types_1.isNever)(extraEntriesInfo.valueType)) {
|
454
474
|
const literalStringType = evaluator.getTypingType(node, 'LiteralString');
|
455
475
|
if (literalStringType && (0, types_1.isInstantiableClass)(literalStringType)) {
|
456
476
|
const literalStringInstance = types_1.ClassType.cloneAsInstance(literalStringType);
|
@@ -476,9 +496,10 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
476
496
|
symbolTable.set('__delitem__', symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, createDelItemMethod(strType)));
|
477
497
|
}
|
478
498
|
symbolTable.set('update', symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, createUpdateMethod()));
|
479
|
-
// If the TypedDict is
|
480
|
-
// add a "clear" and "popitem" method.
|
481
|
-
|
499
|
+
// If the TypedDict is closed and all of its entries are NotRequired and
|
500
|
+
// not ReadOnly, add a "clear" and "popitem" method.
|
501
|
+
const dictValueType = getTypedDictDictEquivalent(evaluator, classType);
|
502
|
+
if (dictValueType) {
|
482
503
|
const clearMethod = types_1.FunctionType.createSynthesizedInstance('clear');
|
483
504
|
types_1.FunctionType.addParameter(clearMethod, selfParam);
|
484
505
|
clearMethod.details.declaredReturnType = evaluator.getNoneType();
|
@@ -489,7 +510,7 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
489
510
|
if (tupleType && (0, types_1.isInstantiableClass)(tupleType)) {
|
490
511
|
tupleType = (0, typeUtils_1.specializeTupleClass)(types_1.ClassType.cloneAsInstance(tupleType), [
|
491
512
|
{ type: strType, isUnbounded: false },
|
492
|
-
{ type:
|
513
|
+
{ type: dictValueType, isUnbounded: false },
|
493
514
|
],
|
494
515
|
/* isTypeArgumentExplicit */ true);
|
495
516
|
}
|
@@ -499,21 +520,50 @@ function synthesizeTypedDictClassMethods(evaluator, node, classType, isClassFina
|
|
499
520
|
popItemMethod.details.declaredReturnType = tupleType;
|
500
521
|
symbolTable.set('popitem', symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, popItemMethod));
|
501
522
|
}
|
523
|
+
// If the TypedDict is closed, we can provide a more accurate value type
|
524
|
+
// for the "items", "keys" and "values" methods.
|
525
|
+
const mappingValueType = getTypedDictMappingEquivalent(evaluator, classType);
|
526
|
+
if (mappingValueType) {
|
527
|
+
['items', 'keys', 'values'].forEach((methodName) => {
|
528
|
+
const method = types_1.FunctionType.createSynthesizedInstance(methodName);
|
529
|
+
types_1.FunctionType.addParameter(method, selfParam);
|
530
|
+
const returnTypeClass = evaluator.getTypingType(node, `dict_${methodName}`);
|
531
|
+
if (returnTypeClass &&
|
532
|
+
(0, types_1.isInstantiableClass)(returnTypeClass) &&
|
533
|
+
returnTypeClass.details.typeParameters.length === 2) {
|
534
|
+
method.details.declaredReturnType = types_1.ClassType.cloneForSpecialization(types_1.ClassType.cloneAsInstance(returnTypeClass), [strType, mappingValueType],
|
535
|
+
/* isTypeArgumentExplicit */ true);
|
536
|
+
symbolTable.set(methodName, symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, method));
|
537
|
+
}
|
538
|
+
});
|
539
|
+
}
|
502
540
|
}
|
503
541
|
}
|
504
542
|
exports.synthesizeTypedDictClassMethods = synthesizeTypedDictClassMethods;
|
505
543
|
function getTypedDictMembersForClass(evaluator, classType, allowNarrowed = false) {
|
544
|
+
var _a;
|
506
545
|
// Were the entries already calculated and cached?
|
507
546
|
if (!classType.details.typedDictEntries) {
|
508
|
-
const entries =
|
547
|
+
const entries = {
|
548
|
+
knownItems: new Map(),
|
549
|
+
extraItems: undefined,
|
550
|
+
};
|
509
551
|
getTypedDictMembersForClassRecursive(evaluator, classType, entries);
|
552
|
+
if (types_1.ClassType.isTypedDictMarkedClosed(classType) && !entries.extraItems) {
|
553
|
+
entries.extraItems = {
|
554
|
+
valueType: types_1.NeverType.createNever(),
|
555
|
+
isReadOnly: false,
|
556
|
+
isRequired: false,
|
557
|
+
isProvided: false,
|
558
|
+
};
|
559
|
+
}
|
510
560
|
// Cache the entries for next time.
|
511
561
|
classType.details.typedDictEntries = entries;
|
512
562
|
}
|
513
563
|
const typeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(classType);
|
514
564
|
// Create a specialized copy of the entries so the caller can mutate them.
|
515
565
|
const entries = new Map();
|
516
|
-
classType.details.typedDictEntries.forEach((value, key) => {
|
566
|
+
classType.details.typedDictEntries.knownItems.forEach((value, key) => {
|
517
567
|
const tdEntry = { ...value };
|
518
568
|
tdEntry.valueType = (0, typeUtils_1.applySolvedTypeVars)(tdEntry.valueType, typeVarContext);
|
519
569
|
// If the class is "Partial", make all entries optional and convert all
|
@@ -537,9 +587,72 @@ function getTypedDictMembersForClass(evaluator, classType, allowNarrowed = false
|
|
537
587
|
entries.set(key, tdEntry);
|
538
588
|
});
|
539
589
|
}
|
540
|
-
return
|
590
|
+
return {
|
591
|
+
knownItems: entries,
|
592
|
+
extraItems: (_a = classType.details.typedDictEntries) === null || _a === void 0 ? void 0 : _a.extraItems,
|
593
|
+
};
|
541
594
|
}
|
542
595
|
exports.getTypedDictMembersForClass = getTypedDictMembersForClass;
|
596
|
+
// If the TypedDict class is consistent with Mapping[str, T] where T
|
597
|
+
// is some type other than object, it returns T. Otherwise it returns undefined.
|
598
|
+
function getTypedDictMappingEquivalent(evaluator, classType) {
|
599
|
+
(0, debug_1.assert)((0, types_1.isInstantiableClass)(classType));
|
600
|
+
(0, debug_1.assert)(types_1.ClassType.isTypedDictClass(classType));
|
601
|
+
// If the TypedDict class isn't closed, it's just a normal Mapping[str, object].
|
602
|
+
if (!types_1.ClassType.isTypedDictEffectivelyClosed(classType)) {
|
603
|
+
return undefined;
|
604
|
+
}
|
605
|
+
const entries = getTypedDictMembersForClass(evaluator, classType);
|
606
|
+
const typesToCombine = [];
|
607
|
+
entries.knownItems.forEach((entry) => {
|
608
|
+
typesToCombine.push(entry.valueType);
|
609
|
+
});
|
610
|
+
if (entries.extraItems) {
|
611
|
+
typesToCombine.push(entries.extraItems.valueType);
|
612
|
+
}
|
613
|
+
// Is the final value type 'object'?
|
614
|
+
const valueType = (0, types_1.combineTypes)(typesToCombine);
|
615
|
+
if ((0, types_1.isClassInstance)(valueType) && types_1.ClassType.isBuiltIn(valueType, 'object')) {
|
616
|
+
return undefined;
|
617
|
+
}
|
618
|
+
return valueType;
|
619
|
+
}
|
620
|
+
exports.getTypedDictMappingEquivalent = getTypedDictMappingEquivalent;
|
621
|
+
// If the TypedDict class is consistent with dict[str, T], it returns T.
|
622
|
+
// Otherwise it returns undefined.
|
623
|
+
function getTypedDictDictEquivalent(evaluator, classType, recursionCount = 0) {
|
624
|
+
(0, debug_1.assert)((0, types_1.isInstantiableClass)(classType));
|
625
|
+
(0, debug_1.assert)(types_1.ClassType.isTypedDictClass(classType));
|
626
|
+
// If the TypedDict class isn't closed, it's not equivalent to a dict.
|
627
|
+
if (!types_1.ClassType.isTypedDictEffectivelyClosed(classType)) {
|
628
|
+
return undefined;
|
629
|
+
}
|
630
|
+
const entries = getTypedDictMembersForClass(evaluator, classType);
|
631
|
+
// If there is no "extraItems" defined or it is read-only, it's not
|
632
|
+
// equivalent to a dict.
|
633
|
+
if (!entries.extraItems || entries.extraItems.isReadOnly) {
|
634
|
+
return undefined;
|
635
|
+
}
|
636
|
+
let dictValueType = entries.extraItems.valueType;
|
637
|
+
let isEquivalentToDict = true;
|
638
|
+
entries.knownItems.forEach((entry) => {
|
639
|
+
if (entry.isReadOnly || entry.isRequired) {
|
640
|
+
isEquivalentToDict = false;
|
641
|
+
}
|
642
|
+
dictValueType = (0, types_1.combineTypes)([dictValueType, entry.valueType]);
|
643
|
+
if (!evaluator.assignType(dictValueType, entry.valueType,
|
644
|
+
/* diag */ undefined,
|
645
|
+
/* destTypeVarContext */ undefined,
|
646
|
+
/* srcTypeVarContext */ undefined, 1 /* AssignTypeFlags.EnforceInvariance */, recursionCount + 1)) {
|
647
|
+
isEquivalentToDict = false;
|
648
|
+
}
|
649
|
+
});
|
650
|
+
if (!isEquivalentToDict) {
|
651
|
+
return undefined;
|
652
|
+
}
|
653
|
+
return dictValueType;
|
654
|
+
}
|
655
|
+
exports.getTypedDictDictEquivalent = getTypedDictDictEquivalent;
|
543
656
|
function getTypedDictFieldsFromDictSyntax(evaluator, entryDict, classFields, isInline) {
|
544
657
|
const entrySet = new Set();
|
545
658
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(entryDict);
|
@@ -581,7 +694,7 @@ function getTypedDictFieldsFromDictSyntax(evaluator, entryDict, classFields, isI
|
|
581
694
|
// get evaluated again.
|
582
695
|
evaluator.setTypeResultForNode(entryDict, { type: types_1.UnknownType.create() });
|
583
696
|
}
|
584
|
-
function getTypedDictMembersForClassRecursive(evaluator, classType,
|
697
|
+
function getTypedDictMembersForClassRecursive(evaluator, classType, entries, recursionCount = 0) {
|
585
698
|
(0, debug_1.assert)(types_1.ClassType.isTypedDictClass(classType));
|
586
699
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
587
700
|
return;
|
@@ -593,7 +706,7 @@ function getTypedDictMembersForClassRecursive(evaluator, classType, keyMap, recu
|
|
593
706
|
(0, debug_1.assert)((0, types_1.isClass)(specializedBaseClassType));
|
594
707
|
// Recursively gather keys from parent classes. Don't report any errors
|
595
708
|
// in these cases because they will be reported within that class.
|
596
|
-
getTypedDictMembersForClassRecursive(evaluator, specializedBaseClassType,
|
709
|
+
getTypedDictMembersForClassRecursive(evaluator, specializedBaseClassType, entries, recursionCount);
|
597
710
|
}
|
598
711
|
});
|
599
712
|
const typeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(classType);
|
@@ -605,48 +718,79 @@ function getTypedDictMembersForClassRecursive(evaluator, classType, keyMap, recu
|
|
605
718
|
if (lastDecl && lastDecl.type === 1 /* DeclarationType.Variable */) {
|
606
719
|
let valueType = evaluator.getEffectiveTypeOfSymbol(symbol);
|
607
720
|
valueType = (0, typeUtils_1.applySolvedTypeVars)(valueType, typeVarContext);
|
721
|
+
const allowRequired = !types_1.ClassType.isTypedDictMarkedClosed(classType) || name !== '__extra_items__';
|
608
722
|
let isRequired = !types_1.ClassType.isCanOmitDictValues(classType);
|
609
723
|
let isReadOnly = false;
|
610
|
-
if (isRequiredTypedDictVariable(evaluator, symbol)) {
|
724
|
+
if (isRequiredTypedDictVariable(evaluator, symbol, allowRequired)) {
|
611
725
|
isRequired = true;
|
612
726
|
}
|
613
|
-
else if (isNotRequiredTypedDictVariable(evaluator, symbol)) {
|
727
|
+
else if (isNotRequiredTypedDictVariable(evaluator, symbol, allowRequired)) {
|
614
728
|
isRequired = false;
|
615
729
|
}
|
616
730
|
if (isReadOnlyTypedDictVariable(evaluator, symbol)) {
|
617
731
|
isReadOnly = true;
|
618
732
|
}
|
619
|
-
|
733
|
+
const tdEntry = {
|
620
734
|
valueType,
|
621
735
|
isReadOnly,
|
622
736
|
isRequired,
|
623
737
|
isProvided: false,
|
624
|
-
}
|
738
|
+
};
|
739
|
+
if (types_1.ClassType.isTypedDictMarkedClosed(classType) && name === '__extra_items__') {
|
740
|
+
tdEntry.isRequired = false;
|
741
|
+
entries.extraItems = tdEntry;
|
742
|
+
}
|
743
|
+
else {
|
744
|
+
entries.knownItems.set(name, tdEntry);
|
745
|
+
}
|
625
746
|
}
|
626
747
|
}
|
627
748
|
});
|
628
749
|
}
|
750
|
+
function getEffectiveExtraItemsEntryType(evaluator, classType) {
|
751
|
+
var _a;
|
752
|
+
(0, debug_1.assert)(types_1.ClassType.isTypedDictClass(classType));
|
753
|
+
// Missing entries in a non-closed TypedDict class are implicitly typed as
|
754
|
+
// ReadOnly[NotRequired[object]].
|
755
|
+
if (!types_1.ClassType.isTypedDictMarkedClosed(classType)) {
|
756
|
+
return {
|
757
|
+
valueType: evaluator.getObjectType(),
|
758
|
+
isReadOnly: true,
|
759
|
+
isRequired: false,
|
760
|
+
isProvided: false,
|
761
|
+
};
|
762
|
+
}
|
763
|
+
if ((_a = classType.details.typedDictEntries) === null || _a === void 0 ? void 0 : _a.extraItems) {
|
764
|
+
return classType.details.typedDictEntries.extraItems;
|
765
|
+
}
|
766
|
+
return {
|
767
|
+
valueType: types_1.NeverType.createNever(),
|
768
|
+
isReadOnly: true,
|
769
|
+
isRequired: false,
|
770
|
+
isProvided: false,
|
771
|
+
};
|
772
|
+
}
|
773
|
+
exports.getEffectiveExtraItemsEntryType = getEffectiveExtraItemsEntryType;
|
629
774
|
function assignTypedDictToTypedDict(evaluator, destType, srcType, diag, typeVarContext, flags, recursionCount = 0) {
|
775
|
+
var _a, _b;
|
630
776
|
let typesAreConsistent = true;
|
631
777
|
const destEntries = getTypedDictMembersForClass(evaluator, destType);
|
632
778
|
const srcEntries = getTypedDictMembersForClass(evaluator, srcType, /* allowNarrowed */ true);
|
633
|
-
|
634
|
-
|
779
|
+
const extraSrcEntries = (_a = srcEntries.extraItems) !== null && _a !== void 0 ? _a : getEffectiveExtraItemsEntryType(evaluator, srcType);
|
780
|
+
destEntries.knownItems.forEach((destEntry, name) => {
|
781
|
+
const srcEntry = srcEntries.knownItems.get(name);
|
635
782
|
if (!srcEntry) {
|
636
783
|
if (destEntry.isRequired || !destEntry.isReadOnly) {
|
637
784
|
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.typedDictFieldMissing().format({
|
638
785
|
name,
|
639
|
-
type: evaluator.printType(srcType),
|
786
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(srcType)),
|
640
787
|
}));
|
641
788
|
typesAreConsistent = false;
|
642
789
|
}
|
643
790
|
else {
|
644
|
-
|
645
|
-
// so we need to make sure the dest entry is compatible with that.
|
646
|
-
const objType = evaluator.getObjectType();
|
647
|
-
if ((0, types_1.isClassInstance)(objType)) {
|
791
|
+
if ((0, types_1.isClassInstance)(extraSrcEntries.valueType)) {
|
648
792
|
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
649
|
-
if (!evaluator.assignType(destEntry.valueType,
|
793
|
+
if (!evaluator.assignType(destEntry.valueType, extraSrcEntries.valueType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), typeVarContext,
|
650
794
|
/* srcTypeVarContext */ undefined, flags, recursionCount)) {
|
651
795
|
subDiag === null || subDiag === void 0 ? void 0 : subDiag.addMessage(localize_1.LocAddendum.memberTypeMismatch().format({ name }));
|
652
796
|
typesAreConsistent = false;
|
@@ -661,30 +805,85 @@ function assignTypedDictToTypedDict(evaluator, destType, srcType, diag, typeVarC
|
|
661
805
|
: localize_1.LocAddendum.typedDictFieldNotRequired();
|
662
806
|
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(message.format({
|
663
807
|
name,
|
664
|
-
type: evaluator.printType(destType),
|
808
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
665
809
|
}));
|
666
810
|
typesAreConsistent = false;
|
667
811
|
}
|
668
812
|
if (!destEntry.isReadOnly && srcEntry.isReadOnly) {
|
669
813
|
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.typedDictFieldNotReadOnly().format({
|
670
814
|
name,
|
671
|
-
type: evaluator.printType(destType),
|
815
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
672
816
|
}));
|
673
817
|
typesAreConsistent = false;
|
674
818
|
}
|
675
819
|
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
676
|
-
let adjustedFlags = flags;
|
677
|
-
// If the dest field is not read-only, we need to enforce invariance.
|
678
|
-
if (!destEntry.isReadOnly) {
|
679
|
-
adjustedFlags |= 1 /* AssignTypeFlags.EnforceInvariance */;
|
680
|
-
}
|
681
820
|
if (!evaluator.assignType(destEntry.valueType, srcEntry.valueType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), typeVarContext,
|
682
|
-
/* srcTypeVarContext */ undefined,
|
821
|
+
/* srcTypeVarContext */ undefined, destEntry.isReadOnly ? flags : flags | 1 /* AssignTypeFlags.EnforceInvariance */, recursionCount)) {
|
683
822
|
subDiag === null || subDiag === void 0 ? void 0 : subDiag.addMessage(localize_1.LocAddendum.memberTypeMismatch().format({ name }));
|
684
823
|
typesAreConsistent = false;
|
685
824
|
}
|
686
825
|
}
|
687
826
|
});
|
827
|
+
// If the destination TypedDict is closed, check any extra entries in the source
|
828
|
+
// TypedDict to ensure that they don't violate the "extra items" type.
|
829
|
+
if (types_1.ClassType.isTypedDictEffectivelyClosed(destType)) {
|
830
|
+
const extraDestEntries = (_b = destEntries.extraItems) !== null && _b !== void 0 ? _b : getEffectiveExtraItemsEntryType(evaluator, destType);
|
831
|
+
srcEntries.knownItems.forEach((srcEntry, name) => {
|
832
|
+
// Have we already checked this item in the loop above?
|
833
|
+
if (destEntries.knownItems.has(name)) {
|
834
|
+
return;
|
835
|
+
}
|
836
|
+
if (!destEntries.extraItems) {
|
837
|
+
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
838
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.addMessage(localize_1.LocAddendum.typedDictExtraFieldNotAllowed().format({
|
839
|
+
name,
|
840
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
841
|
+
}));
|
842
|
+
typesAreConsistent = false;
|
843
|
+
}
|
844
|
+
else {
|
845
|
+
if (srcEntry.isRequired && !destEntries.extraItems.isReadOnly) {
|
846
|
+
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.typedDictFieldNotRequired().format({
|
847
|
+
name,
|
848
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
849
|
+
}));
|
850
|
+
typesAreConsistent = false;
|
851
|
+
}
|
852
|
+
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
853
|
+
if (!evaluator.assignType(destEntries.extraItems.valueType, srcEntry.valueType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), typeVarContext,
|
854
|
+
/* srcTypeVarContext */ undefined, destEntries.extraItems.isReadOnly ? flags : flags | 1 /* AssignTypeFlags.EnforceInvariance */, recursionCount)) {
|
855
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.addMessage(localize_1.LocAddendum.typedDictExtraFieldTypeMismatch().format({
|
856
|
+
name,
|
857
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
858
|
+
}));
|
859
|
+
typesAreConsistent = false;
|
860
|
+
}
|
861
|
+
else if (!destEntries.extraItems.isReadOnly && srcEntry.isReadOnly) {
|
862
|
+
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.typedDictFieldNotReadOnly().format({
|
863
|
+
name,
|
864
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(srcType)),
|
865
|
+
}));
|
866
|
+
typesAreConsistent = false;
|
867
|
+
}
|
868
|
+
}
|
869
|
+
});
|
870
|
+
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
871
|
+
if (!evaluator.assignType(extraDestEntries.valueType, extraSrcEntries.valueType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), typeVarContext,
|
872
|
+
/* srcTypeVarContext */ undefined, extraDestEntries.isReadOnly ? flags : flags | 1 /* AssignTypeFlags.EnforceInvariance */, recursionCount)) {
|
873
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.addMessage(localize_1.LocAddendum.typedDictExtraFieldTypeMismatch().format({
|
874
|
+
name: '__extra_items__',
|
875
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(srcType)),
|
876
|
+
}));
|
877
|
+
typesAreConsistent = false;
|
878
|
+
}
|
879
|
+
else if (!extraDestEntries.isReadOnly && extraSrcEntries.isReadOnly) {
|
880
|
+
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.typedDictFieldNotReadOnly().format({
|
881
|
+
name: '__extra_items__',
|
882
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(destType)),
|
883
|
+
}));
|
884
|
+
typesAreConsistent = false;
|
885
|
+
}
|
886
|
+
}
|
688
887
|
return typesAreConsistent;
|
689
888
|
}
|
690
889
|
exports.assignTypedDictToTypedDict = assignTypedDictToTypedDict;
|
@@ -711,7 +910,7 @@ function assignToTypedDict(evaluator, classType, keyTypes, valueTypes, diagAdden
|
|
711
910
|
/* isTypeArgumentExplicit */ false);
|
712
911
|
}
|
713
912
|
}
|
714
|
-
const
|
913
|
+
const tdEntries = getTypedDictMembersForClass(evaluator, genericClassType);
|
715
914
|
keyTypes.forEach((keyTypeResult, index) => {
|
716
915
|
const keyType = keyTypeResult.type;
|
717
916
|
if (!(0, types_1.isClassInstance)(keyType) || !types_1.ClassType.isBuiltIn(keyType, 'str') || !(0, typeUtils_1.isLiteralType)(keyType)) {
|
@@ -719,17 +918,33 @@ function assignToTypedDict(evaluator, classType, keyTypes, valueTypes, diagAdden
|
|
719
918
|
}
|
720
919
|
else {
|
721
920
|
const keyValue = keyType.literalValue;
|
722
|
-
const symbolEntry =
|
921
|
+
const symbolEntry = tdEntries.knownItems.get(keyValue);
|
723
922
|
if (!symbolEntry) {
|
724
|
-
|
725
|
-
isMatch = false;
|
726
|
-
if (diagAddendum) {
|
923
|
+
if (tdEntries.extraItems) {
|
727
924
|
const subDiag = diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum();
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
925
|
+
if (!evaluator.assignType(tdEntries.extraItems.valueType, valueTypes[index].type, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), typeVarContext,
|
926
|
+
/* srcTypeVarContext */ undefined, 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) {
|
927
|
+
if (subDiag) {
|
928
|
+
subDiag.addMessage(localize_1.LocAddendum.typedDictFieldTypeMismatch().format({
|
929
|
+
name: '__extra_items__',
|
930
|
+
type: evaluator.printType(valueTypes[index].type),
|
931
|
+
}));
|
932
|
+
subDiag.addTextRange(keyTypeResult.node);
|
933
|
+
}
|
934
|
+
isMatch = false;
|
935
|
+
}
|
936
|
+
}
|
937
|
+
else {
|
938
|
+
// The provided key name doesn't exist.
|
939
|
+
isMatch = false;
|
940
|
+
if (diagAddendum) {
|
941
|
+
const subDiag = diagAddendum === null || diagAddendum === void 0 ? void 0 : diagAddendum.createAddendum();
|
942
|
+
subDiag.addMessage(localize_1.LocAddendum.typedDictFieldUndefined().format({
|
943
|
+
name: keyType.literalValue,
|
944
|
+
type: evaluator.printType(types_1.ClassType.cloneAsInstance(classType)),
|
945
|
+
}));
|
946
|
+
subDiag.addTextRange(keyTypeResult.node);
|
947
|
+
}
|
733
948
|
}
|
734
949
|
}
|
735
950
|
else {
|
@@ -762,7 +977,7 @@ function assignToTypedDict(evaluator, classType, keyTypes, valueTypes, diagAdden
|
|
762
977
|
return undefined;
|
763
978
|
}
|
764
979
|
// See if any required keys are missing.
|
765
|
-
|
980
|
+
tdEntries.knownItems.forEach((entry, name) => {
|
766
981
|
if (entry.isRequired && !entry.isProvided) {
|
767
982
|
if (diagAddendum) {
|
768
983
|
diagAddendum.addMessage(localize_1.LocAddendum.typedDictFieldRequired().format({
|
@@ -799,7 +1014,7 @@ function getTypeOfIndexedTypedDict(evaluator, node, baseType, usage) {
|
|
799
1014
|
let diag = new diagnostic_1.DiagnosticAddendum();
|
800
1015
|
let allDiagsInvolveNotRequiredKeys = true;
|
801
1016
|
const resultingType = (0, typeUtils_1.mapSubtypes)(indexType, (subtype) => {
|
802
|
-
var _a, _b;
|
1017
|
+
var _a, _b, _c;
|
803
1018
|
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
804
1019
|
return subtype;
|
805
1020
|
}
|
@@ -811,7 +1026,7 @@ function getTypeOfIndexedTypedDict(evaluator, node, baseType, usage) {
|
|
811
1026
|
}
|
812
1027
|
// Look up the entry in the typed dict to get its type.
|
813
1028
|
const entryName = subtype.literalValue;
|
814
|
-
const entry = entries.get(entryName);
|
1029
|
+
const entry = (_a = entries.knownItems.get(entryName)) !== null && _a !== void 0 ? _a : entries.extraItems;
|
815
1030
|
if (!entry) {
|
816
1031
|
diag.addMessage(localize_1.LocAddendum.keyUndefined().format({
|
817
1032
|
name: entryName,
|
@@ -835,7 +1050,7 @@ function getTypeOfIndexedTypedDict(evaluator, node, baseType, usage) {
|
|
835
1050
|
}));
|
836
1051
|
}
|
837
1052
|
if (usage.method === 'set') {
|
838
|
-
if (!evaluator.assignType(entry.valueType, (
|
1053
|
+
if (!evaluator.assignType(entry.valueType, (_c = (_b = usage.setType) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : types_1.AnyType.create(), diag)) {
|
839
1054
|
allDiagsInvolveNotRequiredKeys = false;
|
840
1055
|
}
|
841
1056
|
}
|
@@ -885,7 +1100,7 @@ function narrowForKeyAssignment(classType, key) {
|
|
885
1100
|
if (!types_1.ClassType.isTypedDictClass(classType) || !classType.details.typedDictEntries) {
|
886
1101
|
return classType;
|
887
1102
|
}
|
888
|
-
const tdEntry = classType.details.typedDictEntries.get(key);
|
1103
|
+
const tdEntry = classType.details.typedDictEntries.knownItems.get(key);
|
889
1104
|
if (!tdEntry || tdEntry.isRequired) {
|
890
1105
|
return classType;
|
891
1106
|
}
|
@@ -905,7 +1120,7 @@ function narrowForKeyAssignment(classType, key) {
|
|
905
1120
|
return types_1.ClassType.cloneForNarrowedTypedDictEntries(classType, narrowedEntries);
|
906
1121
|
}
|
907
1122
|
exports.narrowForKeyAssignment = narrowForKeyAssignment;
|
908
|
-
function isRequiredTypedDictVariable(evaluator, symbol) {
|
1123
|
+
function isRequiredTypedDictVariable(evaluator, symbol, allowRequired) {
|
909
1124
|
return symbol.getDeclarations().some((decl) => {
|
910
1125
|
if (decl.type !== 1 /* DeclarationType.Variable */ || !decl.typeAnnotationNode) {
|
911
1126
|
return false;
|
@@ -914,10 +1129,16 @@ function isRequiredTypedDictVariable(evaluator, symbol) {
|
|
914
1129
|
allowFinal: true,
|
915
1130
|
allowRequired: true,
|
916
1131
|
});
|
1132
|
+
if (!allowRequired) {
|
1133
|
+
if (annotatedType.isRequired) {
|
1134
|
+
evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.requiredNotInTypedDict(), decl.typeAnnotationNode);
|
1135
|
+
}
|
1136
|
+
return false;
|
1137
|
+
}
|
917
1138
|
return !!annotatedType.isRequired;
|
918
1139
|
});
|
919
1140
|
}
|
920
|
-
function isNotRequiredTypedDictVariable(evaluator, symbol) {
|
1141
|
+
function isNotRequiredTypedDictVariable(evaluator, symbol, allowRequired) {
|
921
1142
|
return symbol.getDeclarations().some((decl) => {
|
922
1143
|
if (decl.type !== 1 /* DeclarationType.Variable */ || !decl.typeAnnotationNode) {
|
923
1144
|
return false;
|
@@ -926,6 +1147,12 @@ function isNotRequiredTypedDictVariable(evaluator, symbol) {
|
|
926
1147
|
allowFinal: true,
|
927
1148
|
allowRequired: true,
|
928
1149
|
});
|
1150
|
+
if (!allowRequired) {
|
1151
|
+
if (annotatedType.isNotRequired) {
|
1152
|
+
evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.notRequiredNotInTypedDict(), decl.typeAnnotationNode);
|
1153
|
+
}
|
1154
|
+
return false;
|
1155
|
+
}
|
929
1156
|
return !!annotatedType.isNotRequired;
|
930
1157
|
});
|
931
1158
|
}
|