Skip to content

Commit

Permalink
Allow leading digit in PEP 508 dependency (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jun 20, 2023
1 parent 0749c55 commit 5e85c04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/poetry/core/version/grammars/pep508.lark
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _single_version: LEGACY_VERSION_CONSTRAINT
_url: _AT URI
marker_spec: marker

NAME: /[a-zA-Z][a-zA-Z0-9-_.]*/
NAME: /[a-zA-Z0-9][a-zA-Z0-9-_.]*/
FULL_NAME: NAME
EXTRA: NAME
VERSION_CONSTRAINT: /(~=|==|!=|<=|>=|<|>|===)((?:(?<====)\s*[^\s]*)|(?:(?<===|!=)\s*v?(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*(?:[-_.]?(a|b|c|rc|alpha|beta|pre|preview)[-_.]?[0-9]*)?(?:(?:-[0-9]+)|(?:[-_.]?(post|rev|r)[-_.]?[0-9]*))?(?:(?:[-_.]?dev[-_.]?[0-9]*)?(?:\+[a-z0-9]+(?:[-_.][a-z0-9]+)*)? # local|\.\*)?)|(?:(?<=~=)\s*v?(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)+(?:[-_.]?(a|b|c|rc|alpha|beta|pre|preview)[-_.]?[0-9]*)?(?:(?:-[0-9]+)|(?:[-_.]?(post|rev|r)[-_.]?[0-9]*))?(?:[-_.]?dev[-_.]?[0-9]*)?)|(?:(?<!==|!=|~=)\s*v?(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*(?:[-_.]?(a|b|c|rc|alpha|beta|pre|preview)[-_.]?[0-9]*)?(?:(?:-[0-9]+)|(?:[-_.]?(post|rev|r)[-_.]?[0-9]*))?(?:[-_.]?dev[-_.]?[0-9]*)?))/i
Expand Down
5 changes: 5 additions & 0 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ def test_create_from_pep_508_url_with_activated_extras() -> None:
assert dependency.extras == {"fred", "bar"}


def test_create_from_pep_508_starting_with_digit() -> None:
dependency = Dependency.create_from_pep_508("2captcha-python")
assert dependency.name == "2captcha-python"


@pytest.mark.parametrize(
"dependency1, dependency2, expected",
[
Expand Down

0 comments on commit 5e85c04

Please sign in to comment.