Skip to content

Commit dd7cbb4

Browse files
committed
revert some changes
1 parent 191317b commit dd7cbb4

File tree

5 files changed

+93
-102
lines changed

5 files changed

+93
-102
lines changed

codeflash/api/aiservice.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def make_ai_service_request(
7373
# response.raise_for_status() # Will raise an HTTPError if the HTTP request returned an unsuccessful status code
7474
return response
7575

76-
def optimize_python_code( # noqa: D417
76+
def optimize_python_code(
7777
self,
7878
source_code: str,
7979
dependency_code: str,
@@ -139,7 +139,7 @@ def optimize_python_code( # noqa: D417
139139
console.rule()
140140
return []
141141

142-
def optimize_python_code_line_profiler( # noqa: D417
142+
def optimize_python_code_line_profiler(
143143
self,
144144
source_code: str,
145145
dependency_code: str,
@@ -208,7 +208,7 @@ def optimize_python_code_line_profiler( # noqa: D417
208208
console.rule()
209209
return []
210210

211-
def log_results( # noqa: D417
211+
def log_results(
212212
self,
213213
function_trace_id: str,
214214
speedup_ratio: dict[str, float | None] | None,
@@ -240,7 +240,7 @@ def log_results( # noqa: D417
240240
except requests.exceptions.RequestException as e:
241241
logger.exception(f"Error logging features: {e}")
242242

243-
def generate_regression_tests( # noqa: D417
243+
def generate_regression_tests(
244244
self,
245245
source_code_being_tested: str,
246246
function_to_optimize: FunctionToOptimize,
@@ -307,7 +307,7 @@ def generate_regression_tests( # noqa: D417
307307
error = response.json()["error"]
308308
logger.error(f"Error generating tests: {response.status_code} - {error}")
309309
ph("cli-testgen-error-response", {"response_status_code": response.status_code, "error": error})
310-
return None # noqa: TRY300
310+
return None
311311
except Exception:
312312
logger.error(f"Error generating tests: {response.status_code} - {response.text}")
313313
ph("cli-testgen-error-response", {"response_status_code": response.status_code, "error": response.text})

codeflash/cli_cmds/cmd_init.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from argparse import Namespace
3535

3636
CODEFLASH_LOGO: str = (
37-
f"{LF}" # noqa: ISC003
37+
f"{LF}"
3838
r" _ ___ _ _ " + f"{LF}"
3939
r" | | / __)| | | | " + f"{LF}"
4040
r" ____ ___ _ | | ____ | |__ | | ____ ___ | | _ " + f"{LF}"
@@ -126,8 +126,7 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
126126

127127

128128
def should_modify_pyproject_toml() -> bool:
129-
"""Check if the current directory contains a valid pyproject.toml file with codeflash config.
130-
129+
"""Check if the current directory contains a valid pyproject.toml file with codeflash config
131130
If it does, ask the user if they want to re-configure it.
132131
"""
133132
from rich.prompt import Confirm
@@ -145,11 +144,12 @@ def should_modify_pyproject_toml() -> bool:
145144
if "tests_root" not in config or config["tests_root"] is None or not Path(config["tests_root"]).is_dir():
146145
return True
147146

148-
return Confirm.ask(
147+
create_toml = Confirm.ask(
149148
"✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?",
150149
default=False,
151150
show_default=True,
152151
)
152+
return create_toml
153153

154154

155155
def collect_setup_info() -> SetupInfo:
@@ -469,7 +469,7 @@ def check_for_toml_or_setup_file() -> str | None:
469469
return cast("str", project_name)
470470

471471

472-
def install_github_actions(override_formatter_check: bool = False) -> None: # noqa: FBT001, FBT002
472+
def install_github_actions(override_formatter_check: bool = False) -> None:
473473
try:
474474
config, config_file_path = parse_config_file(override_formatter_check=override_formatter_check)
475475

@@ -566,22 +566,28 @@ def install_github_actions(override_formatter_check: bool = False) -> None: # n
566566

567567
def determine_dependency_manager(pyproject_data: dict[str, Any]) -> DependencyManager:
568568
"""Determine which dependency manager is being used based on pyproject.toml contents."""
569-
result = DependencyManager.UNKNOWN
570569
if (Path.cwd() / "poetry.lock").exists():
571-
result = DependencyManager.POETRY
572-
elif (Path.cwd() / "uv.lock").exists():
573-
result = DependencyManager.UV
574-
elif "tool" not in pyproject_data:
575-
result = DependencyManager.PIP
576-
else:
577-
tool_section = pyproject_data["tool"]
578-
if "poetry" in tool_section:
579-
result = DependencyManager.POETRY
580-
elif any(key.startswith("uv") for key in tool_section):
581-
result = DependencyManager.UV
582-
elif "pip" in tool_section or "setuptools" in tool_section:
583-
result = DependencyManager.PIP
584-
return result
570+
return DependencyManager.POETRY
571+
if (Path.cwd() / "uv.lock").exists():
572+
return DependencyManager.UV
573+
if "tool" not in pyproject_data:
574+
return DependencyManager.PIP
575+
576+
tool_section = pyproject_data["tool"]
577+
578+
# Check for poetry
579+
if "poetry" in tool_section:
580+
return DependencyManager.POETRY
581+
582+
# Check for uv
583+
if any(key.startswith("uv") for key in tool_section):
584+
return DependencyManager.UV
585+
586+
# Look for pip-specific markers
587+
if "pip" in tool_section or "setuptools" in tool_section:
588+
return DependencyManager.PIP
589+
590+
return DependencyManager.UNKNOWN
585591

586592

587593
def get_codeflash_github_action_command(dep_manager: DependencyManager) -> str:
@@ -636,10 +642,7 @@ def get_github_action_working_directory(toml_path: Path, git_root: Path) -> str:
636642

637643

638644
def customize_codeflash_yaml_content(
639-
optimize_yml_content: str,
640-
config: tuple[dict[str, Any], Path],
641-
git_root: Path,
642-
benchmark_mode: bool = False, # noqa: FBT001, FBT002
645+
optimize_yml_content: str, config: tuple[dict[str, Any], Path], git_root: Path, benchmark_mode: bool = False
643646
) -> str:
644647
module_path = str(Path(config["module_root"]).relative_to(git_root) / "**")
645648
optimize_yml_content = optimize_yml_content.replace("{{ codeflash_module_path }}", module_path)
@@ -875,7 +878,7 @@ def test_sort(self):
875878
input = list(reversed(range(100)))
876879
output = sorter(input)
877880
self.assertEqual(output, list(range(100)))
878-
""" # noqa: PTH119
881+
"""
879882
elif args.test_framework == "pytest":
880883
bubble_sort_test_content = f"""from {Path(args.module_root).name}.bubble_sort import sorter
881884
@@ -956,8 +959,10 @@ def ask_for_telemetry() -> bool:
956959
"""Prompt the user to enable or disable telemetry."""
957960
from rich.prompt import Confirm
958961

959-
return Confirm.ask(
962+
enable_telemetry = Confirm.ask(
960963
"⚡️ Would you like to enable telemetry to help us improve the Codeflash experience?",
961964
default=True,
962965
show_default=True,
963966
)
967+
968+
return enable_telemetry

0 commit comments

Comments
 (0)