madpah / madpah/requirements-parser

Line continuations are not parsed correctly

Open
#52 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
141
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Given a file line-bug.txt with the following contents
```
requests==2.25.0 \
# comment
```
```py3
import requirements
list(requirements.parse(Path('line-bug.txt').read_text(encoding='utf8')))
```
throws an exception
```
...
~/.local/share/virtualenvs/pip-OwC7W1fl/lib/python3.8/site-packages/pkg_resources/__init__.py in parse(s)
3133 @staticmethod
3134 def parse(s):
-> 3135 req, = parse_requirements(s)
3136 return req
3137

ValueError: not enough values to unpack (expected 1, got 0)
```

But pip works fine:
```
pip install --target "`mktemp -d`" -r line-bug.txt
```

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 failure with the line-bug.txt contents and the requirements.parse call shown in the issue. Trace how the parser handles the continued line followed by a comment; done means this input parses without an exception, consistent with pip install -r.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.