3434 from argparse import Namespace
3535
3636CODEFLASH_LOGO : str = (
37- f"{ LF } "
37+ f"{ LF } " # noqa: ISC003
3838 r" _ ___ _ _ " + f"{ LF } "
3939 r" | | / __)| | | | " + f"{ LF } "
4040 r" ____ ___ _ | | ____ | |__ | | ____ ___ | | _ " + f"{ LF } "
@@ -126,7 +126,8 @@ 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
129+ """Check if the current directory contains a valid pyproject.toml file with codeflash config.
130+
130131 If it does, ask the user if they want to re-configure it.
131132 """
132133 from rich .prompt import Confirm
@@ -144,12 +145,11 @@ def should_modify_pyproject_toml() -> bool:
144145 if "tests_root" not in config or config ["tests_root" ] is None or not Path (config ["tests_root" ]).is_dir ():
145146 return True
146147
147- create_toml = Confirm .ask (
148+ return Confirm .ask (
148149 "✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?" ,
149150 default = False ,
150151 show_default = True ,
151152 )
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 :
472+ def install_github_actions (override_formatter_check : bool = False ) -> None : # noqa: FBT001, FBT002
473473 try :
474474 config , config_file_path = parse_config_file (override_formatter_check = override_formatter_check )
475475
@@ -566,28 +566,22 @@ def install_github_actions(override_formatter_check: bool = False) -> None:
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
569570 if (Path .cwd () / "poetry.lock" ).exists ():
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
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
591585
592586
593587def get_codeflash_github_action_command (dep_manager : DependencyManager ) -> str :
@@ -642,7 +636,10 @@ def get_github_action_working_directory(toml_path: Path, git_root: Path) -> str:
642636
643637
644638def customize_codeflash_yaml_content (
645- optimize_yml_content : str , config : tuple [dict [str , Any ], Path ], git_root : Path , benchmark_mode : bool = False
639+ optimize_yml_content : str ,
640+ config : tuple [dict [str , Any ], Path ],
641+ git_root : Path ,
642+ benchmark_mode : bool = False , # noqa: FBT001, FBT002
646643) -> str :
647644 module_path = str (Path (config ["module_root" ]).relative_to (git_root ) / "**" )
648645 optimize_yml_content = optimize_yml_content .replace ("{{ codeflash_module_path }}" , module_path )
@@ -878,7 +875,7 @@ def test_sort(self):
878875 input = list(reversed(range(100)))
879876 output = sorter(input)
880877 self.assertEqual(output, list(range(100)))
881- """
878+ """ # noqa: PTH119
882879 elif args .test_framework == "pytest" :
883880 bubble_sort_test_content = f"""from { Path (args .module_root ).name } .bubble_sort import sorter
884881
@@ -959,10 +956,8 @@ def ask_for_telemetry() -> bool:
959956 """Prompt the user to enable or disable telemetry."""
960957 from rich .prompt import Confirm
961958
962- enable_telemetry = Confirm .ask (
959+ return Confirm .ask (
963960 "⚡️ Would you like to enable telemetry to help us improve the Codeflash experience?" ,
964961 default = True ,
965962 show_default = True ,
966963 )
967-
968- return enable_telemetry
0 commit comments