@zzzen/pyright-internal 1.2.0-dev.20260809 → 1.2.0-dev.20260823
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/analyzerNodeInfo.d.ts +119 -24
- package/dist/analyzer/analyzerNodeInfo.js +408 -89
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.d.ts +6 -3
- package/dist/analyzer/binder.js +157 -70
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +5 -2
- package/dist/analyzer/checker.js +92 -34
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -1
- package/dist/analyzer/codeFlowEngine.js +12 -10
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.d.ts +2 -1
- package/dist/analyzer/codeFlowUtils.js +2 -3
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +47 -7
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +18 -8
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +6 -4
- package/dist/analyzer/dataClasses.js +119 -75
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +2 -1
- package/dist/analyzer/declarationUtils.js +2 -2
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.d.ts +5 -4
- package/dist/analyzer/decorators.js +38 -21
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.d.ts +5 -4
- package/dist/analyzer/enums.js +11 -10
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +5 -3
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +3 -1
- package/dist/analyzer/importStatementUtils.js +14 -7
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.d.ts +2 -1
- package/dist/analyzer/namedTuples.js +3 -4
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +3 -2
- package/dist/analyzer/operations.js +8 -8
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +2 -2
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +13 -11
- package/dist/analyzer/parseTreeUtils.js +62 -36
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.d.ts +7 -2
- package/dist/analyzer/parseTreeWalker.js +29 -175
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +4 -3
- package/dist/analyzer/patternMatching.js +47 -43
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +12 -0
- package/dist/analyzer/program.js +235 -29
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.d.ts +4 -3
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -2
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.d.ts +3 -0
- package/dist/analyzer/scope.js +10 -0
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.d.ts +4 -3
- package/dist/analyzer/scopeUtils.js +8 -8
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/sentinel.d.ts +2 -1
- package/dist/analyzer/sentinel.js +2 -3
- package/dist/analyzer/sentinel.js.map +1 -1
- package/dist/analyzer/service.js +28 -10
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceEnumerator.d.ts +5 -0
- package/dist/analyzer/sourceEnumerator.js +57 -3
- package/dist/analyzer/sourceEnumerator.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +12 -6
- package/dist/analyzer/sourceFile.js +73 -50
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
- package/dist/analyzer/sourceFileInfoUtils.js +8 -0
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +4 -1
- package/dist/analyzer/sourceMapper.js +14 -8
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +4 -1
- package/dist/analyzer/symbol.js +8 -0
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/testWalker.js +2 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +2 -1
- package/dist/analyzer/tracePrinter.js +2 -2
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +3 -2
- package/dist/analyzer/tuples.js +5 -5
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.d.ts +6 -2
- package/dist/analyzer/typeCacheUtils.js +16 -37
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +5 -7
- package/dist/analyzer/typeDocStringUtils.js +229 -132
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +2 -0
- package/dist/analyzer/typeEvaluator.js +1280 -302
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +2 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +3 -2
- package/dist/analyzer/typeGuards.js +37 -33
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +12 -9
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +3 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +4 -3
- package/dist/analyzer/typedDicts.js +15 -14
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +11 -1
- package/dist/analyzer/types.js +48 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/collectionUtils.js +15 -6
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -0
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +4 -1
- package/dist/common/configOptions.js +68 -12
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +1 -0
- package/dist/common/envVarUtils.js +41 -10
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +3 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/extraPathGlob.d.ts +12 -0
- package/dist/common/extraPathGlob.js +315 -0
- package/dist/common/extraPathGlob.js.map +1 -0
- package/dist/common/host.d.ts +2 -0
- package/dist/common/host.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +2 -1
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/pathConsts.d.ts +1 -0
- package/dist/common/pathConsts.js +11 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/common/processUtils.d.ts +4 -2
- package/dist/common/processUtils.js +3 -0
- package/dist/common/processUtils.js.map +1 -1
- package/dist/common/stringUtils.d.ts +6 -0
- package/dist/common/stringUtils.js +87 -5
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.d.ts +3 -1
- package/dist/common/textEditTracker.js +8 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRangeCollection.d.ts +1 -0
- package/dist/common/textRangeCollection.js +32 -1
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +3 -0
- package/dist/common/uri/uriUtils.js +65 -15
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/fileSystemMapping.d.ts +10 -0
- package/dist/fileSystemMapping.js +176 -0
- package/dist/fileSystemMapping.js.map +1 -0
- package/dist/languageService/analyzerServiceExecutor.js +2 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +1 -0
- package/dist/languageService/autoImporter.js +32 -5
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +7 -0
- package/dist/languageService/callHierarchyProvider.js +97 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +30 -8
- package/dist/languageService/completionProvider.js +298 -93
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.js +7 -6
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +2 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +3 -1
- package/dist/languageService/documentSymbolCollector.js +78 -14
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +3 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +28 -1
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +2 -1
- package/dist/languageService/hoverProvider.js +48 -16
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.d.ts +3 -1
- package/dist/languageService/importSorter.js +4 -2
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/importStatementCandidates.js +4 -2
- package/dist/languageService/importStatementCandidates.js.map +1 -1
- package/dist/languageService/quickActions.js +2 -1
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js +12 -5
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +3 -0
- package/dist/languageService/signatureHelpProvider.js +56 -18
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +2 -1
- package/dist/languageService/symbolIndexer.js +7 -7
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +1 -1
- package/dist/languageService/tooltipUtils.js +103 -35
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +3 -2
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +12 -0
- package/dist/localization/localize.js +14 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +11 -0
- package/dist/localization/package.nls.de.json +11 -0
- package/dist/localization/package.nls.en-us.json +18 -0
- package/dist/localization/package.nls.es.json +11 -0
- package/dist/localization/package.nls.fr.json +11 -0
- package/dist/localization/package.nls.it.json +11 -0
- package/dist/localization/package.nls.ja.json +11 -0
- package/dist/localization/package.nls.ko.json +11 -0
- package/dist/localization/package.nls.pl.json +11 -0
- package/dist/localization/package.nls.pt-br.json +11 -0
- package/dist/localization/package.nls.qps-ploc.json +11 -0
- package/dist/localization/package.nls.ru.json +11 -0
- package/dist/localization/package.nls.tr.json +11 -0
- package/dist/localization/package.nls.zh-cn.json +12 -1
- package/dist/localization/package.nls.zh-tw.json +13 -2
- package/dist/parser/parseNodes.d.ts +85 -80
- package/dist/parser/parseNodes.js +182 -159
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parseTreeUtils.d.ts +3 -0
- package/dist/parser/parseTreeUtils.js +209 -0
- package/dist/parser/parseTreeUtils.js.map +1 -0
- package/dist/parser/parser.d.ts +16 -6
- package/dist/parser/parser.js +210 -144
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringAnnotationInfo.d.ts +16 -0
- package/dist/parser/stringAnnotationInfo.js +26 -0
- package/dist/parser/stringAnnotationInfo.js.map +1 -0
- package/dist/readonlyAugmentedFileSystem.d.ts +2 -9
- package/dist/readonlyAugmentedFileSystem.js +17 -144
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tests/analyzerNodeInfo.test.d.ts +1 -0
- package/dist/tests/analyzerNodeInfo.test.js +113 -0
- package/dist/tests/analyzerNodeInfo.test.js.map +1 -0
- package/dist/tests/collectionUtils.test.js +46 -0
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/completions.test.js +34 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +131 -6
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/extraPathGlob.test.d.ts +1 -0
- package/dist/tests/extraPathGlob.test.js +434 -0
- package/dist/tests/extraPathGlob.test.js.map +1 -0
- package/dist/tests/fileSystemMapping.test.d.ts +1 -0
- package/dist/tests/fileSystemMapping.test.js +458 -0
- package/dist/tests/fileSystemMapping.test.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js +14 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js +7 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js +41 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +2 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +5 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js +4 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js +48 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +8 -2
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +5 -2
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js +2 -2
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +1 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/hoverProvider.test.js +38 -0
- package/dist/tests/hoverProvider.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +6 -3
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +38 -0
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +88 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +60 -3
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js +23 -0
- package/dist/tests/positionUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +41 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/service.test.js +77 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceEnumeratorSymlink.test.d.ts +1 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js +203 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js.map +1 -0
- package/dist/tests/stringUtils.test.js +84 -0
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symlinkAliasInvalidation.test.d.ts +1 -0
- package/dist/tests/symlinkAliasInvalidation.test.js +471 -0
- package/dist/tests/symlinkAliasInvalidation.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +2 -0
- package/dist/tests/testUtils.js +7 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/textRangeCollection.test.d.ts +1 -0
- package/dist/tests/textRangeCollection.test.js +137 -0
- package/dist/tests/textRangeCollection.test.js.map +1 -0
- package/dist/tests/typeCacheUtils.test.d.ts +1 -0
- package/dist/tests/typeCacheUtils.test.js +69 -0
- package/dist/tests/typeCacheUtils.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.js +24 -3
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +8 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +12 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +33 -1
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +29 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +318 -4
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/typeServer/typeCache.test.d.ts +1 -0
- package/dist/tests/typeServer/typeCache.test.js +69 -0
- package/dist/tests/typeServer/typeCache.test.js.map +1 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js +18 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js.map +1 -1
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/{analyzer/parseTreeCleaner.js → tests/types.test.js} +23 -25
- package/dist/tests/types.test.js.map +1 -0
- package/dist/tests/uri.test.js +51 -0
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/typeServer/notebookDocumentHandler.d.ts +9 -2
- package/dist/typeServer/notebookDocumentHandler.js +16 -6
- package/dist/typeServer/notebookDocumentHandler.js.map +1 -1
- package/dist/typeServer/programWrapper.d.ts +1 -0
- package/dist/typeServer/programWrapper.js +28 -15
- package/dist/typeServer/programWrapper.js.map +1 -1
- package/dist/typeServer/protocol/tspSupplemental.d.ts +1 -1
- package/dist/typeServer/protocol/tspSupplemental.js +2 -2
- package/dist/typeServer/server.d.ts +13 -2
- package/dist/typeServer/server.js +36 -23
- package/dist/typeServer/server.js.map +1 -1
- package/dist/typeServer/typeCache.d.ts +8 -4
- package/dist/typeServer/typeCache.js +33 -5
- package/dist/typeServer/typeCache.js.map +1 -1
- package/dist/typeServer/typeEvalUtils.d.ts +2 -1
- package/dist/typeServer/typeEvalUtils.js +7 -3
- package/dist/typeServer/typeEvalUtils.js.map +1 -1
- package/dist/typeServer/typeServerFileSystem.d.ts +10 -9
- package/dist/typeServer/typeServerFileSystem.js +16 -12
- package/dist/typeServer/typeServerFileSystem.js.map +1 -1
- package/package.json +7 -5
- package/dist/analyzer/parseTreeCleaner.d.ts +0 -8
- package/dist/analyzer/parseTreeCleaner.js.map +0 -1
|
@@ -5,6 +5,7 @@ import { DiagnosticRule } from '../common/diagnosticRules';
|
|
|
5
5
|
import { TextRange } from '../common/textRange';
|
|
6
6
|
import { ArgCategory, ArgumentNode, CallNode, CaseNode, ClassNode, DecoratorNode, ExpressionNode, FunctionNode, MatchNode, NameNode, ParamCategory, ParameterNode, ParseNode, StringNode } from '../parser/parseNodes';
|
|
7
7
|
import { AnalyzerFileInfo } from './analyzerFileInfo';
|
|
8
|
+
import { AnalyzerNodeInfoReader } from './analyzerNodeInfo';
|
|
8
9
|
import { CodeFlowReferenceExpressionNode, FlowNode } from './codeFlowTypes';
|
|
9
10
|
import { ConstraintTracker } from './constraintTracker';
|
|
10
11
|
import { Declaration } from './declaration';
|
|
@@ -308,6 +309,7 @@ export declare const enum AssignTypeFlags {
|
|
|
308
309
|
export interface TypeEvaluator {
|
|
309
310
|
runWithCancellationToken<T>(token: CancellationToken, callback: () => T): T;
|
|
310
311
|
runWithCancellationToken<T>(token: CancellationToken, callback: () => Promise<T>): Promise<T>;
|
|
312
|
+
getAnalyzerNodeInfoReader: () => AnalyzerNodeInfoReader;
|
|
311
313
|
getType: (node: ExpressionNode) => Type | undefined;
|
|
312
314
|
getTypeResult: (node: ExpressionNode) => TypeResult | undefined;
|
|
313
315
|
getTypeResultForDecorator: (node: DecoratorNode) => TypeResult | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeEvaluatorTypes.js","sourceRoot":"","sources":["../../../../../src/analyzer/typeEvaluatorTypes.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;
|
|
1
|
+
{"version":3,"file":"typeEvaluatorTypes.js","sourceRoot":"","sources":["../../../../../src/analyzer/typeEvaluatorTypes.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExpressionNode } from '../parser/parseNodes';
|
|
2
|
+
import { AnalyzerNodeInfoAccessor } from './analyzerNodeInfo';
|
|
2
3
|
import { TypeEvaluator } from './typeEvaluatorTypes';
|
|
3
4
|
import { AnyType, ClassType, FunctionType, OverloadedType, Type, TypeVarType, UnknownType } from './types';
|
|
4
5
|
export interface TypeNarrowingResult {
|
|
@@ -6,9 +7,9 @@ export interface TypeNarrowingResult {
|
|
|
6
7
|
isIncomplete: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type TypeNarrowingCallback = (type: Type) => TypeNarrowingResult | undefined;
|
|
9
|
-
export declare function getTypeNarrowingCallback(evaluator: TypeEvaluator, reference: ExpressionNode, testExpression: ExpressionNode, isPositiveTest: boolean, recursionCount?: number): TypeNarrowingCallback | undefined;
|
|
10
|
+
export declare function getTypeNarrowingCallback(evaluator: TypeEvaluator, reference: ExpressionNode, testExpression: ExpressionNode, isPositiveTest: boolean, nodeInfo: AnalyzerNodeInfoAccessor, recursionCount?: number): TypeNarrowingCallback | undefined;
|
|
10
11
|
export declare function getIsInstanceClassTypes(evaluator: TypeEvaluator, argType: Type): (ClassType | TypeVarType | FunctionType)[] | undefined;
|
|
11
|
-
export declare function narrowTypeForInstanceOrSubclass(evaluator: TypeEvaluator, type: Type, filterTypes: Type[], isInstanceCheck: boolean, isTypeIsCheck: boolean, isPositiveTest: boolean, errorNode: ExpressionNode): import("./types").UnboundType | UnknownType | AnyType | FunctionType | OverloadedType | ClassType | import("./types").ModuleType | TypeVarType | import("./types").NeverType | import("./types").UnionType;
|
|
12
|
+
export declare function narrowTypeForInstanceOrSubclass(evaluator: TypeEvaluator, type: Type, filterTypes: Type[], isInstanceCheck: boolean, isTypeIsCheck: boolean, isPositiveTest: boolean, errorNode: ExpressionNode, nodeInfo: AnalyzerNodeInfoAccessor): import("./types").UnboundType | UnknownType | AnyType | FunctionType | OverloadedType | ClassType | import("./types").ModuleType | TypeVarType | import("./types").NeverType | import("./types").UnionType;
|
|
12
13
|
export declare function getElementTypeForContainerNarrowing(containerType: Type): Type | undefined;
|
|
13
14
|
export declare function narrowTypeForContainerElementType(evaluator: TypeEvaluator, referenceType: Type, elementType: Type): Type;
|
|
14
15
|
export declare function narrowTypeForDiscriminatedDictEntryComparison(evaluator: TypeEvaluator, referenceType: Type, indexLiteralType: ClassType, literalType: Type, isPositiveTest: boolean): Type;
|
|
@@ -68,13 +68,13 @@ const typeUtils_1 = require("./typeUtils");
|
|
|
68
68
|
// can be used to narrow the type described by the reference expression.
|
|
69
69
|
// If the specified flow node is not associated with the test expression,
|
|
70
70
|
// it returns undefined.
|
|
71
|
-
function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositiveTest, recursionCount = 0) {
|
|
71
|
+
function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositiveTest, nodeInfo, recursionCount = 0) {
|
|
72
72
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
|
73
73
|
return undefined;
|
|
74
74
|
}
|
|
75
75
|
recursionCount++;
|
|
76
76
|
if (testExpression.nodeType === 4 /* ParseNodeType.AssignmentExpression */) {
|
|
77
|
-
return getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, recursionCount);
|
|
77
|
+
return getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, nodeInfo, recursionCount);
|
|
78
78
|
}
|
|
79
79
|
if (testExpression.nodeType === 7 /* ParseNodeType.BinaryOperation */) {
|
|
80
80
|
const isOrIsNotOperator = testExpression.d.operator === 39 /* OperatorType.Is */ || testExpression.d.operator === 40 /* OperatorType.IsNot */;
|
|
@@ -422,7 +422,7 @@ function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositi
|
|
|
422
422
|
return (type) => {
|
|
423
423
|
return {
|
|
424
424
|
type: narrowTypeForInstanceOrSubclass(evaluator, type, classTypeList, isInstanceCheck,
|
|
425
|
-
/* isTypeIsCheck */ false, isPositiveTest, testExpression),
|
|
425
|
+
/* isTypeIsCheck */ false, isPositiveTest, testExpression, nodeInfo),
|
|
426
426
|
isIncomplete,
|
|
427
427
|
};
|
|
428
428
|
};
|
|
@@ -491,7 +491,7 @@ function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositi
|
|
|
491
491
|
const isIncomplete = !!callTypeResult.isIncomplete || !!functionReturnTypeResult.isIncomplete;
|
|
492
492
|
return (type) => {
|
|
493
493
|
return {
|
|
494
|
-
type: narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard, testExpression),
|
|
494
|
+
type: narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard, testExpression, nodeInfo),
|
|
495
495
|
isIncomplete,
|
|
496
496
|
};
|
|
497
497
|
};
|
|
@@ -510,7 +510,7 @@ function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositi
|
|
|
510
510
|
}
|
|
511
511
|
// Is this a reference to an aliased conditional expression (a local variable
|
|
512
512
|
// that was assigned a value that can inform type narrowing of the reference expression)?
|
|
513
|
-
const narrowingCallback = getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, recursionCount);
|
|
513
|
+
const narrowingCallback = getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, nodeInfo, recursionCount);
|
|
514
514
|
if (narrowingCallback) {
|
|
515
515
|
return narrowingCallback;
|
|
516
516
|
}
|
|
@@ -520,12 +520,12 @@ function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositi
|
|
|
520
520
|
if (reference.nodeType === 38 /* ParseNodeType.Name */) {
|
|
521
521
|
if (testExpression.nodeType === 55 /* ParseNodeType.UnaryOperation */ &&
|
|
522
522
|
testExpression.d.operator === 38 /* OperatorType.Not */) {
|
|
523
|
-
return getTypeNarrowingCallback(evaluator, reference, testExpression.d.expr, !isPositiveTest, recursionCount);
|
|
523
|
+
return getTypeNarrowingCallback(evaluator, reference, testExpression.d.expr, !isPositiveTest, nodeInfo, recursionCount);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
return undefined;
|
|
527
527
|
}
|
|
528
|
-
function getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, recursionCount) {
|
|
528
|
+
function getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testExpression, isPositiveTest, nodeInfo, recursionCount) {
|
|
529
529
|
if (testExpression.nodeType !== 38 /* ParseNodeType.Name */ ||
|
|
530
530
|
reference.nodeType !== 38 /* ParseNodeType.Name */ ||
|
|
531
531
|
testExpression === reference) {
|
|
@@ -571,13 +571,14 @@ function getTypeNarrowingCallbackForAliasedCondition(evaluator, reference, testE
|
|
|
571
571
|
if (!initNode || ParseTreeUtils.isNodeContainedWithin(testExpression, initNode) || !(0, parseNodes_1.isExpressionNode)(initNode)) {
|
|
572
572
|
return undefined;
|
|
573
573
|
}
|
|
574
|
-
return getTypeNarrowingCallback(evaluator, reference, initNode, isPositiveTest, recursionCount);
|
|
574
|
+
return getTypeNarrowingCallback(evaluator, reference, initNode, isPositiveTest, nodeInfo, recursionCount);
|
|
575
575
|
}
|
|
576
576
|
// Determines whether the symbol is a local variable or parameter within
|
|
577
577
|
// the current scope. If requireUnique is true, there can be only one
|
|
578
578
|
// declaration (assignment) of the symbol, otherwise it is rejected.
|
|
579
579
|
function getDeclsForLocalVar(evaluator, name, reachableFrom, requireUnique) {
|
|
580
|
-
const
|
|
580
|
+
const nodeInfo = (0, analyzerNodeInfo_1.getInfoReader)(evaluator);
|
|
581
|
+
const scope = (0, scopeUtils_1.getScopeForNode)(name, nodeInfo);
|
|
581
582
|
if (scope?.type !== 2 /* ScopeType.Function */ && scope?.type !== 4 /* ScopeType.Module */) {
|
|
582
583
|
return undefined;
|
|
583
584
|
}
|
|
@@ -598,7 +599,7 @@ function getDeclsForLocalVar(evaluator, name, reachableFrom, requireUnique) {
|
|
|
598
599
|
let prevDeclScope;
|
|
599
600
|
if (decls.some((decl) => {
|
|
600
601
|
const nodeToConsider = decl.type === 2 /* DeclarationType.Param */ ? decl.node.d.name : decl.node;
|
|
601
|
-
const declScopeNode = ParseTreeUtils.getExecutionScopeNode(nodeToConsider);
|
|
602
|
+
const declScopeNode = ParseTreeUtils.getExecutionScopeNode(nodeToConsider, nodeInfo);
|
|
602
603
|
if (prevDeclScope && declScopeNode !== prevDeclScope) {
|
|
603
604
|
return true;
|
|
604
605
|
}
|
|
@@ -610,11 +611,11 @@ function getDeclsForLocalVar(evaluator, name, reachableFrom, requireUnique) {
|
|
|
610
611
|
const reachableDecls = decls.filter((decl) => evaluator.isNodeReachable(reachableFrom, decl.node));
|
|
611
612
|
return reachableDecls.length > 0 ? reachableDecls : undefined;
|
|
612
613
|
}
|
|
613
|
-
function getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, recursionCount) {
|
|
614
|
-
return (getTypeNarrowingCallback(evaluator, reference, testExpression.d.rightExpr, isPositiveTest, recursionCount) ??
|
|
615
|
-
getTypeNarrowingCallback(evaluator, reference, testExpression.d.name, isPositiveTest, recursionCount));
|
|
614
|
+
function getTypeNarrowingCallbackForAssignmentExpression(evaluator, reference, testExpression, isPositiveTest, nodeInfo, recursionCount) {
|
|
615
|
+
return (getTypeNarrowingCallback(evaluator, reference, testExpression.d.rightExpr, isPositiveTest, nodeInfo, recursionCount) ??
|
|
616
|
+
getTypeNarrowingCallback(evaluator, reference, testExpression.d.name, isPositiveTest, nodeInfo, recursionCount));
|
|
616
617
|
}
|
|
617
|
-
function narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard, errorNode) {
|
|
618
|
+
function narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPositiveTest, isStrictTypeGuard, errorNode, nodeInfo) {
|
|
618
619
|
// For non-strict type guards, always narrow to the typeGuardType
|
|
619
620
|
// in the positive case and don't narrow in the negative case.
|
|
620
621
|
if (!isStrictTypeGuard) {
|
|
@@ -636,7 +637,7 @@ function narrowTypeForUserDefinedTypeGuard(evaluator, type, typeGuardType, isPos
|
|
|
636
637
|
});
|
|
637
638
|
return narrowTypeForInstanceOrSubclass(evaluator, type, filterTypes,
|
|
638
639
|
/* isInstanceCheck */ true,
|
|
639
|
-
/* isTypeIsCheck */ true, isPositiveTest, errorNode);
|
|
640
|
+
/* isTypeIsCheck */ true, isPositiveTest, errorNode, nodeInfo);
|
|
640
641
|
}
|
|
641
642
|
// Narrow the type based on whether the subtype can be true or false.
|
|
642
643
|
function narrowTypeForTruthiness(evaluator, type, isPositiveTest) {
|
|
@@ -896,18 +897,18 @@ function getIsInstanceClassTypes(evaluator, argType) {
|
|
|
896
897
|
});
|
|
897
898
|
return foundNonClassType ? undefined : classTypeList;
|
|
898
899
|
}
|
|
899
|
-
function narrowTypeForInstanceOrSubclass(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest, errorNode) {
|
|
900
|
+
function narrowTypeForInstanceOrSubclass(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest, errorNode, nodeInfo) {
|
|
900
901
|
// First try with intersection types disallowed.
|
|
901
902
|
const narrowedType = narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest,
|
|
902
|
-
/* allowIntersections */ false, errorNode);
|
|
903
|
+
/* allowIntersections */ false, errorNode, nodeInfo);
|
|
903
904
|
if (!(0, types_1.isNever)(narrowedType)) {
|
|
904
905
|
return narrowedType;
|
|
905
906
|
}
|
|
906
907
|
// Try again with intersection types allowed.
|
|
907
908
|
return narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest,
|
|
908
|
-
/* allowIntersections */ true, errorNode);
|
|
909
|
+
/* allowIntersections */ true, errorNode, nodeInfo);
|
|
909
910
|
}
|
|
910
|
-
function narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode) {
|
|
911
|
+
function narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, isInstanceCheck, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode, nodeInfo) {
|
|
911
912
|
const result = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
|
912
913
|
let adjSubtype = subtype;
|
|
913
914
|
let resultRequiresAdj = false;
|
|
@@ -925,7 +926,7 @@ function narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, i
|
|
|
925
926
|
}
|
|
926
927
|
}
|
|
927
928
|
}
|
|
928
|
-
const narrowedResult = narrowTypeForInstance(evaluator, adjSubtype, adjFilterTypes, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode);
|
|
929
|
+
const narrowedResult = narrowTypeForInstance(evaluator, adjSubtype, adjFilterTypes, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode, nodeInfo);
|
|
929
930
|
if (!resultRequiresAdj) {
|
|
930
931
|
return narrowedResult;
|
|
931
932
|
}
|
|
@@ -943,7 +944,7 @@ function narrowTypeForInstanceOrSubclassInternal(evaluator, type, filterTypes, i
|
|
|
943
944
|
// type of expression "x" is "Mammal" and the test expression is
|
|
944
945
|
// "isinstance(x, Cow)", (assuming "Cow" is a subclass of "Mammal"), we can
|
|
945
946
|
// narrow x to "Cow".
|
|
946
|
-
function narrowTypeForInstance(evaluator, type, filterTypes, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode) {
|
|
947
|
+
function narrowTypeForInstance(evaluator, type, filterTypes, isTypeIsCheck, isPositiveTest, allowIntersections, errorNode, nodeInfo) {
|
|
947
948
|
let expandedTypes = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
|
948
949
|
return (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(subtype);
|
|
949
950
|
});
|
|
@@ -955,7 +956,7 @@ function narrowTypeForInstance(evaluator, type, filterTypes, isTypeIsCheck, isPo
|
|
|
955
956
|
}
|
|
956
957
|
// If this is an isinstance or issubclass check, the type variables
|
|
957
958
|
// should be converted to "free" type variables.
|
|
958
|
-
return (0, typeUtils_1.makeTypeVarsFree)(varType, ParseTreeUtils.getTypeVarScopesForNode(errorNode));
|
|
959
|
+
return (0, typeUtils_1.makeTypeVarsFree)(varType, ParseTreeUtils.getTypeVarScopesForNode(errorNode, nodeInfo));
|
|
959
960
|
};
|
|
960
961
|
// Filters the varType by the parameters of the isinstance
|
|
961
962
|
// and returns the list of types the varType could be after
|
|
@@ -1001,7 +1002,7 @@ function narrowTypeForInstance(evaluator, type, filterTypes, isTypeIsCheck, isPo
|
|
|
1001
1002
|
// bound to free type variables. We'll retain the bound type
|
|
1002
1003
|
// variables for TypeIs checks.
|
|
1003
1004
|
if (!isTypeIsCheck) {
|
|
1004
|
-
runtimeVarType = (0, typeUtils_1.makeTypeVarsFree)(runtimeVarType, ParseTreeUtils.getTypeVarScopesForNode(errorNode));
|
|
1005
|
+
runtimeVarType = (0, typeUtils_1.makeTypeVarsFree)(runtimeVarType, ParseTreeUtils.getTypeVarScopesForNode(errorNode, nodeInfo));
|
|
1005
1006
|
}
|
|
1006
1007
|
// If the value is a TypedDict, convert it into its runtime form,
|
|
1007
1008
|
// which is a dict[str, Any].
|
|
@@ -1189,7 +1190,7 @@ function narrowTypeForInstance(evaluator, type, filterTypes, isTypeIsCheck, isPo
|
|
|
1189
1190
|
// two type is a subclass that is callable. We'll synthesize a
|
|
1190
1191
|
// new intersection type.
|
|
1191
1192
|
const className = `<callable subtype of ${concreteVarType.shared.name}>`;
|
|
1192
|
-
const fileInfo =
|
|
1193
|
+
const fileInfo = nodeInfo.getFileInfo(errorNode);
|
|
1193
1194
|
let newClassType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
|
|
1194
1195
|
/* declaredMetaclass */ undefined, concreteVarType.shared.effectiveMetaclass, concreteVarType.shared.docString);
|
|
1195
1196
|
newClassType.shared.baseClasses = [concreteVarType];
|
|
@@ -1588,11 +1589,13 @@ function narrowTypeForTypedDictKey(evaluator, referenceType, literalKey, isPosit
|
|
|
1588
1589
|
// // narrowing it isn't possible in this case.
|
|
1589
1590
|
// return subtype;
|
|
1590
1591
|
// }
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1592
|
+
if ((0, types_1.isNever)(tdEntry.valueType)) {
|
|
1593
|
+
// If the entry is typed as Never or the "extra items" is typed as Never,
|
|
1594
|
+
// then this key cannot be present in the TypedDict, and we can eliminate it.
|
|
1595
|
+
// A closed TypedDict has an "extra items" of Never, so this is what allows
|
|
1596
|
+
// a key check to discriminate between closed TypedDicts.
|
|
1597
|
+
return undefined;
|
|
1598
|
+
}
|
|
1596
1599
|
// If the entry is currently not required and not marked provided, we can mark
|
|
1597
1600
|
// it as provided after this guard expression confirms it is.
|
|
1598
1601
|
if (tdEntry.isRequired || tdEntry.isProvided) {
|
|
@@ -1953,9 +1956,10 @@ function enumerateLiteralsForType(evaluator, type) {
|
|
|
1953
1956
|
];
|
|
1954
1957
|
}
|
|
1955
1958
|
if (types_1.ClassType.isEnumClass(type)) {
|
|
1956
|
-
// Enum expansion doesn't apply
|
|
1957
|
-
// from enum.Flag.
|
|
1958
|
-
if (
|
|
1959
|
+
// Enum expansion doesn't apply if the member set cannot be statically
|
|
1960
|
+
// enumerated or if the class derives from enum.Flag.
|
|
1961
|
+
if (types_1.ClassType.isEnumMemberSetMayBeDynamicallyModified(type) ||
|
|
1962
|
+
type.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'Flag'))) {
|
|
1959
1963
|
return undefined;
|
|
1960
1964
|
}
|
|
1961
1965
|
// Enumerate all of the values in this enumeration.
|
|
@@ -1964,7 +1968,7 @@ function enumerateLiteralsForType(evaluator, type) {
|
|
|
1964
1968
|
fields.forEach((symbol, name) => {
|
|
1965
1969
|
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
1966
1970
|
let symbolType = evaluator.getEffectiveTypeOfSymbol(symbol);
|
|
1967
|
-
symbolType = (0, enums_1.transformTypeForEnumMember)(evaluator, type, name) ?? symbolType;
|
|
1971
|
+
symbolType = (0, enums_1.transformTypeForEnumMember)(evaluator, type, name, (0, analyzerNodeInfo_1.getInfoReader)(evaluator)) ?? symbolType;
|
|
1968
1972
|
if ((0, types_1.isClassInstance)(symbolType) &&
|
|
1969
1973
|
types_1.ClassType.isSameGenericClass(type, symbolType) &&
|
|
1970
1974
|
symbolType.priv.literalValue !== undefined) {
|