Skip to content

Commit

Permalink
Merge pull request #1684 from pre-commit/migrate_config_less_work
Browse files Browse the repository at this point in the history
only perform migrate_config parsing if it is a list
  • Loading branch information
asottile committed Nov 6, 2020
2 parents 1975c05 + b4ab84d commit c972205
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pre_commit/commands/migrate_config.py
Expand Up @@ -12,17 +12,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 c972205

Please sign in to comment.