File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from functools import cache
43from pathlib import Path
54from typing import Any
65
76import tomlkit
87
8+ PYPROJECT_TOML_CACHE = {}
9+
910
10- @cache
1111def find_pyproject_toml (config_file : Path | None = None ) -> Path :
1212 # Find the pyproject.toml file on the root of the project
1313
@@ -21,10 +21,15 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
2121 raise ValueError (msg )
2222 return config_file
2323 dir_path = Path .cwd ()
24-
24+ cur_path = dir_path
25+ # see if it was encountered before in search
26+ if cur_path in PYPROJECT_TOML_CACHE :
27+ return PYPROJECT_TOML_CACHE [cur_path ]
28+ # map current path to closest file
2529 while dir_path != dir_path .parent :
2630 config_file = dir_path / "pyproject.toml"
2731 if config_file .exists ():
32+ PYPROJECT_TOML_CACHE [cur_path ] = config_file
2833 return config_file
2934 # Search for pyproject.toml in the parent directories
3035 dir_path = dir_path .parent
@@ -33,7 +38,6 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
3338 raise ValueError (msg )
3439
3540
36- @cache
3741def find_conftest_files (test_paths : list [Path ]) -> list [Path ]:
3842 list_of_conftest_files = set ()
3943 for test_path in test_paths :
You can’t perform that action at this time.
0 commit comments