Open
Description
Issue
In PEP-695, running under 3.12 will cause exceptions in YAPF. For example the following two lines of code for testing:
type Testing = dict[int | str]
type Testing2 = dict[str: int]
The following error message happens:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/josh.lam/.local/yapf/yapf/__main__.py", line 18, in <module>
yapf.run_main()
File "/home/josh.lam/local/.pyenv/versions/3.12.0/lib/python3.12/site-packages/yapf/__init__.py", line 377, in run_main
sys.exit(main(sys.argv))
^^^^^^^^^^^^^^
File "/home/josh.lam/.local/.pyenv/versions/3.12.0/lib/python3.12/site-packages/yapf/__init__.py", line 136, in main
changed = FormatFiles(
^^^^^^^^^^^^
File "/home/josh.lam/.local/.pyenv/versions/3.12.0/lib/python3.12/site-packages/yapf/__init__.py", line 214, in FormatFiles
changed |= _FormatFile(filename, lines, style_config, no_local_style,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/josh.lam/local/.pyenv/versions/3.12.0/lib/python3.12/site-packages/yapf/__init__.py", line 248, in _FormatFile
raise errors.YapfError(errors.FormatErrorMsg(e))
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/josh.lam/.local/.pyenv/versions/3.12.0/lib/python3.12/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
>>>>> In file /home/josh.lam/testing.py <<<<<
1,2d0
< type Testing = dict[int | str]
< type Testing2 = dict[str: int]
Other Info
Yapf Configuration file:
[style]
based_on_style = google
column_limit = 120
split_before_arithmetic_operator = true
Metadata
Metadata
Assignees
Labels
No labels