Skip to content

Add more context to Poetry error messages #5885

@MSLeiter

Description

@MSLeiter
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

I'm using Poetry 1.1.13.

I've recently gotten some Poetry errors for the first time. When Poetry works, it just works and it's great, but when Poetry has an issue it does not provide any context - at least with the 2 errors I've seen so far. This makes it difficult to understand what the issue is and how to even find the general thing that is causing the issue.

For example, I was getting a "ValueError - not enough values to unpack (expected 2, got 1)" for a script entry that was not complete in pyproject.toml, but Poetry only gives the quoted error statement, without mentioning that it was trying to parse the [tool.poetry.scripts] section of pyproject.toml, or that this was during pyproject.toml parsing at all. Preferrably it would also give the line number where the error occurred.

The other error was attempting to parse a non-semver version that was installed to the venv - again, no context to understand what Poetry was trying to do at the time. Thankfully I had just installed that alternate package, and the version name itself was clear, but I didn't know Poetry could fail just parsing the version of an item that was installed to the venv, that Poetry didn't install itself or was mentioned in pyproject.toml at all as a dependency (I hadn't done anything with it yet), so it was originally quiet stunning to get a message that Poetry could not parse a version when I hadn't changed my pyproject.toml at all.

Request:

Please add more context to the error messages, where possible. We need to at least know what Poetry was doing generally, or what line of which file it was parsing, etc. to be able to decipher what is going on.

Some possibilities:

  1. If there is a parse error, print the filename and line number (if line number is possible), or print the text that was attempting to be parsed (i.e. perhaps the raw line of text prior to parsing). With the raw text, we can search our files to find the problem location.
  2. Currently the errors only show the final piece of the exception call stack - maybe Poetry should print the entire call stack? I realize often the additional steps are not needed and take up a lot of space in the shell, but sometimes they are required to understand what went wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFeature requests/implementationsstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions