1 parent a6add1c commit 28b2c8eCopy full SHA for 28b2c8e
2 files changed
pre_commit_hooks/requirements_txt_fixer.py
@@ -95,7 +95,7 @@ def fix_requirements(f: IO[bytes]) -> int:
95
requirement.value = b'\n'
96
else:
97
requirement.comments.append(line)
98
- elif line.startswith(b'#') or line.strip() == b'':
+ elif line.lstrip().startswith(b'#') or line.strip() == b'':
99
100
101
requirement.append_value(line)
tests/requirements_txt_fixer_test.py
@@ -30,6 +30,16 @@
30
),
31
(b'#comment\n\nfoo\nbar\n', FAIL, b'#comment\n\nbar\nfoo\n'),
32
(b'#comment\n\nbar\nfoo\n', PASS, b'#comment\n\nbar\nfoo\n'),
33
+ (
34
+ b'foo\n\t#comment with indent\nbar\n',
35
+ FAIL,
36
+ b'\t#comment with indent\nbar\nfoo\n',
37
+ ),
38
39
+ b'bar\n\t#comment with indent\nfoo\n',
40
+ PASS,
41
42
43
(b'\nfoo\nbar\n', FAIL, b'bar\n\nfoo\n'),
44
(b'\nbar\nfoo\n', PASS, b'\nbar\nfoo\n'),
45
(
0 commit comments