omnilib / vscode-ufmt

VS Code extension for µfmt
https://ufmt.omnilib.dev
MIT License
5 stars 4 forks source link

formatter fails with `RuntimeError: generator didn't yield` #27

Closed sarisia closed 10 months ago

sarisia commented 2 years ago

Starting from omnilib.ufmt v2022.9.14, formatting document no longer works.

extension output:

formatting in-process
CWD Linter: /workspace
Failed to handle request 26 textDocument/formatting work_done_token=None text_document=TextDocumentIdentifier(uri='file:///workspace/src/masked.py') options=FormattingOptions(tab_size=4, insert_spaces=True, trim_trailing_whitespace=None, insert_final_newline=None, trim_final_newlines=None)
Traceback (most recent call last):
  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/libs/pygls/protocol.py", line 331, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/libs/pygls/protocol.py", line 260, in _execute_request
    method_name, method_type, msg_id, handler(params))
  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 92, in formatting
    edits = _formatting_helper(document)
  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 102, in _formatting_helper
    result = _run_tool_on_document(document, use_stdin=True)
  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 296, in _run_tool_on_document
    with update_sys_path(BUNDLED_LIBS, IMPORT_STRATEGY):
  File "/usr/local/lib/python3.9/contextlib.py", line 121, in __enter__
    raise RuntimeError("generator didn't yield") from None
RuntimeError: generator didn't yield
[Error - 5:50:54 AM] Request textDocument/formatting failed.
  Message: RuntimeError: generator didn't yield
  Code: -32602 
{'traceback': ['  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/libs/pygls/protocol.py", line 331, in _handle_request\n    self._execute_request(msg_id, handler, params)\n', '  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/libs/pygls/protocol.py", line 260, in _execute_request\n    method_name, method_type, msg_id, handler(params))\n', '  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 92, in formatting\n    edits = _formatting_helper(document)\n', '  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 102, in _formatting_helper\n    result = _run_tool_on_document(document, use_stdin=True)\n', '  File "/home/vscode/.vscode-server/extensions/omnilib.ufmt-2022.9.14-linux-x64/bundled/tool/server.py", line 296, in _run_tool_on_document\n    with update_sys_path(BUNDLED_LIBS, IMPORT_STRATEGY):\n', '  File "/usr/local/lib/python3.9/contextlib.py", line 121, in __enter__\n    raise RuntimeError("generator didn\'t yield") from None\n']}

VSCode info:

Version: 1.71.2 (system setup)
Commit: 74b1f979648cc44d385a2286793c226e611f59e7
Date: 2022-09-14T21:03:37.738Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.22000
Sandboxed: No
Jeremie-Chauvel commented 1 year ago

Hi, I had the same issue, I bypassed it for now by specifying the ufmt binary in .vscode/settings.json:

  "ufmt.path": [
    "./venv/bin/ufmt"
  ],

you will need to adapt it to your setup (and where you installed ufmt)

amyreese commented 10 months ago

Hi, apologies for not following up on this sooner. I haven't been able to replicate this issue in any recent releases, so I'm going to close this issue. Please feel free to comment here or open a new issue if you are able to reproduce this on the latest (today's) release. Cheers!