Skip to content

Commit e7c1d00

Browse files
authored
Merge branch 'main' into misc_doc_12_nov
2 parents 7fae3b5 + 0e8f5e4 commit e7c1d00

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,23 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
171171
run_end_to_end_test(args, file_path)
172172

173173

174-
def is_valid_pyproject_toml(pyproject_toml_path: Path) -> tuple[bool, dict[str, Any] | None, str]: # noqa: PLR0911
174+
def config_found(pyproject_toml_path: Union[str, Path]) -> tuple[bool, str]:
175+
pyproject_toml_path = Path(pyproject_toml_path)
176+
175177
if not pyproject_toml_path.exists():
176-
return False, None, f"Configuration file not found: {pyproject_toml_path}"
178+
return False, f"Configuration file not found: {pyproject_toml_path}"
179+
180+
if not pyproject_toml_path.is_file():
181+
return False, f"Configuration file is not a file: {pyproject_toml_path}"
182+
183+
if pyproject_toml_path.suffix != ".toml":
184+
return False, f"Configuration file is not a .toml file: {pyproject_toml_path}"
185+
186+
return True, ""
177187

188+
189+
def is_valid_pyproject_toml(pyproject_toml_path: Union[str, Path]) -> tuple[bool, dict[str, Any] | None, str]:
190+
pyproject_toml_path = Path(pyproject_toml_path)
178191
try:
179192
config, _ = parse_config_file(pyproject_toml_path)
180193
except Exception as e:
@@ -206,6 +219,10 @@ def should_modify_pyproject_toml() -> tuple[bool, dict[str, Any] | None]:
206219

207220
pyproject_toml_path = Path.cwd() / "pyproject.toml"
208221

222+
found, _ = config_found(pyproject_toml_path)
223+
if not found:
224+
return True, None
225+
209226
valid, config, _message = is_valid_pyproject_toml(pyproject_toml_path)
210227
if not valid:
211228
# needs to be re-configured

codeflash/discovery/functions_to_optimize.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ def is_git_repo(file_path: str) -> bool:
405405
def ignored_submodule_paths(module_root: str) -> list[str]:
406406
if is_git_repo(module_root):
407407
git_repo = git.Repo(module_root, search_parent_directories=True)
408-
return [Path(git_repo.working_tree_dir, submodule.path).resolve() for submodule in git_repo.submodules]
408+
try:
409+
return [Path(git_repo.working_tree_dir, submodule.path).resolve() for submodule in git_repo.submodules]
410+
except Exception as e:
411+
logger.warning(f"Error getting submodule paths: {e}")
409412
return []
410413

411414

codeflash/lsp/beta.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from codeflash.cli_cmds.cmd_init import (
1515
CommonSections,
1616
VsCodeSetupInfo,
17+
config_found,
1718
configure_pyproject_toml,
1819
create_empty_pyproject_toml,
1920
create_find_common_tags_file,
@@ -263,6 +264,10 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
263264
"root": root,
264265
}
265266

267+
found, message = config_found(pyproject_toml_path)
268+
if not found:
269+
return {"status": "error", "message": message}
270+
266271
valid, config, reason = is_valid_pyproject_toml(pyproject_toml_path)
267272
if not valid:
268273
return {

codeflash/tracing/tracing_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def ignored_submodule_paths(module_root: str) -> list[Path]:
3838
if is_git_repo(module_root):
3939
git_repo = git.Repo(module_root, search_parent_directories=True)
4040
working_tree_dir = cast("Path", git_repo.working_tree_dir)
41-
return [Path(working_tree_dir, submodule.path).resolve() for submodule in git_repo.submodules]
41+
try:
42+
return [Path(working_tree_dir, submodule.path).resolve() for submodule in git_repo.submodules]
43+
except Exception as e:
44+
print(f"Failed to get submodule paths {e!s}") # no logger since used in the tracer
4245
return []
4346

4447

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.18.3"
2+
__version__ = "0.18.4"

0 commit comments

Comments
 (0)