3434 from argparse import Namespace
3535
3636CODEFLASH_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
128128def 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
155155def 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
567567def 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
587593def 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
638644def 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