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

Formatting a file causes error in LSP log panel #71

Closed
jamesWalker55 opened this issue Mar 14, 2022 · 1 comment
Closed

Formatting a file causes error in LSP log panel #71

jamesWalker55 opened this issue Mar 14, 2022 · 1 comment

Comments

@jamesWalker55
Copy link

jamesWalker55 commented Mar 14, 2022

When trying to format a file, nothing happens to the current file. In the LSP log panel, this error appears:

LSP-pylsp: 2022-03-14 20:50:00,152 GMT Standard Time - ERROR - pylsp_jsonrpc.endpoint - Failed to handle request 27
LSP-pylsp: Traceback (most recent call last):
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 116, in consume
LSP-pylsp:     self._handle_request(message['id'], message['method'], message.get('params'))
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 185, in _handle_request
LSP-pylsp:     handler_result = handler(params)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\dispatchers.py", line 25, in handler
LSP-pylsp:     return method(**(params or {}))
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 366, in m_text_document__formatting
LSP-pylsp:     return self.format_document(textDocument['uri'])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 281, in format_document
LSP-pylsp:     return self._hook('pylsp_format_document', doc_uri)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 156, in _hook
LSP-pylsp:     return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
LSP-pylsp:     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
LSP-pylsp:     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 327, in traced_hookexec
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 60, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 33, in from_call
LSP-pylsp:     result = func()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 324, in <lambda>
LSP-pylsp:     lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 60, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
LSP-pylsp:     res = hook_impl.function(*args)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 13, in pylsp_format_document
LSP-pylsp:     return format_document(document)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 36, in format_document
LSP-pylsp:     config = load_config(document.path)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 82, in load_config
LSP-pylsp:     pyproject_filename = root / "pyproject.toml"
LSP-pylsp: TypeError: unsupported operand type(s) for /: 'tuple' and 'str'

In plugin.py line 80, the value of root is (WindowsPath('D:/'), 'file system root'). Looking at Black's documentation, this function is expected to output a tuple - https://black.readthedocs.io/en/stable/contributing/reference/reference_functions.html#black.find_project_root

@rwols
Copy link
Member

rwols commented Mar 14, 2022

This seems to be an upstream issue: rupert/pyls-black#40

@rwols rwols closed this as completed Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants