Skip to content

Commit

Permalink
Fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vhoulbreque-withings committed Feb 21, 2024
1 parent cd36abd commit 03ffb7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pre_commit_hooks/requirements_txt_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import IO
from typing import Sequence


PASS = 0
FAIL = 1

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/requirements_txt_fixer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 03ffb7e

Please # to comment.