Add new flake8 rules to do some meaningful corrections
SUMMARY
We have a select list of flake8 rules that we enforce. Every now and then, I believe we should revisit those. Here is my method here: I remove all our select = rules and run flake8. Then I create an ignore = list and add the rules I don't care about or find annoying. I iterate on those until every discovery is something that I really care about and want to fix.
Here are the things I'm adding here:
- E265 block comment should start with #
- E266 too many leading # for block comment
- F541 fstring placeholder
- W605 invalid escape sequence
- E722 bare except
- F822 undefined name
- F523 format has unused arguments
- W291 trailing whitespace
- F405 variable may be undefined
The thing I really wanted to do was find a rule that would find the re-definition of a class inside of https://github.com/ansible/awx/pull/12875, but I failed to do that. However, this found a good handful of cases where we had a reference to a variable that doesn't exist.
This fixes at least a few real bugs where an error message will not render correctly, but I'm guessing that no one hit those errors that that's why we don't otherwise know about these.
ISSUE TYPE
- Bug, Docs Fix or other nominal change
COMPONENT NAME
- API
ADDITIONAL INFORMATION
I will keep this as draft for a while, and will probably block merging until other major feature branches have landed.