Skip to content

Commit

Permalink
Permit arbitrary whitespace around versions specifier in parenthesis
Browse files Browse the repository at this point in the history
This is more consistent with the rest of the format which is largely
whitespace agnostic.
  • Loading branch information
pradyunsg committed Dec 7, 2022
1 parent e7ce051 commit b997a48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packaging/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ def _parse_extras_list(tokenizer: Tokenizer) -> List[str]:

def _parse_specifier(tokenizer: Tokenizer) -> str:
"""
specifier = LEFT_PARENTHESIS version_many RIGHT_PARENTHESIS
| version_many
specifier = LEFT_PARENTHESIS WS? version_many WS? RIGHT_PARENTHESIS
| WS? version_many WS?
"""
with tokenizer.enclosing_tokens("LEFT_PARENTHESIS", "RIGHT_PARENTHESIS"):
tokenizer.consume("WS")
parsed_specifiers = _parse_version_many(tokenizer)
tokenizer.consume("WS")

return parsed_specifiers

Expand Down
4 changes: 2 additions & 2 deletions tests/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
("git+https://git.example.com/[email protected]", ""),
("git+https://git.example.com/MyProject.git@refs/pull/123/head", ""),
(None, "==={ws}arbitrarystring"),
(None, "(==={ws}arbitrarystring)"),
(None, "({ws}==={ws}arbitrarystring{ws})"),
(None, "=={ws}1.0"),
(None, "(=={ws}1.0)"),
(None, "({ws}=={ws}1.0{ws})"),
(None, "<={ws}1!3.0.0.rc2"),
(None, ">{ws}2.2{ws},{ws}<{ws}3"),
(None, "(>{ws}2.2{ws},{ws}<{ws}3)"),
Expand Down

0 comments on commit b997a48

Please sign in to comment.