Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion codeflash/code_utils/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import tomlkit

PYPROJECT_TOML_CACHE = {}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how many pyproject.toml's are we expecting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at most 2-3 guessing


def find_pyproject_toml(config_file: Path | None = None) -> Path:
# Find the pyproject.toml file on the root of the project
Expand All @@ -19,10 +21,15 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
raise ValueError(msg)
return config_file
dir_path = Path.cwd()

cur_path = dir_path
# see if it was encountered before in search
if cur_path in PYPROJECT_TOML_CACHE:
return PYPROJECT_TOML_CACHE[cur_path]
# map current path to closest file
while dir_path != dir_path.parent:
config_file = dir_path / "pyproject.toml"
if config_file.exists():
PYPROJECT_TOML_CACHE[cur_path] = config_file
return config_file
# Search for pyproject.toml in the parent directories
dir_path = dir_path.parent
Expand Down
Loading