Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extraPaths in language server no longer work on pyright >= 1.1.340 #7016

Closed
FindDefinition opened this issue Jan 17, 2024 · 15 comments
Closed
Assignees
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@FindDefinition
Copy link

Describe the bug

I'm using pyright as language server via a websocket server and pyright server run in --stdio mode. recently I found that my dev project (installed via pip install -e .) can't be resolved by pyright langserver. previously I use extraPaths to tell pyright check my dev project and it works well in pyright <= 1.1.339.

packages in standard python directory (miniconda3) have no problem.

I test some pyright versions by binary search and get following result:

version <= 1.1.339: works
version == 1.1.340: hang
version >= 1.1.341: not working

Code or Screenshots
I can provide language server input and output jsonrpc messages:
1.1.347:

[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'method': 'initialize', 'params': {'processId': None, 'clientInfo': {'name': 'Monaco', 'version': '1.76.0'}, 'locale': 'en-US', 'rootPath': None, 'rootUri': None, 'capabilities': {'workspace': {'applyEdit': True, 'workspaceEdit': {'documentChanges': True, 'resourceOperations': ['create', 'rename', 'delete'], 'failureHandling': 'textOnlyTransactional', 'normalizesLineEndings': True, 'changeAnnotationSupport': {'groupsOnLabel': True}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'executeCommand': {'dynamicRegistration': True}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'workspaceFolders': True, 'semanticTokens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}}, 'textDocument': {'publishDiagnostics': {'relatedInformation': True, 'versionSupport': False, 'tagSupport': {'valueSet': [1, 2]}, 'codeDescriptionSupport': True, 'dataSupport': True}, 'synchronization': {'dynamicRegistration': True}, 'completion': {'dynamicRegistration': True, 'contextSupport': True, 'completionItem': {'snippetSupport': True, 'commitCharactersSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'deprecatedSupport': True, 'preselectSupport': True, 'tagSupport': {'valueSet': [1]}, 'insertReplaceSupport': True, 'resolveSupport': {'properties': ['documentation', 'detail', 'additionalTextEdits']}, 'insertTextModeSupport': {'valueSet': [1, 2]}, 'labelDetailsSupport': True}, 'insertTextMode': 2, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'completionList': {'itemDefaults': ['commitCharacters', 'editRange', 'insertTextFormat', 'insertTextMode']}}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'signatureHelp': {'dynamicRegistration': True, 'signatureInformation': {'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}, 'activeParameterSupport': True}, 'contextSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}, 'labelSupport': True}, 'codeAction': {'dynamicRegistration': True, 'isPreferredSupport': True, 'disabledSupport': True, 'dataSupport': True, 'resolveSupport': {'properties': ['edit']}, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['', 'quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source', 'source.organizeImports']}}, 'honorsChangeAnnotations': False}, 'codeLens': {'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'onTypeFormatting': {'dynamicRegistration': True}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1, 'honorsChangeAnnotations': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'colorProvider': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'rangeLimit': 5000, 'lineFoldingOnly': True, 'foldingRangeKind': {'valueSet': ['comment', 'imports', 'region']}, 'foldingRange': {'collapsedText': False}}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'semanticTokens': {'dynamicRegistration': True, 'tokenTypes': ['namespace', 'type', 'class', 'enum', 'interface', 'struct', 'typeParameter', 'parameter', 'variable', 'property', 'enumMember', 'event', 'function', 'method', 'macro', 'keyword', 'modifier', 'comment', 'string', 'number', 'regexp', 'operator', 'decorator'], 'tokenModifiers': ['declaration', 'definition', 'readonly', 'static', 'deprecated', 'abstract', 'async', 'modification', 'documentation', 'defaultLibrary'], 'formats': ['relative'], 'requests': {'range': True, 'full': {'delta': True}}, 'multilineTokenSupport': False, 'overlappingTokenSupport': False, 'serverCancelSupport': True, 'augmentsSyntaxTokens': True}, 'linkedEditingRange': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['tooltip', 'textEdits', 'label.tooltip', 'label.location', 'label.command']}}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': False}}, 'window': {'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'showDocument': {'support': True}}, 'general': {'staleRequestSupport': {'cancel': True, 'retryOnContentModified': ['textDocument/semanticTokens/full', 'textDocument/semanticTokens/range', 'textDocument/semanticTokens/full/delta']}, 'regularExpressions': {'engine': 'ECMAScript', 'version': 'ES2020'}, 'markdown': {'parser': 'marked', 'version': '1.1.0'}, 'positionEncodings': ['utf-16']}}, 'trace': 'off', 'workspaceFolders': None}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Pyright language server 1.1.347 starting'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Server root directory: file:///root/.cache/pyright-python/1.1.347/node_modules/pyright/dist'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 0, 'result': {'capabilities': {'textDocumentSync': 2, 'definitionProvider': {'workDoneProgress': True}, 'declarationProvider': {'workDoneProgress': True}, 'typeDefinitionProvider': {'workDoneProgress': True}, 'referencesProvider': {'workDoneProgress': True}, 'documentSymbolProvider': {'workDoneProgress': True}, 'workspaceSymbolProvider': {'workDoneProgress': True}, 'hoverProvider': {'workDoneProgress': True}, 'documentHighlightProvider': {'workDoneProgress': True}, 'renameProvider': {'prepareProvider': True, 'workDoneProgress': True}, 'completionProvider': {'triggerCharacters': ['.', '[', '"', "'"], 'resolveProvider': True, 'workDoneProgress': True, 'completionItem': {'labelDetailsSupport': True}}, 'signatureHelpProvider': {'triggerCharacters': ['(', ',', ')'], 'workDoneProgress': True}, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'source.organizeImports'], 'workDoneProgress': True}, 'executeCommandProvider': {'commands': [], 'workDoneProgress': True}, 'callHierarchyProvider': True, 'workspace': {'workspaceFolders': {'supported': True, 'changeNotifications': True}}}}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'initialized', 'params': {}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'textDocument/didOpen', 'params': {'textDocument': {'uri': 'file:///default', 'languageId': 'python', 'version': 1, 'text': ''}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Starting service instance "<default>"'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 0, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'result': [{'analysis': {'extraPaths': ['/root/distflow_dev/distflow/'], 'pythonPath': '/root/miniconda3/bin/python'}}]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 1, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python.analysis'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'result': [{'extraPaths': ['/root/distflow_dev/distflow/'], 'pythonPath': '/root/miniconda3/bin/python'}]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 2, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'pyright'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'result': [None]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'No source files found.'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'uri': 'file:///default', 'version': 1, 'diagnostics': []}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'textDocument/didOpen', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E', 'languageId': 'python', 'version': 1, 'text': 'from tensorpc.flow import mui, three, plus, appctx, mark_create_layout\nclass App:\n    @mark_create_layout\n    def my_layout(self):\n        return mui.VBox([\n            mui.Typography("Hello World"),\n        ])\n'}}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 1, 'result': []}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E', 'version': 1, 'diagnostics': [{'range': {'start': {'line': 0, 'character': 5}, 'end': {'line': 0, 'character': 18}}, 'message': 'Import "tensorpc.flow" could not be resolved', 'severity': 1, 'code': 'reportMissingImports', 'source': 'Pyright', 'codeDescription': {'href': 'https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingImports'}}, {'range': {'start': {'line': 0, 'character': 31}, 'end': {'line': 0, 'character': 36}}, 'message': '"three" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}, {'range': {'start': {'line': 0, 'character': 38}, 'end': {'line': 0, 'character': 42}}, 'message': '"plus" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}, {'range': {'start': {'line': 0, 'character': 44}, 'end': {'line': 0, 'character': 50}}, 'message': '"appctx" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 2, 'result': []}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 3, 'method': 'textDocument/hover', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'position': {'line': 0, 'character': 16}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 3, 'result': None}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 4, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 5}, 'end': {'line': 0, 'character': 18}}, 'context': {'diagnostics': [{'range': {'start': {'line': 0, 'character': 5}, 'end': {'line': 0, 'character': 18}}, 'message': 'Import "tensorpc.flow" could not be resolved', 'code': 'reportMissingImports', 'codeDescription': {'href': 'https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingImports'}, 'severity': 1, 'source': 'Pyright'}], 'only': ['quickfix'], 'triggerKind': 1}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 4, 'result': []}

1.1.339:

[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'method': 'initialize', 'params': {'processId': None, 'clientInfo': {'name': 'Monaco', 'version': '1.76.0'}, 'locale': 'en-US', 'rootPath': None, 'rootUri': None, 'capabilities': {'workspace': {'applyEdit': True, 'workspaceEdit': {'documentChanges': True, 'resourceOperations': ['create', 'rename', 'delete'], 'failureHandling': 'textOnlyTransactional', 'normalizesLineEndings': True, 'changeAnnotationSupport': {'groupsOnLabel': True}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'executeCommand': {'dynamicRegistration': True}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'workspaceFolders': True, 'semanticTokens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}}, 'textDocument': {'publishDiagnostics': {'relatedInformation': True, 'versionSupport': False, 'tagSupport': {'valueSet': [1, 2]}, 'codeDescriptionSupport': True, 'dataSupport': True}, 'synchronization': {'dynamicRegistration': True}, 'completion': {'dynamicRegistration': True, 'contextSupport': True, 'completionItem': {'snippetSupport': True, 'commitCharactersSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'deprecatedSupport': True, 'preselectSupport': True, 'tagSupport': {'valueSet': [1]}, 'insertReplaceSupport': True, 'resolveSupport': {'properties': ['documentation', 'detail', 'additionalTextEdits']}, 'insertTextModeSupport': {'valueSet': [1, 2]}, 'labelDetailsSupport': True}, 'insertTextMode': 2, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'completionList': {'itemDefaults': ['commitCharacters', 'editRange', 'insertTextFormat', 'insertTextMode']}}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'signatureHelp': {'dynamicRegistration': True, 'signatureInformation': {'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}, 'activeParameterSupport': True}, 'contextSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}, 'labelSupport': True}, 'codeAction': {'dynamicRegistration': True, 'isPreferredSupport': True, 'disabledSupport': True, 'dataSupport': True, 'resolveSupport': {'properties': ['edit']}, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['', 'quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source', 'source.organizeImports']}}, 'honorsChangeAnnotations': False}, 'codeLens': {'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'onTypeFormatting': {'dynamicRegistration': True}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1, 'honorsChangeAnnotations': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'colorProvider': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'rangeLimit': 5000, 'lineFoldingOnly': True, 'foldingRangeKind': {'valueSet': ['comment', 'imports', 'region']}, 'foldingRange': {'collapsedText': False}}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'semanticTokens': {'dynamicRegistration': True, 'tokenTypes': ['namespace', 'type', 'class', 'enum', 'interface', 'struct', 'typeParameter', 'parameter', 'variable', 'property', 'enumMember', 'event', 'function', 'method', 'macro', 'keyword', 'modifier', 'comment', 'string', 'number', 'regexp', 'operator', 'decorator'], 'tokenModifiers': ['declaration', 'definition', 'readonly', 'static', 'deprecated', 'abstract', 'async', 'modification', 'documentation', 'defaultLibrary'], 'formats': ['relative'], 'requests': {'range': True, 'full': {'delta': True}}, 'multilineTokenSupport': False, 'overlappingTokenSupport': False, 'serverCancelSupport': True, 'augmentsSyntaxTokens': True}, 'linkedEditingRange': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['tooltip', 'textEdits', 'label.tooltip', 'label.location', 'label.command']}}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': False}}, 'window': {'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'showDocument': {'support': True}}, 'general': {'staleRequestSupport': {'cancel': True, 'retryOnContentModified': ['textDocument/semanticTokens/full', 'textDocument/semanticTokens/range', 'textDocument/semanticTokens/full/delta']}, 'regularExpressions': {'engine': 'ECMAScript', 'version': 'ES2020'}, 'markdown': {'parser': 'marked', 'version': '1.1.0'}, 'positionEncodings': ['utf-16']}}, 'trace': 'off', 'workspaceFolders': None}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Pyright language server 1.1.339 starting'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Server root directory: /root/.cache/pyright-python/1.1.339/node_modules/pyright/dist'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 0, 'result': {'capabilities': {'textDocumentSync': 2, 'definitionProvider': {'workDoneProgress': True}, 'declarationProvider': {'workDoneProgress': True}, 'typeDefinitionProvider': {'workDoneProgress': True}, 'referencesProvider': {'workDoneProgress': True}, 'documentSymbolProvider': {'workDoneProgress': True}, 'workspaceSymbolProvider': {'workDoneProgress': True}, 'hoverProvider': {'workDoneProgress': True}, 'documentHighlightProvider': {'workDoneProgress': True}, 'renameProvider': {'prepareProvider': True, 'workDoneProgress': True}, 'completionProvider': {'triggerCharacters': ['.', '[', '"', "'"], 'resolveProvider': True, 'workDoneProgress': True, 'completionItem': {'labelDetailsSupport': True}}, 'signatureHelpProvider': {'triggerCharacters': ['(', ',', ')'], 'workDoneProgress': True}, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'source.organizeImports'], 'workDoneProgress': True}, 'executeCommandProvider': {'commands': [], 'workDoneProgress': True}, 'callHierarchyProvider': True, 'workspace': {'workspaceFolders': {'supported': True, 'changeNotifications': True}}}}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'initialized', 'params': {}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'textDocument/didOpen', 'params': {'textDocument': {'uri': 'file:///default', 'languageId': 'python', 'version': 1, 'text': ''}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Starting service instance "<default>"'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 0, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'result': [{'analysis': {'extraPaths': ['/root/distflow_dev/distflow/'], 'pythonPath': '/root/miniconda3/bin/python'}}]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 1, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python.analysis'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'result': [{'extraPaths': ['/root/distflow_dev/distflow/'], 'pythonPath': '/root/miniconda3/bin/python'}]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 2, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'pyright'}]}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'result': [None]}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'No source files found.'}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'uri': 'file:///default', 'version': 1, 'diagnostics': []}}
[JSONRPC IN] {'jsonrpc': '2.0', 'method': 'textDocument/didOpen', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E', 'languageId': 'python', 'version': 1, 'text': 'from tensorpc.flow import mui, three, plus, appctx, mark_create_layout\nclass App:\n    @mark_create_layout\n    def my_layout(self):\n        return mui.VBox([\n            mui.Typography("Hello World"),\n        ])\n'}}}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E', 'version': 1, 'diagnostics': [{'range': {'start': {'line': 0, 'character': 31}, 'end': {'line': 0, 'character': 36}}, 'message': '"three" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}, {'range': {'start': {'line': 0, 'character': 38}, 'end': {'line': 0, 'character': 42}}, 'message': '"plus" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}, {'range': {'start': {'line': 0, 'character': 44}, 'end': {'line': 0, 'character': 50}}, 'message': '"appctx" is not accessed', 'severity': 4, 'source': 'Pyright', 'tags': [1]}]}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 1, 'result': []}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 2, 'result': []}
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 3, 'method': 'textDocument/hover', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'position': {'line': 0, 'character': 17}}}
[JSONRPC OUT] <class 'dict'> {'jsonrpc': '2.0', 'id': 3, 'result': {'contents': {'kind': 'markdown', 'value': '```python\n(module) flow\n```'}, 'range': {'start': {'line': 0, 'character': 14}, 'end': {'line': 0, 'character': 18}}}}

error screen shot:
image
image

VS Code extension or command-line
I'm using monaco, not vscode.

@FindDefinition FindDefinition added the bug Something isn't working label Jan 17, 2024
@erictraut
Copy link
Collaborator

@rchiodo, this looks like fallout from the recent URI changes. Do you want to take this bug?

@FindDefinition FindDefinition changed the title extraPaths in language server no longer work on pyright >= 1.1.339 extraPaths in language server no longer work on pyright >= 1.1.340 Jan 17, 2024
@rchiodo
Copy link
Collaborator

rchiodo commented Jan 17, 2024

Sure. @FindDefinition what's your pyrightconfig.json look like? I cannot reproduce this in VS code using these settings:

image

Can you set this in your pyrightconfig.json and upload the logs then:

"verboseOutput": true

The server output is just showing the same thing as the screenshots do - that pyright can't find the imports. With trace logging turned on, we should log a lot more messages. Specifically, there should be something that has the paths we searched for the failed import.

For example without the foo in my extraPaths, I get this:

[Info  - 9:20:39 AM] Could not import 'other_module' in file 'c:\Users\rchiodo\source\testing\Test_ExtraPath\test.py'
[Info  - 9:20:39 AM]   Looking in stubPath 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath/typings'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath/typings'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath/typings'
[Info  - 9:20:39 AM]   Looking in root directory of execution environment 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Users/rchiodo/source/testing/Test_ExtraPath'
[Info  - 9:20:39 AM]   Looking in extraPath 'file:///c%3A/Users/rchiodo/testing/Test_ExtraPath/foo'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Users/rchiodo/testing/Test_ExtraPath/foo'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Users/rchiodo/testing/Test_ExtraPath/foo'
[Info  - 9:20:39 AM]   Finding python search paths
[Info  - 9:20:39 AM]   Executing interpreter: 'c:\Users\rchiodo\AppData\Local\Microsoft\WindowsApps\python3.12.exe'
[Info  - 9:20:39 AM]   Skipping 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0\python312.zip' because it is not a valid directory
[Info  - 9:20:39 AM]   Received 5 paths from interpreter
[Info  - 9:20:39 AM]     file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/DLLs
[Info  - 9:20:39 AM]     file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib
[Info  - 9:20:39 AM]     file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0
[Info  - 9:20:39 AM]     file:///c%3A/Users/rchiodo/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages
[Info  - 9:20:39 AM]     file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib/site-packages
[Info  - 9:20:39 AM]   Looking in python search path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/DLLs'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/DLLs'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/DLLs'
[Info  - 9:20:39 AM]   Looking in python search path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib'
[Info  - 9:20:39 AM]   Looking in python search path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0'
[Info  - 9:20:39 AM]   Looking in python search path 'file:///c%3A/Users/rchiodo/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Users/rchiodo/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Users/rchiodo/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages'
[Info  - 9:20:39 AM]   Looking in python search path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib/site-packages'
[Info  - 9:20:39 AM]   Attempting to resolve stub package using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib/site-packages'
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64__qbz5n2kfra8p0/Lib/site-packages'
[Info  - 9:20:39 AM]   Looking for typeshed stdlib path
[Info  - 9:20:39 AM]   Looking for typeshed stdlib path
[Info  - 9:20:39 AM]   Attempting to resolve using root path 'file:///c%3A/Users/rchiodo/source/repos/pyright/packages/vscode-pyright/dist/typeshed-fallback/stdlib'
[Info  - 9:20:39 AM]   Typeshed path not found
[Info  - 9:20:39 AM]   Looking for typeshed third-party path
[Info  - 9:20:39 AM]   Looking for typeshed stubs path
[Info  - 9:20:39 AM]   Typeshed path not found

@rchiodo rchiodo self-assigned this Jan 17, 2024
@rchiodo
Copy link
Collaborator

rchiodo commented Jan 17, 2024

This one in particular should show what we searched for in your extra paths:

[Info  - 9:20:39 AM]   Looking in extraPath 'file:///c%3A/Users/rchiodo/testing/Test_ExtraPath/foo'

(I had this hardcoded to the wrong path initiallly)

@FindDefinition
Copy link
Author

@rchiodo I can't reproduce this problem with pyright config (with only extraPaths) and command line interface. when I enable logLevel = "Trace" in language server settings, I find that there is no user-provided extraPaths in log:
pyright 1.1.347:

[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'result': [{'analysis': {'extraPaths': ['/root/distflow_dev/distflow'], 'logLevel': 'Trace', 'pythonPath': '/root/miniconda3/bin/python'}}]}                                                                                                                                                                                               
[JSONRPC OUT] {'jsonrpc': '2.0', 'id': 1, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python.analysis'}]}}                                                                                                                                                                                                                               
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}                                                
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'result': [{'extraPaths': ['/root/distflow_dev/distflow'], 'logLevel': 'Trace', 'pythonPath': '/root/miniconda3/bin/python'}]}                                                                                                                                                                                                             
[JSONRPC OUT] {'jsonrpc': '2.0', 'id': 2, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'pyright'}]}}                                                                                                                                                                                                                                       
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'result': [None]}                                                                                                                                                                                                                                                                                                                          
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': 'No pyproject.toml file found.'}}                                                                                                                                                                                                                                                  
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': 'Assuming Python platform Linux'}}                                                                                                                                                                                                                                                 
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Search paths for '}}                                                                                                                                                                                                                                                              
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.cache/pyright-python/1.1.347/node_modules/pyright/dist/typeshed-fallback/stdlib'}}                                                                                                                                                                                       
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  '}}                                                                                                                                                                                                                                                                             
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  '}}                                                                                                                                                                                                                                                                             
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  '}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.cache/pyright-python/1.1.347/node_modules/pyright/dist/typeshed-fallback/stubs/...'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.xxx/lib/python3'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.xxx/lib/python3.8/site-packages'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/lib-dynload'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/site-packages'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/xxx/tstools_core'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/site-packages/tinycudann-1.7-py3.8-linux-x86_64.egg'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Adding fs watcher for library directories:\n file:///root/.xxx/lib/python3\nfile:///root/.xxx/lib/python3.8/site-packages\nfile:///root/miniconda3/lib/python3.8\nfile:///root/miniconda3/lib/python3.8/lib-dynload\nfile:///root/miniconda3/lib/python3.8/site-packages\nfile:///root/xxx/tstools_core\nfile:///root/miniconda3/lib/python3.8/site-packages/tinycudann-1.7-py3.8-linux-x86_64.egg'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': 'Searching for source files'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'No source files found.'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'id': 1, 'result': []}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': '[FG] analyzing: file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E ...'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': '[FG]   parsing: file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E (33ms)'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "Could not import 'tensorpc.flow' in file '/<__tensorpc_inmemory_fname-01-basic/1.1-Hello World.md-1>'"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Looking in stubPath ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve stub package using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Looking in root directory of execution environment ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve stub package using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Looking in extraPath ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve stub package using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Attempting to resolve using root path ''"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  Finding python search paths'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Executing interpreter: 'python3'"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Skipping '/root/.xxx/lib/python3/dist-packages' because it is not a valid directory"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Skipping '/root/.xxx/lib/python3.8/dist-packages' because it is not a valid directory"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Skipping '/root/miniconda3/lib/python38.zip' because it is not a valid directory"}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  Received 7 paths from interpreter'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/.xxx/lib/python3'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/.xxx/lib/python3.8/site-packages'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/miniconda3/lib/python3.8'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/miniconda3/lib/python3.8/lib-dynload'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/miniconda3/lib/python3.8/site-packages'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/xxx/tstools_core'}}
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '    file:///root/miniconda3/lib/python3.8/site-packages/tinycudann-1.7-py3.8-linux-x86_64.egg'}}

pyright 1.1.339:

[JSONRPC IN] {'jsonrpc': '2.0', 'id': 0, 'result': [{'analysis': {'extraPaths': ['/root/distflow_dev/distflow'], 'logLevel': 'Trace', 'pythonPath': '/root/miniconda3/bin/python'}}]}                                                                                                                                                                                               
[JSONRPC OUT] {'jsonrpc': '2.0', 'id': 1, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'python.analysis'}]}}                                                                                                                                                                                                                               
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'method': 'textDocument/codeAction', 'params': {'textDocument': {'uri': 'file:///%3C__tensorpc_inmemory_fname-01-basic/1.1-Hello%20World.md-1%3E'}, 'range': {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}, 'context': {'diagnostics': [], 'triggerKind': 2}}}                                                
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 1, 'result': [{'extraPaths': ['/root/distflow_dev/distflow'], 'logLevel': 'Trace', 'pythonPath': '/root/miniconda3/bin/python'}]}                                                                                                                                                                                                             
[JSONRPC OUT] {'jsonrpc': '2.0', 'id': 2, 'method': 'workspace/configuration', 'params': {'items': [{'scopeUri': '', 'section': 'pyright'}]}}                                                                                                                                                                                                                                       
[JSONRPC IN] {'jsonrpc': '2.0', 'id': 2, 'result': [None]}                                                                                                                                                                                                                                                                                                                          
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': 'No pyproject.toml file found.'}}                                                                                                                                                                                                                                                  
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 4, 'message': 'Assuming Python platform Linux'}}                                                                                                                                                                                                                                                 
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': 'Search paths for <default>'}}                                                                                                                                                                                                                                                     
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.cache/pyright-python/1.1.339/node_modules/pyright/dist/typeshed-fallback/stdlib'}}                                                                                                                                                                                       
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/distflow_dev/distflow'}}                                                                                                                                                                                                                                                  
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  typings'}}                                                                                                                                                                                                                                                                      
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.cache/pyright-python/1.1.339/node_modules/pyright/dist/typeshed-fallback/stubs/...'}}                                                                                                                                                                                    
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.xxx/lib/python3'}}                                                                                                                                                                                                                                                     
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/.xxx/lib/python3.8/site-packages'}}                                                                                                                                                                                                                                     
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8'}}                                                                                                                                                                                                                                               
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/lib-dynload'}}                                                                                                                                                                                                                                   
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/site-packages'}}                                                                                                                                                                                                                                 
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/xxx/tstools_core'}}                                                                                                                                                                                                                                                  
[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': '  /root/miniconda3/lib/python3.8/site-packages/tinycudann-1.7-py3.8-linux-x86_64.egg'}}                                                                                                                                                                                           

You can see the language server config sent by language client, may be there is some problem between language server and pyright core?
In 1.1.339 we can see the path (/root/distflow_dev/distflow) in user-provided settings, but not in 1.1.347.

@rchiodo
Copy link
Collaborator

rchiodo commented Jan 18, 2024

VS code is using the pyright server too and doesn't have this problem. Well at least for me. Can you try VS code to see if you can reproduce your issue?

Otherwise, I'd need some way to reproduce it locally.

@FindDefinition
Copy link
Author

FindDefinition commented Jan 18, 2024

@rchiodo you can start a pyright language server and send jsonrpc messages above to reproduce.
I write a minimal reproduce script, it use pyright in pypi. you need to change the pyright config and code in messages. you may also need to use PYRIGHT_PYTHON_FORCE_VERSION=1.1.339 to force pyright(pypi) use specific version,
also you can change the language server cmd to yours.

@rchiodo
Copy link
Collaborator

rchiodo commented Jan 18, 2024

Thanks I'll try that. I'm going to hazard a guess and say I broke rooted paths somehow. At least that looks like one difference between my configuration and yours.

@divyansshhh
Copy link

I have a similar problem. I'm using jupyterlab-lsp and I have added extraPaths to my config. I recently upgraded to pyright v1.1.347 and it keeps complaining that it can't resolve imports (which are coming from my extraPaths location).

The version I was using earlier was v1.1.326 and it didn't have this issue.

@rchiodo
Copy link
Collaborator

rchiodo commented Jan 18, 2024

Found the root cause. Internally we're trying to combine the extra paths with the workspace URI. In the test code provided, there is no workspace URI and combining an empty URI with anything (currently) returns empty. So, the extraPaths are essentially nulled out.

A workaround would be to pass a workspace folder message. Like so:

        {'jsonrpc': '2.0', 'method': 'workspace/didChangeWorkspaceFolders', 'params': { 'event': { 'added': [ { 'uri': 'file:///root', 'name': 'root '}], 'removed': [] }}},

That allows the extraPaths to be combined correctly (even if the combination just returns the original extra path). For example, I now get this in my extraPaths:

[JSONRPC OUT] {'jsonrpc': '2.0', 'method': 'window/logMessage', 'params': {'type': 3, 'message': "  Looking in extraPath 'file:///root/distflow_dev/distflow'"}}

@rchiodo rchiodo added the addressed in next version Issue is fixed and will appear in next published version label Jan 18, 2024
@divyansshhh
Copy link

When will the next version be released?

@erictraut
Copy link
Collaborator

I typically publish a new version of pyright about once a week — when there are enough fixes or features to justify a new release. A new version of pylance is released once a month.

@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.348, which was just published. It will also be included in a future release of pylance.

@FindDefinition
Copy link
Author

@erictraut @rchiodo this problem comes back in pyright >= 1.1.356, the uri becomes empty in language server output.

@heejaechang
Copy link
Collaborator

@FindDefinition let me take a look

@heejaechang
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants