madpah / requirements-parser

A Pip requirements file parser.
https://requirements-parser.readthedocs.io
Apache License 2.0
128 stars 42 forks source link

Optional dependencies support #68

Open andriyor opened 2 years ago

andriyor commented 2 years ago

Trying to parse such requirements https://github.com/psf/requests/blob/main/requirements-dev.txt

-e .[socks]
pytest>=2.8.0,<=6.2.5
pytest-cov
pytest-httpbin==1.0.0
pytest-mock==2.0.0
httpbin==0.7.0
trustme
wheel

# Flask Stack
Flask>1.0,<2.0
markupsafe<2.1

and parser produces an error

❯ python req_parse.py
Traceback (most recent call last):
  File "/Users/andrejorehov/PycharmProjects/pypi-github-check/req_parse.py", line 13, in <module>
    for req in requirements.parse(fd):
  File "/Users/andrejorehov/.pyenv/versions/3.9.6/lib/python3.9/site-packages/requirements/parser.py", line 87, in parse
    yield Requirement.parse(line)
  File "/Users/andrejorehov/.pyenv/versions/3.9.6/lib/python3.9/site-packages/requirements/requirement.py", line 251, in parse
    return cls.parse_editable(
  File "/Users/andrejorehov/.pyenv/versions/3.9.6/lib/python3.9/site-packages/requirements/requirement.py", line 157, in parse_editable
    assert local_match is not None, 'This should match everything'
AssertionError: This should match everything
andriyor commented 2 years ago

Also as i know its not recommend to use assertion as error-handling tool. https://realpython.com/python-assert-statement/#when-not-to-use-assertions