-
Notifications
You must be signed in to change notification settings - Fork 10
Remove imports and variables #6
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
Conversation
pyformat.py
Outdated
| help='use more aggressive formatters') | ||
| parser.add_argument('--remove-all-unused-imports', action='store_true', | ||
| help='remove all unused imports, not just standard library \ | ||
| (requires "aggresive")') |
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.
I try to avoid escaped newlines. Could you format that strings the way it is done below?
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.
It was just to reduce the line length - I've used another solution (which I now see you've used in other places).
| parser.add_argument('--remove-all-unused-imports', action='store_true', | ||
| help='remove all unused imports, not just standard library \ | ||
| (requires "aggresive")') | ||
| parser.add_argument('--remove-unused-variables', action='store_true', |
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.
I think it would be good to add a check to make sure that --aggressive is used. Otherwise, the user might wonder why it isn't working. Maybe something like:
if args.remove_unused_variables and not args.aggressive:
parser.error('--remove-unused-variables requires --aggressive')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.
Yes indeed - good call.
|
Updated, and spelling mistakes corrected. |
|
Thanks! |
|
Thanks for merging this, @myint. When do you release to PyPI? |
|
Brillo. Thank you and happy New Year. |
pyformatdoes a lovely job of wrappingautoflaketo make changes recommended by a linter.autoflakeallows unused imports and variables to be removed, but the required flags aren't passed bypyformat.This adds the ability, in "aggressive" mode, to request that all unused imports (not just standard library) and variables be removed (by
autoflake).