Silence spurious errors from dirname
If the poetry executable and a pyproject.toml exist, but the project we're in doesn't use poetry, the two dirname calls spit out an annoying "usage: dirname path" every time we cd.
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 91fafeca53825a591c19f59ca46763275c81afad..2568e816785ee00ef52b9c9a39424fb08364cf8c 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -187,9 +187,11 @@ function check_venv()
6 # we need to infer the target virtualenv directory based on poetry's data
7 # to easiest way is to actually get the location of the python binary and
8 # infer the location of the virtualenv from there.
9- if venv_path="$(dirname $(dirname $(poetry run which python)))"; then
10- _maybeworkon "$venv_path" "poetry"
11- return
12+ if poetry_python=$(poetry run which python); then
13+ if venv_path="$(dirname $(dirname $poetry_python))"; then
14+ _maybeworkon "$venv_path" "poetry"
15+ return
16+ fi
17 fi
18 fi
19