microsoft / vscode-autopep8

Formatting support for python using autopep8.
https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8
MIT License
20 stars 13 forks source link

AUTOPEP8 NOT WORK!!! #290

Closed CoderCore closed 2 months ago

CoderCore commented 2 months ago

2024-08-27 11:30:28.833 [info] [Error - 11:30:28] Request textDocument/formatting failed. 2024-08-27 11:30:28.833 [info] Message: FileNotFoundError: [WinError 2] 系统找不到指定的文件。 Code: -32603 [object Object] 2024-08-27 11:30:28.975 [info] --max-line-length=1024 - 2024-08-27 11:30:28.975 [info] CWD Server: D:\ 2024-08-27 11:30:28.977 [info] Failed to handle request 4 textDocument/formatting DocumentFormattingParams(text_document=TextDocumentIdentifier(uri='file:///d%3A/test.py'), options=FormattingOptions(tab_size=4, insert_spaces=True, trim_trailing_whitespace=None, insert_final_newline=None, trim_final_newlines=None), work_done_token=None) Traceback (most recent call last): File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\libs\pygls\protocol\json_rpc.py", line 266, in _handle_request self._execute_request(msg_id, handler, params) File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\libs\pygls\protocol\json_rpc.py", line 188, in _execute_request self._send_response(msg_id, handler(params)) ^^^^^^^^^^^^^^^ File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool\lsp_server.py", line 82, in formatting return _formatting_helper(document) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool\lsp_server.py", line 116, in _formatting_helper result = _run_tool_on_document(document, use_stdin=True, extra_args=extra_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool\lsp_server.py", line 466, in _run_tool_on_document result = utils.run_path( ^^^^^^^^^^^^^^^ File "c:\Users\Windows.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool\lsp_utils.py", line 196, in run_path with subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "c:\Program Files\Python312\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "c:\Program Files\Python312\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] 系统找不到指定的文件。

2024-08-27 11:30:28.977 [info] [Error - 11:30:28] Request textDocument/formatting failed. 2024-08-27 11:30:28.978 [info] Message: FileNotFoundError: [WinError 2] 系统找不到指定的文件。 Code: -32603 [object Object]

karthiknadig commented 2 months ago

@CoderCore please provide logs from output > autopep8.

CoderCore commented 2 months ago

@CoderCore please provide logs from output > autopep8.

无标题 The above is

CoderCore commented 2 months ago

@CoderCore please provide logs from output > autopep8.

Or do you need another LOG, how can I get it?

karthiknadig commented 2 months ago

That is the log. Can you copy paste the whole content? also please share what you have in settings.json.

CoderCore commented 2 months ago

I found the reason....

This is settings.json

{ "autopep8.path": [ "--max-line-length=1024" ], "[python]": { "editor.formatOnSave": true, "editor.defaultFormatter": "ms-python.autopep8", }, "[vue]": { "editor.defaultFormatter": "Vue.volar" }, "fittencode.languagePreference.displayPreference": "zh-cn", "fittencode.languagePreference.commentPreference": "zh-cn", "workbench.startupEditor": "none", "window.zoomLevel": 3, "workbench.settings.applyToAllProfiles": [ "window.zoomLevel" ], "python.experiments.optInto": [], "flake8.args": [ "--max-line-length=1024", "--ignore=E402,F841,F401,E302,E305", ], "security.workspace.trust.untrustedFiles": "open" }

after remove

"autopep8.path": [ "--max-line-length=1024" ],

it run ok

CoderCore commented 2 months ago

what's the right method to set --max-line-length parm now?

maybe i set --max-line-length parm befrom vscode update, later it became wrong...

karthiknadig commented 2 months ago

"autopep8.args": [ "--max-line-length=1024" ]

CoderCore commented 2 months ago

Thanks!!!