Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions codeflash/context/code_context_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def get_function_to_optimize_as_function_source(
name.type == "function"
and name.full_name
and name.name == function_to_optimize.function_name
and name.full_name.startswith(name.module_name)
and get_qualified_name(name.module_name, name.full_name) == function_to_optimize.qualified_name
):
function_source = FunctionSource(
Expand Down Expand Up @@ -410,6 +411,7 @@ def get_function_sources_from_jedi(
and definition.full_name
and definition.type == "function"
and not belongs_to_function_qualified(definition, qualified_function_name)
and definition.full_name.startswith(definition.module_name)
# Avoid nested functions or classes. Only class.function is allowed
and len((qualified_name := get_qualified_name(definition.module_name, definition.full_name)).split(".")) <= 2
):
Expand Down
2 changes: 1 addition & 1 deletion codeflash/optimization/function_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def belongs_to_class(name: Name, class_name: str) -> bool:
def belongs_to_function_qualified(name: Name, qualified_function_name: str) -> bool:
"""Check if the given jedi Name is a direct child of the specified function, matched by qualified function name."""
try:
if get_qualified_name(name.module_name, name.full_name) == qualified_function_name:
if name.full_name.startswith(name.module_name) and get_qualified_name(name.module_name, name.full_name) == qualified_function_name:
# Handles function definition and recursive function calls
return False
if name := name.parent():
Expand Down
Loading