diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index cf605175..187141bc 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -5,7 +5,6 @@ from typing import IO from typing import Sequence - PASS = 0 FAIL = 1 @@ -45,8 +44,9 @@ def __lt__(self, requirement: Requirement) -> bool: elif requirement.value == b'\n': return False else: - # if 2 requirements have the same name, the one with comments needs to go - # first (so that when removing duplicates, the one with comments is kept) + # if 2 requirements have the same name, the one with comments + # needs to go first (so that when removing duplicates, the one + # with comments is kept) if self.name == requirement.name: return bool(self.comments) > bool(requirement.comments) return self.name < requirement.name diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index 657a61ac..c400be1f 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -69,7 +69,11 @@ b'g<2\n', ), (b'a==1\nb==1\na==1\n', FAIL, b'a==1\nb==1\n'), - (b'a==1\nb==1\n#comment about a\na==1\n', FAIL, b'#comment about a\na==1\nb==1\n'), + ( + b'a==1\nb==1\n#comment about a\na==1\n', + FAIL, + b'#comment about a\na==1\nb==1\n', + ), (b'ocflib\nDjango\nPyMySQL\n', FAIL, b'Django\nocflib\nPyMySQL\n'), ( b'-e git+ssh://git_url@tag#egg=ocflib\nDjango\nPyMySQL\n',