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

Option to avoid converting overly complex logic into f-strings #176

Open
eli-schwartz opened this issue Apr 9, 2023 · 1 comment
Open

Comments

@eli-schwartz
Copy link

See e.g. asottile/pyupgrade#526

It would be nice to have a configurable tool that allows me to choose what threshold of changes I feel comfortable making -- I want to be able to convert simple, obvious code to f-strings, but not code that I subjectively feel is harder to read, and if in doubt I'd prefer to do nothing and leave that to a manual touch-up. Or even perform and git commit objectively beneficial changes, then run the reformatting tool in a more aggressive mode and eyeball the results for subjective taste.

AFAICT this isn't currently possible with flynt but also hasn't previously come up (as opposed to other projects where it's come up and been rapidly shot down. 😢)

@ikamensh
Copy link
Owner

Thanks for the suggestion. As scope of flynt is just f-strings, I think this idea is appropriate for the project.

I wonder what universal metric you want to use for this. I could imagine some metric like AST graph depth / node count of a f-string, feel free to suggest other complexity metrics. If you have interest to make a PR for a new CLI flag that wouldn't change default behavior, I would be in favor or such a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants