Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add validation check for -C/--directory flag argument #9852

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 6 additions & 1 deletion src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def _default_definition(self) -> Definition:
description=(
"The working directory for the Poetry command (defaults to the"
" current working directory)."
" The Poetry project will be selected automatically using this path"
),
)
)
Expand All @@ -371,7 +372,11 @@ def _default_definition(self) -> Definition:
@cached_property
def _directory(self) -> Path:
if self._io and self._io.input.option("directory"):
return Path(self._io.input.option("directory")).absolute()
path = Path(self._io.input.option("directory")).absolute()
if not (path / "pyproject.toml").exists():
raise ValueError(f"Could not find a project in directory {path}")
return path

return Path.cwd()


Expand Down