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

Yapf not formatting python generic #1198

Open
Selvaganapathi-A opened this issue Feb 4, 2024 · 0 comments
Open

Yapf not formatting python generic #1198

Selvaganapathi-A opened this issue Feb 4, 2024 · 0 comments

Comments

@Selvaganapathi-A
Copy link

code to reproduce

class Node[T]:
    def __init__(self, value: T) -> None:
        self.value = value

log
'''
2024-02-04 20:55:56.160 [info] [Trace - 8:55:56 PM] Sending request 'textDocument/formatting - (7)'.
2024-02-04 20:55:56.163 [info] [Trace - 8:55:56 PM] Received notification 'window/logMessage'.
2024-02-04 20:55:56.163 [info] d:\platipus.venv\Scripts\python.exe -m yapf
2024-02-04 20:55:56.164 [info] [Trace - 8:55:56 PM] Received notification 'window/logMessage'.
2024-02-04 20:55:56.164 [info] CWD Linter: d:\platipus
2024-02-04 20:55:56.188 [info] [Trace - 8:55:56 PM] Received notification 'window/logMessage'.
2024-02-04 20:55:56.189 [info] [Error - 8:55:56 PM] Traceback (most recent call last):
File "d:\platipus.venv\Lib\site-packages\yapf\yapflib\yapf_api.py", line 198, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf\pytree\pytree_utils.py", line 113, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf_third_party_ylib2to3\pgen2\driver.py", line 188, in parse_string
return self.parse_tokens(tokens, debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf_third_party_ylib2to3\pgen2\driver.py", line 157, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf_third_party_ylib2to3\pgen2\parse.py", line 230, in addtoken
return self._addtoken(ilabel, type, value, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf_third_party_ylib2to3\pgen2\parse.py", line 313, in _addtoken
raise ParseError('bad input', type, value, context)
yapf_third_party._ylib2to3.pgen2.parse.ParseError: bad input: type=9, value='[', context=('', (4, 10))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\platipus.venv\Lib\site-packages\yapf_init_.py", line 116, in main
reformatted_source, _ = yapf_api.FormatCode(
^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf\yapflib\yapf_api.py", line 201, in FormatCode
raise errors.YapfError(errors.FormatErrorMsg(e))
^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf\yapflib\errors.py", line 37, in FormatErrorMsg
return '{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)
~~~~~~^^^
IndexError: tuple index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\Tesla.vscode\extensions\eeyore.yapf-2023.12.104100706\bundled\tool\lsp_server.py", line 367, in _run_tool_on_document
result = utils.run_module(
^^^^^^^^^^^^^^^^^
File "c:\Users\Tesla.vscode\extensions\eeyore.yapf-2023.12.104100706\bundled\tool\lsp_utils.py", line 202, in run_module
return run_module(module, argv, use_stdin, source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Tesla.vscode\extensions\eeyore.yapf-2023.12.104100706\bundled\tool\lsp_utils.py", line 189, in run_module
runpy.run_module(module, run_name="main")
File "", line 229, in run_module
File "", line 88, in run_code
File "d:\platipus.venv\Lib\site-packages\yapf_main
.py", line 18, in
yapf.run_main()
File "d:\platipus.venv\Lib\site-packages\yapf_init
.py", line 380, in run_main
sys.exit(main(sys.argv))
^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf_init
.py", line 124, in main
raise errors.YapfError(errors.FormatErrorMsg(e))
^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\platipus.venv\Lib\site-packages\yapf\yapflib\errors.py", line 37, in FormatErrorMsg
return '{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)
~~~~~~^^^
IndexError: tuple index out of range

2024-02-04 20:55:56.190 [info] [Trace - 8:55:56 PM] Received notification 'window/showMessage'.
2024-02-04 20:55:56.191 [info] [Trace - 8:55:56 PM] Received response 'textDocument/formatting - (7)' in 31ms. Request failed: IndexError: tuple index out of range (-32603).
2024-02-04 20:55:56.192 [info] [Error - 8:55:56 PM] Request textDocument/formatting failed.
2024-02-04 20:55:56.192 [info] Message: IndexError: tuple index out of range
Code: -32603
'''

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

1 participant