fix(poetry-env): fix env detection for pyproject without [tool.poetry]

Since version 2.0.0, poetry stopped requiring '[tool.poetry]' section in pyproject.toml and new environments are created without it, but the zsh plugin still required it.

With this change, the plugin will check for `pyproject.toml` and `poetry.lock` files to reliably check if it's a poetry project. Tested with both poetry versions 1.8.5, 2.0.1 and 2.1.2.
This commit is contained in:
Jacob Rogers 2025-08-12 15:12:20 +12:00
commit 3a6f538109

View file

@ -1,7 +1,7 @@
_togglePoetryShell() { _togglePoetryShell() {
# Determine if currently in a Poetry-managed directory # Determine if currently in a Poetry-managed directory
local in_poetry_dir=0 local in_poetry_dir=0
if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then if [[ -f "$PWD/pyproject.toml" && -f "$PWD/poetry.lock" ]]; then
in_poetry_dir=1 in_poetry_dir=1
fi fi