Skip to content

Commit a455566

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4842364 commit a455566

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

pre_commit_hooks/trailing_whitespace_fixer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _process_line(
3030
is_markdown: bool,
3131
chars: bytes | None,
3232
line_num: int,
33-
error_lines: list[int] | None
33+
error_lines: list[int] | None,
3434
) -> bytes:
3535
org_line = line
3636
if line[-2:] == b'\r\n':
@@ -46,7 +46,7 @@ def _process_line(
4646
return line[:-2].rstrip(chars) + b' ' + eol
4747
result = line.rstrip(chars) + eol
4848
if error_lines is not None and org_line != result:
49-
error_lines.append(line_num+1)
49+
error_lines.append(line_num + 1)
5050
return result
5151

5252

@@ -106,8 +106,8 @@ def main(argv: Sequence[str] | None = None) -> int:
106106
error_lines = []
107107
if _fix_file(filename, md, chars, args.check, error_lines):
108108
if args.check:
109-
location = ",".join(map(str, error_lines[:4]))
110-
location += "..." if len(error_lines) > 4 else ""
109+
location = ','.join(map(str, error_lines[:4]))
110+
location += '...' if len(error_lines) > 4 else ''
111111
print(f'Trailing whitespace check failed: {filename} @ {location}')
112112
else:
113113
print(f'Fixing {filename}')

tests/end_of_file_fixer_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_fix_file(input_s, expected_retval, output, options):
4444
options = [options]
4545

4646
file_obj = io.BytesIO(input_s)
47-
ret = fix_file(file_obj, "--check" in [*options])
47+
ret = fix_file(file_obj, '--check' in [*options])
4848
assert file_obj.getvalue() == output
4949
assert ret == expected_retval
5050

tests/trailing_whitespace_fixer_test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@ def test_fixes_trailing_whitespace(input_s, expected, tmpdir):
1818
assert main((str(path),)) == 1
1919
assert path.read() == expected
2020

21+
2122
@pytest.mark.parametrize(
22-
('input_s', 'exit_code', "lines"),
23+
('input_s', 'exit_code', 'lines'),
2324
(
24-
('foo \nbar \n', 1, [1,2]),
25-
('bar\t\nbaz\t\n', 1, [1,2]),
26-
('bar\nbaz\t\n', 1, [2]),
25+
('foo \nbar \n', 1, [1, 2]),
26+
('bar\t\nbaz\t\n', 1, [1, 2]),
27+
('bar\nbaz\t\n', 1, [2]),
2728
),
2829
)
2930
def test_fixes_trailing_whitespace_check_only(capsys, input_s, exit_code, lines, tmpdir):
3031
path = tmpdir.join('file.md')
3132
path.write(input_s)
32-
assert main(('--check', str(path),)) == exit_code
33+
assert main(('--check', str(path))) == exit_code
3334
assert path.read() == input_s
3435
captured = capsys.readouterr()
35-
location = "@ " + ','.join(map(str, lines))
36+
location = '@ ' + ','.join(map(str, lines))
3637
assert location in captured.out
3738

3839

0 commit comments

Comments
 (0)