Skip to content

Commit 53696d1

Browse files
authored
Merge branch 'main' into fix-lineprofiler
2 parents 1b13456 + 309ec58 commit 53696d1

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

codeflash/api/aiservice.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import annotations
22

3-
import time
4-
53
import json
64
import os
75
import platform
6+
import time
87
from typing import TYPE_CHECKING, Any
98

109
import requests
@@ -122,7 +121,7 @@ def optimize_python_code(
122121
logger.info(f"Generated {len(optimizations_json)} candidates.")
123122
console.rule()
124123
end_time = time.perf_counter()
125-
logger.debug(f"Optimization took {end_time - start_time:.2f} seconds.")
124+
logger.debug(f"Generating optimizations took {end_time - start_time:.2f} seconds.")
126125
return [
127126
OptimizedCandidate(
128127
source_code=opt["source_code"],
@@ -177,7 +176,7 @@ def optimize_python_code_line_profiler(
177176

178177
logger.info("Generating optimized candidates…")
179178
console.rule()
180-
if line_profiler_results=="":
179+
if line_profiler_results == "":
181180
logger.info("No LineProfiler results were provided, Skipping optimization.")
182181
console.rule()
183182
return []
@@ -209,7 +208,6 @@ def optimize_python_code_line_profiler(
209208
console.rule()
210209
return []
211210

212-
213211
def log_results(
214212
self,
215213
function_trace_id: str,
@@ -272,9 +270,10 @@ def generate_regression_tests(
272270
- Dict[str, str] | None: The generated regression tests and instrumented tests, or None if an error occurred.
273271
274272
"""
275-
assert test_framework in ["pytest", "unittest"], (
276-
f"Invalid test framework, got {test_framework} but expected 'pytest' or 'unittest'"
277-
)
273+
assert test_framework in [
274+
"pytest",
275+
"unittest",
276+
], f"Invalid test framework, got {test_framework} but expected 'pytest' or 'unittest'"
278277
payload = {
279278
"source_code_being_tested": source_code_being_tested,
280279
"function_to_optimize": function_to_optimize,

codeflash/cli_cmds/cmd_init.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def collect_setup_info() -> SetupInfo:
239239
else:
240240
apologize_and_exit()
241241
else:
242-
tests_root = Path(curdir) / Path(cast(str, tests_root_answer))
242+
tests_root = Path(curdir) / Path(cast("str", tests_root_answer))
243243
tests_root = tests_root.relative_to(curdir)
244244
ph("cli-tests-root-provided")
245245

@@ -302,7 +302,7 @@ def collect_setup_info() -> SetupInfo:
302302
elif benchmarks_answer == no_benchmarks_option:
303303
benchmarks_root = None
304304
else:
305-
benchmarks_root = tests_root / Path(cast(str, benchmarks_answer))
305+
benchmarks_root = tests_root / Path(cast("str", benchmarks_answer))
306306

307307
# TODO: Implement other benchmark framework options
308308
# if benchmarks_root:
@@ -354,9 +354,9 @@ def collect_setup_info() -> SetupInfo:
354354
module_root=str(module_root),
355355
tests_root=str(tests_root),
356356
benchmarks_root=str(benchmarks_root) if benchmarks_root else None,
357-
test_framework=cast(str, test_framework),
357+
test_framework=cast("str", test_framework),
358358
ignore_paths=ignore_paths,
359-
formatter=cast(str, formatter),
359+
formatter=cast("str", formatter),
360360
git_remote=str(git_remote),
361361
)
362362

@@ -466,7 +466,7 @@ def check_for_toml_or_setup_file() -> str | None:
466466
click.echo("⏩️ Skipping pyproject.toml creation.")
467467
apologize_and_exit()
468468
click.echo()
469-
return cast(str, project_name)
469+
return cast("str", project_name)
470470

471471

472472
def install_github_actions(override_formatter_check: bool = False) -> None:
@@ -852,7 +852,7 @@ def enter_api_key_and_save_to_rc() -> None:
852852

853853

854854
def create_bubble_sort_file_and_test(args: Namespace) -> tuple[str, str]:
855-
bubble_sort_content = """def sorter(arr):
855+
bubble_sort_content = """def sorter(arr: list[int] | list[float]) -> list[int] | list[float]:
856856
for i in range(len(arr)):
857857
for j in range(len(arr) - 1):
858858
if arr[j] > arr[j + 1]:

0 commit comments

Comments
 (0)