-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add support of ignore comment on the top of the file #291
Conversation
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.
Thanks for contributing!
README.md
Outdated
@@ -127,6 +127,11 @@ options: | |||
-s, --stdout print changed text to stdout. defaults to true when formatting stdin, or to false otherwise | |||
``` | |||
|
|||
To ignore the file, you can also add a comment to the top of the file: | |||
```python | |||
# autoflake: ignore |
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.
can you make it skip_file
instead?
It's more explicit. ignore
can be a bit vague (is it ignoring the next line? the whole file?)
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.
Replaced with skip_file
, thank you!
autoflake.py
Outdated
@@ -904,6 +906,9 @@ def fix_code( | |||
if not source: | |||
return source | |||
|
|||
if source.lstrip().startswith(IGNORE_COMMENT): |
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.
can you please make sure this works with shebangs too?
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.
sorry, what do you mean by shebangs?
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.
Something like:
#!/usr/bin/env python3
# autoflake: skip_file
...
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.
Done, thank you!
3f2ec11
to
ba134f9
Compare
ba134f9
to
adeed89
Compare
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.
Thanks for contributing!
Autoflake can now ignore files with the
# autoflake: ignore
comment on top.Closes #97