Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#30 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
cli

调研方向

首先阅读 traceback 中显示的 assertion 所在的 poetry_plugin_shell/command.py,尤其是 handle 中的环境检查。将 virtualenvs.create 设置为 false 来重现该情况,并确认当前的 AssertionError。完成的标志是 shell 激活报告虚拟环境创建已禁用,而不是暴露该 assertion。

由索引模型根据 Issue 内容生成。

描述

When attempting to activate the shell in a project with the virtualenvs.create configuration set to false, an AssertionError is raised. While the error itself may not be inherently wrong (since Poetry is expecting a virtual environment), the error message should more clearly indicate that the virtualenvs.create setting has been disabled, preventing the creation of a virtual environment.

How to reproduce:

  1. Create a new project:

    $ poetry new env-issue
    Created package env_issue in env-issue
    $ cd env-issue/
    
  2. Disable virtual environment creation:

    poetry config virtualenvs.create false --local
    
  3. Attempt to activate the Poetry shell:

    $ poetry shell
    Skipping virtualenv creation, as specified in config file.
    Spawning shell within /usr
    
      AssertionError
    

Error traceback:

  at ~/.local/share/pipx/venvs/poetry/lib/python3.13/site-packages/poetry_plugin_shell/command.py:43 in handle
       39│         self.line(f"Spawning shell within {self.env.path}")
       40│ 
       41│         # Be sure that we have the right type of environment.
       42│         env = self.env
    →  43│         assert env.is_venv()
       44│         env = cast("VirtualEnv", env)
       45│ 
       46│         # Setting this to avoid spawning unnecessary nested shells
       47│         os.environ["POETRY_ACTIVE"] = "1"

Expected behavior:

The shell may indeed not be spawned, and that is correct. However, instead of the AssertionError, the error message should clearly indicate that the virtualenvs.create setting is disabled, which prevents Poetry from creating a virtual environment. A more descriptive message, such as "Virtual environment creation is disabled by the configuration," would help clarify the reason for the error.

主要语言
Python
星标
141
派生
10
平均合并
59 分钟
30 天内合并 PR
3

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-poetry/poetry-plugin-shell 的其他 Issue

查看 python-poetry/poetry-plugin-shell 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。