-
-
Notifications
You must be signed in to change notification settings - Fork 709
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
Attempt to add fixing of BOMs #522
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.
I think we should deprecate check-byte-order-marker, but we cannot remove it in this PR
3de1539
to
5a7ca4e
Compare
Sorry for the churn, I don't write much Python |
c8ef07f
to
f3cee4e
Compare
Okay, I think this is good now. |
Would you mind adding a hacktoberfest-accepted label to this PR? I didn't make this change specifically for hacktoberfest, I need it, but I am participating in hacktoberfest. Thanks! |
yeah sorry I've been slow about this -- I'll take a look when I get the chance 👍 |
f3cee4e
to
d18bd5b
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.
@@ -17,8 +17,8 @@ | |||
language: python | |||
types: [python] | |||
- id: check-byte-order-marker | |||
name: Check for byte-order marker | |||
description: Forbid files which have a UTF-8 byte-order marker | |||
name: 'check BOM - deprecated: use fix-byte-order-marker' |
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 shortened the name here so it doesn't wrap -- I should probably add a test for this
@@ -131,6 +131,12 @@ | |||
entry: file-contents-sorter | |||
language: python | |||
files: '^$' | |||
- id: fix-byte-order-marker |
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 renamed this to fix-byte-order-marker
so it's more clear what it does
|
||
def main(argv: Optional[Sequence[str]] = None) -> int: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('filenames', nargs='*', help='Filenames to check') |
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 removed the --fix=no
-- I'd rather have formatters-only
|
||
for filename in args.filenames: | ||
with open(filename, 'rb') as f_b: | ||
bts = f_b.read(3) |
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.
there was a leaking file descriptor here, I fixed that
I'm attempting to add automatic fixing of BOMs