mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-31 10:36:54 +00:00
pre_commit_hooks/end_of_file_fixer.py: remove unnecessary check for empty file
This commit is contained in:
parent
974bb4de56
commit
67b1980f3e
1 changed files with 3 additions and 2 deletions
|
|
@ -13,9 +13,10 @@ def fix_file(file_obj: IO[bytes]) -> int:
|
|||
file_obj.seek(-1, os.SEEK_END)
|
||||
except OSError:
|
||||
return 0
|
||||
|
||||
last_character = file_obj.read(1)
|
||||
# last_character will be '' for an empty file
|
||||
if last_character not in {b'\n', b'\r'} and last_character != b'':
|
||||
|
||||
if last_character not in {b'\n', b'\r'}:
|
||||
# Needs this seek for windows, otherwise IOError
|
||||
file_obj.seek(0, os.SEEK_END)
|
||||
file_obj.write(b'\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue