EeyoreLee / vscode-extension-yapf

Vscode formatter extension support for python files using `yapf`.
MIT License
18 stars 5 forks source link

Cannot start server #64

Closed pghezzo closed 12 months ago

pghezzo commented 1 year ago

Hello! I would be very keen on using the extension, but I don't seem to be able to start the server/

Here's the output logs:

2023-10-25 15:03:39.610 [info] [Error - 3:03:39 PM] Server initialization failed.
2023-10-25 15:03:39.610 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-10-25 15:03:39.611 [info] [Info  - 3:03:39 PM] Connection to server got closed. Server will restart.
2023-10-25 15:03:39.611 [info] true
2023-10-25 15:03:39.611 [info] [Error - 3:03:39 PM] yapf client: couldn't create connection to server.
2023-10-25 15:03:39.611 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-10-25 15:03:39.611 [info] [Error - 3:03:39 PM] Restarting server failed
2023-10-25 15:03:39.611 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-10-25 15:03:43.203 [info] Traceback (most recent call last):
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\tool\lsp_server.py", line 46, in <module>
    from pygls import server, uris, workspace
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\libs\pygls\server.py", line 35, in <module>
    import cattrs
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\libs\cattrs\__init__.py", line 1, in <module>
    from .converters import BaseConverter, Converter, GenConverter, UnstructureStrategy
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\libs\cattrs\converters.py", line 26, in <module>
    from ._compat import (
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\libs\cattrs\_compat.py", line 25, in <module>
    from typing_extensions import TypedDict as ExtensionsTypedDict
  File "c:\Users\myUser\.vscode\extensions\eeyore.yapf-0.1.10\bundled\libs\typing_extensions.py", line 874
    def TypedDict(typename, fields=_marker, /, *, total=True, **kwargs):
                                            ^
SyntaxError: invalid syntax

I have python 3.11.5 as my system level python, with yapf 0.40.2 installed globally. I have the following in my settings.json:

"python.formatting.provider": "none",
...
"[python]": {
        "editor.formatOnSaveMode": "file",
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "eeyore.yapf"
      }
...

Am I doing something wrong? Thank you for the help! Best.

EeyoreLee commented 1 year ago

@pghezzo - Hi, could you check python version is really 3.11? The issue occurred on python 3.7 which is already EOL. Same as issue #53

EeyoreLee commented 1 year ago

A message like Server run command: ~/miniconda3/envs/api/bin/python ~/.vscode-server/extensions/eeyore.yapf-0.1.10/bundled/tool/lsp_server.py will appear at the head of output. You can check which python did you select.

EeyoreLee commented 12 months ago

@pghezzo - hi, does it fix your issue ? Another way to fix it is set the property yapf.interpreter manually to select which python to executable this extension. close this issue and feel free to reopen it if it still not works for you.