Skip to content

Commit ed4f33f

Browse files
committed
♻️ Format code with consistent line wrapping
Improve code readability by unwrapping long lines consistently across multiple files. This change maintains Python's recommended line length while making the codebase more uniform.
1 parent 94a3350 commit ed4f33f

File tree

6 files changed

+10
-26
lines changed

6 files changed

+10
-26
lines changed

aicodebot/coder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ def identify_languages(files):
250250

251251
def is_inside_git_repo():
252252
"""Checks if the current directory is inside a git repository."""
253-
out = subprocess.run(
254-
["git", "rev-parse", "--is-inside-work-tree"], capture_output=True, text=True, check=False
255-
)
253+
out = subprocess.run(["git", "rev-parse", "--is-inside-work-tree"], capture_output=True, text=True, check=False)
256254
if out.returncode == 0:
257255
return True
258256
else:

aicodebot/commands/commit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def commit(response_token_size, yes, skip_pre_commit, files): # noqa: PLR0915
5656
files = unstaged_files
5757
else:
5858
# The list of files to be committed is the same as the list of staged files
59-
console.print(
60-
"The following files have been staged and are ready for commit:\n\t" + "\n\t".join(staged_files)
61-
)
59+
console.print("The following files have been staged and are ready for commit:\n\t" + "\n\t".join(staged_files))
6260

6361
files = staged_files
6462

aicodebot/commands/review.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def review(commit, output_format, response_token_size, files):
5555

5656
else:
5757
# Stream live
58-
console.print(
59-
"Examining the diff and generating the review for the following files:\n\t" + "\n\t".join(files)
60-
)
58+
console.print("Examining the diff and generating the review for the following files:\n\t" + "\n\t".join(files))
6159
with Live(OurMarkdown(f"Talking to {lmm.model_name} via {lmm.provider}"), auto_refresh=True) as live:
6260
model = lmm.model_factory(
6361
response_token_size=response_token_size,

aicodebot/commands/sidekick.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def sidekick(apply, request, no_files, max_file_tokens, files): # noqa: PLR0915
2828
sys.exit(1)
2929

3030
console.print(
31-
Panel(
32-
OurMarkdown("This is an *experimental* feature. We love bug reports 😉", style=console.warning_style)
33-
)
31+
Panel(OurMarkdown("This is an *experimental* feature. We love bug reports 😉", style=console.warning_style))
3432
)
3533

3634
# ----------------- Determine which files to use for context ----------------- #
@@ -99,9 +97,7 @@ def sidekick(apply, request, no_files, max_file_tokens, files): # noqa: PLR0915
9997
# have a record of what they asked for on their terminal
10098
console.print(parsed_human_input)
10199
try:
102-
with Live(
103-
OurMarkdown(f"Sending task to {lmm.model_name} via {lmm.provider}"), auto_refresh=False
104-
) as live:
100+
with Live(OurMarkdown(f"Sending task to {lmm.model_name} via {lmm.provider}"), auto_refresh=False) as live:
105101
llm = lmm.model_factory(
106102
streaming=True,
107103
callbacks=[RichLiveCallbackHandler(live, console.bot_style)],
@@ -121,9 +117,7 @@ def sidekick(apply, request, no_files, max_file_tokens, files): # noqa: PLR0915
121117
code_blocks = markdown.pull_code_blocks()
122118
if code_blocks:
123119
logger.debug(f"Found code blocks: {code_blocks}")
124-
code_block_message = (
125-
f"{len(code_blocks)} code block(s) found, **/copy** to copy to your clipboard."
126-
)
120+
code_block_message = f"{len(code_blocks)} code block(s) found, **/copy** to copy to your clipboard."
127121
console.print(Panel(OurMarkdown(code_block_message)))
128122
chat.code_blocks = markdown.pull_code_blocks()
129123

aicodebot/patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ def rebuild_patch(patch_string): # noqa: PLR0915
134134
first_change_line_index = next(
135135
i for i, line in enumerate(parsed_lines) if line.type in ("addition", "subtraction")
136136
)
137-
parsed_lines.insert(first_change_line_index, Patch.parse_line(f" {source_file_contents[i-1]}"))
137+
parsed_lines.insert(first_change_line_index, Patch.parse_line(f" {source_file_contents[i - 1]}"))
138138

139139
# Add x lines of context after the last change
140140
number_of_subtractions = len([line for line in parsed_lines if line.type == "subtraction"])
141141
start_trailing_context = first_change_line_number + number_of_subtractions
142142
for i in range(start_trailing_context, start_trailing_context + lines_of_context):
143-
parsed_lines.append(Patch.parse_line(f" {source_file_contents[i-1]}"))
143+
parsed_lines.append(Patch.parse_line(f" {source_file_contents[i - 1]}"))
144144

145145
# ------------------------- Rebuild the chunk header ------------------------- #
146146

aicodebot/prompts.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ def generate_files_context(files):
288288
else:
289289
files_context += f"--- START OF FILE: {file_name} {file_info} file, modified {modification_ago} ---\n"
290290
contents = Path(file_name).read_text()
291-
contents_with_line_numbers = "\n".join(
292-
f"{i + 1}: {line}" for i, line in enumerate(contents.split("\n"))
293-
)
291+
contents_with_line_numbers = "\n".join(f"{i + 1}: {line}" for i, line in enumerate(contents.split("\n")))
294292
files_context += contents_with_line_numbers
295293
files_context += f"\n--- END OF FILE: {file_name} ---\n\n"
296294

@@ -451,9 +449,7 @@ def get_prompt(command, structured_output=False):
451449
"commit": PromptTemplate(template=COMMIT_TEMPLATE, input_variables=["diff_context", "languages"]),
452450
"debug": PromptTemplate(template=DEBUG_TEMPLATE, input_variables=["command_output", "languages"]),
453451
"fun_fact": PromptTemplate(template=FUN_FACT_TEMPLATE, input_variables=["topic"]),
454-
"sidekick": PromptTemplate(
455-
template=SIDEKICK_TEMPLATE, input_variables=["task", "context", "languages"]
456-
),
452+
"sidekick": PromptTemplate(template=SIDEKICK_TEMPLATE, input_variables=["task", "context", "languages"]),
457453
}
458454

459455
try:

0 commit comments

Comments
 (0)