Skip to content

refactor: move FunctionToOptimize to models/function_types to fix circular imports - #1285

Merged
misrasaurabh1 merged 1 commit into
mainfrom
fix/move-function-to-optimize-to-models
Feb 3, 2026
Merged

misrasaurabh1 merged 1 commit into
mainfrom
fix/move-function-to-optimize-to-models

Conversation

@misrasaurabh1

Copy link
Copy Markdown
Contributor

Summary

  • Moves FunctionToOptimize class from discovery/functions_to_optimize.py to models/function_types.py
  • This breaks the circular import chain: env_utils → registry → javascript/support → functions_to_optimize → cfapi → env_utils
  • The models/function_types.py module is designed to be dependency-free

Test plan

  • All existing tests pass (2154 passed, 42 skipped)
  • Import works: from codeflash.discovery.functions_to_optimize import FunctionToOptimize
  • Import works: from codeflash.models.function_types import FunctionToOptimize

🤖 Generated with Claude Code

@misrasaurabh1
misrasaurabh1 force-pushed the fix/move-function-to-optimize-to-models branch from f99cec4 to 371ee1e Compare February 3, 2026 04:00
…cular imports

The FunctionToOptimize class was defined in discovery/functions_to_optimize.py
which has many heavy dependencies (API calls, registry, etc). This caused circular
import issues when modules that needed FunctionToOptimize also needed env_utils.

Moving FunctionToOptimize to models/function_types.py (which is designed to be
dependency-free) breaks the circular import chain.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@misrasaurabh1
misrasaurabh1 force-pushed the fix/move-function-to-optimize-to-models branch from 371ee1e to fd59fb8 Compare February 3, 2026 04:04
@misrasaurabh1
misrasaurabh1 merged commit f21c12e into main Feb 3, 2026
23 of 24 checks passed
@misrasaurabh1
misrasaurabh1 deleted the fix/move-function-to-optimize-to-models branch February 3, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant