Poetry: `poetry run` could handle args better

Created on 28 Jul 2020  路  1Comment  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Ubuntu 20.04

  • Poetry version: 1.0.10
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

When bad arguments are passed to poetry run, it is not immediately obvious what is wrong.

When no argument is provided, poetry run does not complain about the missing argument:

$poetry run

[FileNotFoundError]
[Errno 2] No such file or directory

Contrast with poetry new:

$poetry new
Not enough arguments (missing: "path").

Similarly, if given a flag, it might not be obvious that it is looking for an executable:

$poetry run --help

[FileNotFoundError]
[Errno 2] No such file or directory
Bug CLI Error Handling Triage

>All comments

In the current implementation, it appears that when poetry run is called without any additional parameter, run is passed as the only argument to the run command. Effectively, it is the same as poetry run run, which explains why you are seeing a "No such file or directory error.

I'm not sure why RunCommand implements a custom argument parser. If I remove RunCommand.__init__, the code seems to behave as one would expect. Running the single test test_run_passes_all_args seems to indicate there is custom logic that is necessary as otherwise the CLI parser considers poetry run python -V as similar to poetry -V and thus gets interrupted during the PRE_HANDLE step of the command dispatcher.

What I suggested seems to be what @sdispater did @ 65ba952f2db1ce400a3153575db7c5b42f398885, which was then reverted back @ 8fb4f4524dbe8603e7fd7bba390b2a7e72eb3ae9, so it appears to be a current limitation with clikit.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EdgyEdgemond picture EdgyEdgemond  路  3Comments

probablykasper picture probablykasper  路  3Comments

tonysyu picture tonysyu  路  3Comments

sobolevn picture sobolevn  路  3Comments

ulope picture ulope  路  3Comments