mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-17 22:40:11 -06:00
Merge pull request #1683 from pre-commit/textwrap_indent
use textwrap.indent instead of _indent
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
import yaml
|
||||
|
||||
@@ -6,11 +7,6 @@ from pre_commit.clientlib import load_config
|
||||
from pre_commit.util import yaml_load
|
||||
|
||||
|
||||
def _indent(s: str) -> str:
|
||||
lines = s.splitlines(True)
|
||||
return ''.join(' ' * 4 + line if line.strip() else line for line in lines)
|
||||
|
||||
|
||||
def _is_header_line(line: str) -> bool:
|
||||
return line.startswith(('#', '---')) or not line.strip()
|
||||
|
||||
@@ -34,7 +30,7 @@ def _migrate_map(contents: str) -> str:
|
||||
yaml_load(trial_contents)
|
||||
contents = trial_contents
|
||||
except yaml.YAMLError:
|
||||
contents = f'{header}repos:\n{_indent(rest)}'
|
||||
contents = f'{header}repos:\n{textwrap.indent(rest, " " * 4)}'
|
||||
|
||||
return contents
|
||||
|
||||
|
||||
Reference in New Issue
Block a user