tox-dev/pyproject-fmt

Version at `main` branch is currently not able to handle PEP 508 properly

abravalheri opened this issue · 4 comments

Describe the bug
In #4 I was just experimenting with pyproject-fmt and the examples in the PEP 508 text, and I noticed that the current version of the project (bleeding edge at the main branch), cannot handle complex requirements very well.

To Reproduce

  1. Clone the repository and install it (master branch) in a virtual environment
  2. Open a Python REPL and perform some simple tests using examples from PEP 508:
    >>> from pyproject_fmt.formatter import pep508
    >>> pep508.normalize_req("name [fred,bar] @ http://foo.com ; python_version=='2.7'")
    "name@http://foo.com ;python_version=='2.7'"
    >>> pep508.normalize_req("name[quux, strange];python_version<'2.7' and platform_version=='2'")
    "name[quux,;python_version<'2.7' and platform_version=='2'"
    >>>
  3. Note here that in the first example, the extras got removed from the requirement string, and in the second example, the resulting requirement is invalid and violates PEP 508 grammar.

Expected behavior
Requirement normalisation should not change the meaning of the requirement or produce invalid strings

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Ubuntu 20.04.3 LTS
  • Python 3.8.10

I added the examples in #7, so they can be identified more easily.

On reflection, I'd be ok to swap to packaging instead of our own in-house rolled normalization. 👍

Perfect, I will go ahead and prepare the PR (probably re-use the same one with the test - #7).

This is now done via #2