refactor: locate project root by pyproject.toml marker
This commit is contained in:
+7
-1
@@ -33,7 +33,13 @@ def is_wecker_ringing() -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def _project_root() -> Path:
|
def _project_root() -> Path:
|
||||||
return Path(__file__).parent.parent.absolute()
|
"""Locate the project root by searching upward for pyproject.toml."""
|
||||||
|
start = Path(__file__).resolve()
|
||||||
|
for parent in start.parents:
|
||||||
|
if (parent / "pyproject.toml").exists():
|
||||||
|
return parent
|
||||||
|
# Fallback for unusual layouts; keep a sensible default.
|
||||||
|
return start.parent.parent
|
||||||
|
|
||||||
|
|
||||||
def _default_command() -> str:
|
def _default_command() -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user