flake8-simplify
flake8-simplify copied to clipboard
[Question] Automatically fix yoda-conditions
Hi, first of all, thanks for the great tool. I have several apps with a lot of yoda-conditions and I wanted to see if there is a way to make it automatically fix. Is it possible to implement this?
Thanks!
Thank you!
I was actually wondering about this several times myself. In principle, I would have the necessary information to fix things. However, this is currently not possible with Flake8: https://github.com/PyCQA/flake8/issues/545
In the past, when I had to do a lot of changes to fix such an issue, I did it gradually:
- Disable the rule
- Fix the rule whenever I see it
- Once all are fixed: Enable the rule
Depending on the project size, this can take a while.
I'll look more into https://github.com/PyCQA/autoflake, but it seems like there's no plugin interface.
There is actually a simple combination of tools that might do the job :
- Black cover formatter
- Find the joda conditions with flake8-simplify
- Use simple string search+replace
If you find something that works well, please share it here!