mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
style: Run linter on clean_metadata.py
This commit is contained in:
parent
58f4db4e52
commit
ebfce5b0f2
1 changed files with 24 additions and 20 deletions
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
|
||||||
import re
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import json5
|
import json5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_block_lines(lines, key_to_remove):
|
def find_block_lines(lines, key_to_remove):
|
||||||
"""Finds the start and end line indices for a top-level key's block."""
|
"""Finds the start and end line indices for a top-level key's block."""
|
||||||
start_line_idx = -1
|
start_line_idx = -1
|
||||||
|
@ -45,7 +44,9 @@ def find_block_lines(lines, key_to_remove):
|
||||||
break
|
break
|
||||||
|
|
||||||
if start_line_idx == -1:
|
if start_line_idx == -1:
|
||||||
print(f"Warning: Could not reliably find start line for '{key_to_remove}'. Skipping removal.")
|
print(
|
||||||
|
f"Warning: Could not reliably find start line for '{key_to_remove}'. Skipping removal."
|
||||||
|
)
|
||||||
return None, None # Key block start not found clearly
|
return None, None # Key block start not found clearly
|
||||||
|
|
||||||
brace_level = 0
|
brace_level = 0
|
||||||
|
@ -65,17 +66,17 @@ def find_block_lines(lines, key_to_remove):
|
||||||
# Check if preceded by an odd number of backslashes (escaped quote)
|
# Check if preceded by an odd number of backslashes (escaped quote)
|
||||||
backslashes = 0
|
backslashes = 0
|
||||||
temp_idx = char_idx - 1
|
temp_idx = char_idx - 1
|
||||||
while temp_idx >= 0 and line[temp_idx] == '\\':
|
while temp_idx >= 0 and line[temp_idx] == "\\":
|
||||||
backslashes += 1
|
backslashes += 1
|
||||||
temp_idx -= 1
|
temp_idx -= 1
|
||||||
if backslashes % 2 == 0:
|
if backslashes % 2 == 0:
|
||||||
in_string = not in_string
|
in_string = not in_string
|
||||||
|
|
||||||
if not in_string:
|
if not in_string:
|
||||||
if char == '{':
|
if char == "{":
|
||||||
brace_level += 1
|
brace_level += 1
|
||||||
block_started = True # Mark that we've entered the block
|
block_started = True # Mark that we've entered the block
|
||||||
elif char == '}':
|
elif char == "}":
|
||||||
brace_level -= 1
|
brace_level -= 1
|
||||||
|
|
||||||
# Check if the block ends *after* processing the entire line
|
# Check if the block ends *after* processing the entire line
|
||||||
|
@ -84,7 +85,10 @@ def find_block_lines(lines, key_to_remove):
|
||||||
break
|
break
|
||||||
|
|
||||||
if end_line_idx == -1:
|
if end_line_idx == -1:
|
||||||
print(f"Warning: Could not find end of block for '{key_to_remove}' starting at line {start_line_idx+1}. Skipping removal.")
|
print(
|
||||||
|
f"Warning: Could not find end of block for '{key_to_remove}' starting at line"
|
||||||
|
f" {start_line_idx+1}. Skipping removal."
|
||||||
|
)
|
||||||
return None, None # Block end not found
|
return None, None # Block end not found
|
||||||
|
|
||||||
return start_line_idx, end_line_idx
|
return start_line_idx, end_line_idx
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue