-
Couldn't load subscription status.
- Fork 20
Better handle when acknowledging violations will cause reformat #72
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
Better handle when acknowledging violations will cause reformat #72
Conversation
|
Note: I attempted to move the "--aggressive" logic up a level to the CLI (such that if --aggressive is passed, it would find all included .py files, call down to remove suppressions, call down to suppress, then do the loop.) however, this yielded a lot of difficulties. I will probably re-attempt when I next get a chance work on this (unless you disagree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code easier to understand IMO. Thx!
This is already a pretty big diff. I am opting to leave it as is and will come in later to add a "--remove-current-acknowledgements" arg |
|
Blocked on #73 |
Adding a "--aggressive" flag to
acknowledge-existing-violationsthat will attempt to suppres, then format, then move suppressions back to the correct lines, and format, and repeat until formatting no longer changes the file (max of 10 tries)._lint.lint_cli.pyto_config_constants.py_format.formthelper method for runningblack(decided to leave adding potential "format" command to future PR)_acknowledge_existing_errors.acknowledge_lint_errorsto_acknowledge_existing_errors._suppress_errors_in_filehandle_lines_that_are_now_too_long(this re-uses _suppress_errors_in_file for subsequent runs).Example run:
(starting code)
This contains several errors, so round 1 will suppress those:
Now the line is too long, so when
blackis called, it will break up the line:However, now the suppressions are on the wrong line.
Because the file was reformatted - we attempt again.
We remove the suppressions and re-lint and suppress:
The args line is still too long, so
blackwill again formatAgain, now the suppressions are on the wrong line, but we know it was reformatted, so we attempt again.
And this time,
blackis happy with the output, and so doesn't format and leaves the suppressions on the correct lines.