More naturally sort requirements.
diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index 2dec6bf..cc09242 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py
@@ -18,7 +18,10 @@ elif requirement.value == b'\n': return False else: - return self.value < requirement.value + return ( + self.value.partition(b'==') < + requirement.value.partition(b'==') + ) def fix_requirements(f):
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index b135fdf..3eac637 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py
@@ -15,6 +15,7 @@ (b'#comment\n\nbar\nfoo\n', 0, b'#comment\n\nbar\nfoo\n'), (b'\nfoo\nbar\n', 1, b'bar\n\nfoo\n'), (b'\nbar\nfoo\n', 0, b'\nbar\nfoo\n'), + (b'pyramid==1\npyramid-foo==2\n', 0, b'pyramid==1\npyramid-foo==2\n'), )