mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #1684 from pre-commit/migrate_config_less_work
only perform migrate_config parsing if it is a list
This commit is contained in:
commit
c972205214
1 changed files with 10 additions and 10 deletions
|
|
@ -12,6 +12,7 @@ def _is_header_line(line: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def _migrate_map(contents: str) -> str:
|
def _migrate_map(contents: str) -> str:
|
||||||
|
if isinstance(yaml_load(contents), list):
|
||||||
# Find the first non-header line
|
# Find the first non-header line
|
||||||
lines = contents.splitlines(True)
|
lines = contents.splitlines(True)
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -22,7 +23,6 @@ def _migrate_map(contents: str) -> str:
|
||||||
header = ''.join(lines[:i])
|
header = ''.join(lines[:i])
|
||||||
rest = ''.join(lines[i:])
|
rest = ''.join(lines[i:])
|
||||||
|
|
||||||
if isinstance(yaml_load(contents), list):
|
|
||||||
# If they are using the "default" flow style of yaml, this operation
|
# If they are using the "default" flow style of yaml, this operation
|
||||||
# will yield a valid configuration
|
# will yield a valid configuration
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue