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

Support 3.12 feature: PEP 695 Type Parameter Syntax #1170

Open
joshlam123 opened this issue Oct 12, 2023 · 0 comments
Open

Support 3.12 feature: PEP 695 Type Parameter Syntax #1170

joshlam123 opened this issue Oct 12, 2023 · 0 comments

Comments

@joshlam123
Copy link

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
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