File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,24 @@ def find_conftest_files(test_paths: list[Path]) -> list[Path]:
8888def parse_config_file (
8989 config_file_path : Path | None = None , override_formatter_check : bool = False
9090) -> tuple [dict [str , Any ], Path ]:
91- # First try package.json for JS/TS projects
9291 package_json_path = find_package_json (config_file_path )
92+ pyproject_toml_path = find_closest_config_file ("pyproject.toml" ) if config_file_path is None else None
93+
94+ # When both config files exist, prefer the one closer to CWD.
95+ # This prevents a parent-directory package.json (e.g., monorepo root)
96+ # from overriding a closer pyproject.toml with [tool.codeflash].
97+ use_package_json = False
9398 if package_json_path :
99+ if pyproject_toml_path is None :
100+ use_package_json = True
101+ else :
102+ # Compare depth: more path parts = closer to CWD = more specific
103+ package_json_depth = len (package_json_path .parent .parts )
104+ pyproject_toml_depth = len (pyproject_toml_path .parent .parts )
105+ use_package_json = package_json_depth >= pyproject_toml_depth
106+
107+ if use_package_json :
108+ assert package_json_path is not None
94109 result = parse_package_json_config (package_json_path )
95110 if result is not None :
96111 config , path = result
You can’t perform that action at this time.
0 commit comments