Attempt to add fixing of BOMs by jgowdy · Pull Request #522 · pre-commit/pre-commit-hooks
jgowdy
marked this pull request as draft
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
jgowdy
marked this pull request as ready for review
jgowdy
marked this pull request as draft
jgowdy
marked this pull request as ready for review
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!
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - 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' |
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
| entry: file-contents-sorter | ||
| language: python | ||
| files: '^$' | ||
| - id: fix-byte-order-marker |
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') |
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) |
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
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this pull request
pat-s pushed a commit to devxygmbh/ansible-data-science-core that referenced this pull request
