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

Rewrite f"x={x!r}" to f"{x=} on Python 3.8+ #829

Open
Zac-HD opened this issue Jun 3, 2023 · 0 comments
Open

Rewrite f"x={x!r}" to f"{x=} on Python 3.8+ #829

Zac-HD opened this issue Jun 3, 2023 · 0 comments

Comments

@Zac-HD
Copy link

Zac-HD commented Jun 3, 2023

It would be lovely to have this built into pyupgrade!

For HypothesisWorks/hypothesis#3657 I did this with a regex replacement r"(.+?)=\{\1!r\}" -> r"\{\1=\}", which in principle is super inefficient but in practice worked just fine. Applying it only to f-string tokens would be a nice precision and safety improvement, which I'd appreciate as part of my autoformatting stack 🙂

@Zac-HD Zac-HD changed the title Rewrite f"x={x!r}" to f"{x=}` on Python 3.8+ Rewrite f"x={x!r}" to f"{x=} on Python 3.8+ Jun 3, 2023
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