Skip to content

Commit cd47a08

Browse files
committed
fixed formatting issues
1 parent df46f71 commit cd47a08

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

pre_commit_hooks/requirements_txt_fixer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def is_complete(self) -> bool:
6060
)
6161

6262
def contains_version_specifier(self) -> bool:
63-
return bool(self.VERSION_SPECIFIED.match(self.value))
63+
return (
64+
self.value is not None and
65+
bool(self.VERSION_SPECIFIED.match(self.value))
66+
)
6467

6568
def append_value(self, value: bytes) -> None:
6669
if self.value is not None:
@@ -171,7 +174,9 @@ def main(argv: Sequence[str] | None = None) -> int:
171174

172175
for arg in args.filenames:
173176
with open(arg, 'rb+') as file_obj:
174-
ret_for_file = fix_requirements(file_obj, args.fail_without_version)
177+
ret_for_file = fix_requirements(
178+
file_obj, args.fail_without_version,
179+
)
175180

176181
if ret_for_file:
177182
print(f'Error in file {arg}')

tests/requirements_txt_fixer_test.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,24 @@
120120
b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n',
121121
),
122122
(b'bar\nfoo\n', ['--fail-without-version'], FAIL, b'bar\nfoo\n'),
123-
(b'bar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\nfoo==1.1a\n'),
124-
(b'#test\nbar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'#test\nbar==1.0\nfoo==1.1a\n'),
125-
(b'bar==1.0\n#test\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\n#test\nfoo==1.1a\n'),
123+
(
124+
b'bar==1.0\nfoo==1.1a\n',
125+
['--fail-without-version'],
126+
PASS,
127+
b'bar==1.0\nfoo==1.1a\n',
128+
),
129+
(
130+
b'#test\nbar==1.0\nfoo==1.1a\n',
131+
['--fail-without-version'],
132+
PASS,
133+
b'#test\nbar==1.0\nfoo==1.1a\n',
134+
),
135+
(
136+
b'bar==1.0\n#test\nfoo==1.1a\n',
137+
['--fail-without-version'],
138+
PASS,
139+
b'bar==1.0\n#test\nfoo==1.1a\n',
140+
),
126141
),
127142
)
128143
def test_integration(input_s, argv, expected_retval, output, tmpdir):

0 commit comments

Comments
 (0)