poethepoet
poethepoet copied to clipboard
Including square brackets in arguments does not pass to poe
- version: 0.24.4
- system: macOS
Issue
When including square brackets in an argument (either positional or non-positional), it seems to break how poe sends along the arguments to the actual task.
Reproduction
# pyproject.toml
[tool.poe.tasks.hello]
cmd = "echo $name"
args = [{ name = "name", positional = true }]
This works as expected:
poe hello "world"
Poe => echo world
world
This does not:
poe hello "world[extra]"
Poe => echo
Use Case
I have a sequence command to install poetry packages (poe add
) which runs poetry add $package
, and then a second command to sync them with my dev container:
[tool.poe.tasks.add]
sequence = [{ cmd = "poetry add $package" }, { ref = "sync-dev-deps" }]
args = [{ name = "package", positional = true }]
All good if I'm trying to install something like django
or numpy
, but for something with "extra" packages (ex. django-anymail[mailgun]
), I'm not able to utilize this command and need to fall back to poetry add "django-anymail[mailgun]"
.
Hopefully this isn't documented anywhere - if it is, feel free to point me in that direction and close the issue! Thanks so much for the awesome package, fits my needs exactly.
Hi @stephen-spar, thanks for reporting this issue.
It looks like the square brackets from the argument are getting picked up in the cmd task as glob pattern to be interpreted. I agree that this is surprising, and I'm going to leave this issue open to think about how to improve it.
This is a quirk of the design at the intersection of how cmd tasks implement shell like features (including parameter expansion and glob expansion) and how they interpolate CLI arguments as env vars.
I think you can get around this by quoting the parameter expansion in your task definition like so:
[tool.poe.tasks.add]
sequence = [{ cmd = "poetry add \"$package\"" }, { ref = "sync-dev-deps" }]
args = [{ name = "package", positional = true }]
The logic here is similar to bash, where you can disable glob expansion with quotes.
@nat-n ah, thank you for the workaround - works a treat. Appreciate your quick response, and again, thanks for the phenomenal tool, it vastly improves the DX of the project I'm working on. Keep up the great work!!