pre_commit_hooks/end_of_file_fixer.py: remove unnecessary check for empty file

This commit is contained in:
Jeffrey 'jf' Lim 2022-05-11 18:43:47 +08:00
parent 974bb4de56
commit 67b1980f3e
No known key found for this signature in database
GPG key ID: 490E7F256E67B497

View file

@ -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')