mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-08 04:34:16 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
3310eb9734
commit
57328f538e
2 changed files with 4 additions and 4 deletions
|
|
@ -61,7 +61,7 @@ def fix_strings(filename: str, replace_single_quotes: bool = False) -> int:
|
||||||
fstring_depth -= 1
|
fstring_depth -= 1
|
||||||
elif fstring_depth == 0 and token_type == tokenize.STRING:
|
elif fstring_depth == 0 and token_type == tokenize.STRING:
|
||||||
new_text = handle_match(
|
new_text = handle_match(
|
||||||
token_text, replace_single_quotes=replace_single_quotes
|
token_text, replace_single_quotes=replace_single_quotes,
|
||||||
)
|
)
|
||||||
splitcontents[
|
splitcontents[
|
||||||
line_offsets[srow] + scol:
|
line_offsets[srow] + scol:
|
||||||
|
|
@ -92,7 +92,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
|
|
||||||
for filename in args.filenames:
|
for filename in args.filenames:
|
||||||
return_value = fix_strings(
|
return_value = fix_strings(
|
||||||
filename, replace_single_quotes=args.replace_single_quotes
|
filename, replace_single_quotes=args.replace_single_quotes,
|
||||||
)
|
)
|
||||||
if return_value != 0:
|
if return_value != 0:
|
||||||
print(f'Fixing strings in {filename}')
|
print(f'Fixing strings in {filename}')
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ TESTS = (
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
('input_s', 'output', 'reversed_case', 'expected_retval'), TESTS
|
('input_s', 'output', 'reversed_case', 'expected_retval'), TESTS,
|
||||||
)
|
)
|
||||||
def test_rewrite(input_s, output, reversed_case, expected_retval, tmpdir):
|
def test_rewrite(input_s, output, reversed_case, expected_retval, tmpdir):
|
||||||
path = tmpdir.join('file.py')
|
path = tmpdir.join('file.py')
|
||||||
|
|
@ -79,7 +79,7 @@ def test_rewrite(input_s, output, reversed_case, expected_retval, tmpdir):
|
||||||
|
|
||||||
argv = [str(path)]
|
argv = [str(path)]
|
||||||
if reversed_case:
|
if reversed_case:
|
||||||
argv.append("--replace-single-quotes")
|
argv.append('--replace-single-quotes')
|
||||||
retval = main(argv)
|
retval = main(argv)
|
||||||
|
|
||||||
assert path.read() == output
|
assert path.read() == output
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue