Handle missing virtualenv in shell command#60
Conversation
StantonMatt
left a comment
There was a problem hiding this comment.
I checked this locally because it covers the virtualenvs.create=false path from #30.
On the PR branch, a scratch project with local virtualenvs.create false now returns exit code 1 with the new user-facing message instead of reaching the assertion, and it no longer prints the misleading Spawning shell within ... line first.
Local checks I ran on Python 3.12.13:
.venv/bin/python -m pytest -q tests/test_shell_command.py::test_shell_without_virtualenv_shows_error.venv/bin/python -m pytest -q.venv/bin/python -m ruff check src/poetry_plugin_shell/command.py tests/test_shell_command.py.venv/bin/python -m mypy src/poetry_plugin_shell/command.py tests/test_shell_command.py
I do not see a blocking issue from this pass.
yangfan-yf-yf
left a comment
There was a problem hiding this comment.
I reviewed the current head d3ea749 independently. The non-virtual environment path is now checked before the spawn message and before the VirtualEnv cast. The regression test verifies the intended user-facing error, exit status 1, no Shell.activate() call, and absence of the misleading spawn line.
Local verification on Windows with Python 3.12:
python -m pytest -q— 18 passedpython -m ruff check src/poetry_plugin_shell/command.py tests/test_shell_command.pypython -m ruff format --check src/poetry_plugin_shell/command.py tests/test_shell_command.pypython -m mypy src/poetry_plugin_shell/command.py tests/test_shell_command.pygit diff --check
The GitHub Ubuntu, macOS, and Windows matrix is green on the current head.
Fixes #30.
This replaces the internal assertion when
poetry shellis run without a virtualenv with a user-facing error. It also avoids printing the misleadingSpawning shell within ...line before the environment type is validated.Checks:
pytest tests/test_shell_command.py -q -n 0ruff check src/poetry_plugin_shell/command.py tests/test_shell_command.pyruff format --check src/poetry_plugin_shell/command.py tests/test_shell_command.pypre-commit run --all-files