Skip to content
Merged
Changes from all 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
8 changes: 7 additions & 1 deletion codeflash/code_utils/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import tomlkit

PYPROJECT_TOML_CACHE = {}
ALL_CONFIG_FILES = {} # map path to closest config file

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


Expand All @@ -21,10 +22,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