Skip to content

Commit

Permalink
only perform migrate_config parsing if it is a list
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Nov 6, 2020
1 parent b2207e5 commit b4ab84d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pre_commit/commands/migrate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def _is_header_line(line: str) -> bool:


def _migrate_map(contents: str) -> str:
# Find the first non-header line
lines = contents.splitlines(True)
i = 0
# Only loop on non empty configuration file
while i < len(lines) and _is_header_line(lines[i]):
i += 1
if isinstance(yaml_load(contents), list):
# Find the first non-header line
lines = contents.splitlines(True)
i = 0
# Only loop on non empty configuration file
while i < len(lines) and _is_header_line(lines[i]):
i += 1

header = ''.join(lines[:i])
rest = ''.join(lines[i:])
header = ''.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
# will yield a valid configuration
try:
Expand Down

0 comments on commit b4ab84d

Please sign in to comment.