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

TypeError when formatting with Black 22.1 #29

Closed
wlcx opened this issue Jan 30, 2022 · 0 comments · Fixed by #30
Closed

TypeError when formatting with Black 22.1 #29

wlcx opened this issue Jan 30, 2022 · 0 comments · Fixed by #30
Assignees
Labels
bug Something isn't working
Milestone

Comments

@wlcx
Copy link
Contributor

wlcx commented Jan 30, 2022

When attempting to format, I get an error. The backtrace from lsp.log is below:

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

Looks like the latest version of black, 22.1.0, changed the signature for find_project_root, now returning a tuple.

@ccordoba12 ccordoba12 added this to the v1.1.0 milestone Jan 30, 2022
@ccordoba12 ccordoba12 changed the title Unsupported operand type(s) for /: 'tuple' and 'str'when formatting TypeError when formatting with Black 22.1 Jan 30, 2022
@haplo haplo added the bug Something isn't working label Jan 30, 2022
@haplo haplo closed this as completed in #30 Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants