python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.72k stars 2.27k forks source link

Report actual pyproject.toml error text in event of InvalidRequirement error #1739

Open shintoo opened 4 years ago

shintoo commented 4 years ago

Feature Request

Upon a parse error of a package name in pyproject.toml, poetry reports the a portion of the malformed package name in its canonicalized form, with no indication that it is canonicalized, and reports characters following the error, but not including the error.

Example:

[tool.poetry]
name = "Malformed PackageName"
version= "1.0"
description = "The package name should not have spaces"
authors = [ "shintoo" ]

Running e.g. poetry update produces the following error:

[InvalidRequirement]                 
Invalid requirement, parse error at "'packagen'"  

As the text does not match the actual text in pyproject.toml, it becomes more difficult to track down the source of the user error, especially considering that it merely reports the 8 characters following the error location (but not the error itself). Poetry should report the actual text that is malformed in order to aid the user in fixing their error.

shintoo commented 4 years ago

The error string is generated in the __init__() of the Requirement class in requirements.py.