Skip to content

Commit d7186b2

Browse files
committed
function discovery tests
1 parent c4089f6 commit d7186b2

2 files changed

Lines changed: 545 additions & 5 deletions

File tree

codeflash/discovery/functions_to_optimize.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,18 @@ def filter_functions(
827827
if not file_path_normalized.startswith(module_root_str + os.sep):
828828
non_modules_removed_count += len(_functions)
829829
continue
830-
try:
831-
ast.parse(f"import {module_name_from_file_path(Path(file_path), project_root)}")
832-
except SyntaxError:
833-
malformed_paths_count += 1
834-
continue
830+
831+
# TODO for claude: make this work only for python, not when its not js
832+
# Check if module path is valid - only for Python files
833+
# JavaScript files don't have the same import constraints
834+
file_ext = Path(file_path).suffix.lower()
835+
is_javascript = file_ext in (".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx")
836+
if not is_javascript:
837+
try:
838+
ast.parse(f"import {module_name_from_file_path(Path(file_path), project_root)}")
839+
except SyntaxError:
840+
malformed_paths_count += 1
841+
continue
835842

836843
if blocklist_funcs:
837844
functions_tmp = []

0 commit comments

Comments
 (0)