Skip to content

Handle missing virtualenv in shell command#60

Open
bubaizhanshen wants to merge 1 commit into
python-poetry:mainfrom
bubaizhanshen:fix-non-venv-shell-error
Open

Handle missing virtualenv in shell command#60
bubaizhanshen wants to merge 1 commit into
python-poetry:mainfrom
bubaizhanshen:fix-non-venv-shell-error

Conversation

@bubaizhanshen
Copy link
Copy Markdown

@bubaizhanshen bubaizhanshen commented Jun 1, 2026

Fixes #30.

This replaces the internal assertion when poetry shell is run without a virtualenv with a user-facing error. It also avoids printing the misleading Spawning shell within ... line before the environment type is validated.

Checks:

  • pytest tests/test_shell_command.py -q -n 0
  • ruff check src/poetry_plugin_shell/command.py tests/test_shell_command.py
  • ruff format --check src/poetry_plugin_shell/command.py tests/test_shell_command.py
  • pre-commit run --all-files

Copy link
Copy Markdown

@StantonMatt StantonMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError when spawning shell with "virtualenvs.create" set to false

2 participants