python-poetry / python-poetry/poetry

Add more context to Poetry error messages

Open
#5,885 4 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported errors involving incomplete [tool.poetry.scripts] entries in pyproject.toml and non-semver versions installed in the virtual environment. Trace the relevant parsing and exception-reporting paths; done means errors identify what Poetry was doing and, where possible, the filename, line number, or source text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.