File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 55
66import tomlkit
77
8+ PYPROJECT_TOML_CACHE = {}
89ALL_CONFIG_FILES = {} # map path to closest config file
910
1011
@@ -21,10 +22,15 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
2122 raise ValueError (msg )
2223 return config_file
2324 dir_path = Path .cwd ()
24-
25+ cur_path = dir_path
26+ # see if it was encountered before in search
27+ if cur_path in PYPROJECT_TOML_CACHE :
28+ return PYPROJECT_TOML_CACHE [cur_path ]
29+ # map current path to closest file
2530 while dir_path != dir_path .parent :
2631 config_file = dir_path / "pyproject.toml"
2732 if config_file .exists ():
33+ PYPROJECT_TOML_CACHE [cur_path ] = config_file
2834 return config_file
2935 # Search for pyproject.toml in the parent directories
3036 dir_path = dir_path .parent
You can’t perform that action at this time.
0 commit comments