Fix requirements-txt-fixer for comments at end of file
diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py
index ffabf2a..1ee6fac 100644
--- a/pre_commit_hooks/requirements_txt_fixer.py
+++ b/pre_commit_hooks/requirements_txt_fixer.py
@@ -63,9 +63,16 @@
else:
requirement.value = line
+ # if a file ends in a comment, preserve it at the end
+ if requirements[-1].value is None:
+ rest = requirements.pop().comments
+ else:
+ rest = []
+
for requirement in sorted(requirements):
after.extend(requirement.comments)
after.append(requirement.value)
+ after.extend(rest)
after_string = b''.join(after)