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

Ternary conditionals within F Strings Raise IndexError #1215

Open
CS-Account opened this issue Mar 20, 2024 · 0 comments
Open

Ternary conditionals within F Strings Raise IndexError #1215

CS-Account opened this issue Mar 20, 2024 · 0 comments

Comments

@CS-Account
Copy link

CS-Account commented Mar 20, 2024

Example:

yapf_example.py contents:

print(f"This Fails, but is legal: {"Should be fine" if True else "But it's not"}")

Running Yapf:
python -m yapf yapf_example.py

Result:

...
    return '{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)
                                 ~~~~~~^^^
IndexError: tuple index out of range

Yapf version
0.40.2 (Latest at time of writing)

This might be related to PEP 701, but if memory serves, this has been an issue since before 3.12.

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