Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to parse requirement with trailing whitespace #649

Closed
gaborbernat opened this issue Dec 26, 2022 · 1 comment
Closed

Fails to parse requirement with trailing whitespace #649

gaborbernat opened this issue Dec 26, 2022 · 1 comment

Comments

@gaborbernat
Copy link

gaborbernat commented Dec 26, 2022

from packaging.requirements import Requirement

req = "pycontracts @ https://github.com/slorg1/contracts/archive/c5a6da27d4dc9985f68e574d20d86000880919c3.zip "
Requirement(req)
packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after URL and whitespace)
    pycontracts @ https://github.com/slorg1/contracts/archive/c5a6da27d4dc9985f68e574d20d86000880919c3.zip 
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bgabor8/git/github/tox/magic.py", line 4, in <module>
    Requirement(req)
  File "/Users/bgabor8/git/github/tox/.tox/dev/lib/python3.11/site-packages/packaging/requirements.py", line 37, in __init__
    raise InvalidRequirement(str(e)) from e
packaging.requirements.InvalidRequirement: Expected end or semicolon (after URL and whitespace)
    pycontracts @ https://github.com/slorg1/contracts/archive/c5a6da27d4dc9985f68e574d20d86000880919c3.zip 
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Would you happen to know if this is expected? If you remove the trailing whitespace, the parsing succeeds. Parsing attrs works, so this is slightly unexpected. Initially reported via tox-dev/tox#2773

@pradyunsg
Copy link
Member

Covered by #642.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants