python-language-server
python-language-server copied to clipboard
Support non-file URIs
Summary
I've tried to use PYLS on Monaco Editor using Monaco Language Client with the following configuration
this.editor.setModel(monaco.editor.createModel(exampleCode, 'python', monaco.Uri.parse('inmemory://dummy.py')););
const services = createMonacoServices(this.editor);
And everything that this blog explained.
Everything works as expected but the auto complete. When I do ctrl + space
on the editor, there's only "No Suggestions." and I saw the PYLS logs error as follows
PYLS Server: 2017-12-08 09:56:21,029 UTC - ERROR - jsonrpc.manager - API Exception: {'message': "'Folder' object has no attribute 'read'", 'args': ("'Folder' object has no attribute 'read'",), 'type': 'AttributeError'}
Traceback (most recent call last):
File "myVirtualEnv/lib/python2.7/site-packages/jsonrpc/manager.py", line 112, in _get_responses
result = method(*request.args, **request.kwargs)
File "myVirtualEnv/lib/python2.7/site-packages/pyls/language_server.py", line 64, in wrapped
return func(*args, **kwargs)
File "myVirtualEnv/lib/python2.7/site-packages/pyls/python_ls.py", line 140, in m_text_document__completion
return self.completions(textDocument['uri'], position)
File "myVirtualEnv/lib/python2.7/site-packages/pyls/python_ls.py", line 70, in completions
position=position
File "myVirtualEnv/lib/python2.7/site-packages/pyls/_utils.py", line 113, in race_hooks
for impl, result in pool.imap_unordered(_apply, impls, chunksize=1):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 668, in next
raise value
AttributeError: 'Folder' object has no attribute 'read'
Could you help me? is it about the monaco URI that I pass ? inmemory://dummy.py
I think there is an issue somewhere about supporting URIs that have schemes other than “file”. I suspect this is what you’re hitting. I believe the SourceGraph language server has better support for things like this right now.
https://github.com/sourcegraph/python-langserver
@gatesn Thanks. But the sourcegraph language server hasn't been maintained for a while. After so long, is there any workaround or speical configuration to make the pyls support non-file uri?? Or can you point out some other alternitives?
@exiaohu are you looking to use arbitrary URLs? e.g. https etc. Or are you looking for purely in-memory analysis, e.g. only things passed by didOpen will be valid
Any updates on the subject ? I am trying to make pyls work with monaco editor with inmemory scheme files, and cant find a way to have intellisense across multiple files. I would like to import methods/class from a model created in monaco editor into an other model, (import method from "inmemory://toto.py" into "inmemory://tata.py") , but pyls seems to not understand that toto.py exist while editing tata.py.